Skip to content

Incorrect base url for azuread b2c backend #809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zahid-arbisoft opened this issue Jul 12, 2023 · 5 comments · Fixed by #1013
Closed

Incorrect base url for azuread b2c backend #809

zahid-arbisoft opened this issue Jul 12, 2023 · 5 comments · Fixed by #1013

Comments

@zahid-arbisoft
Copy link

As per this documentation, I think the base URL for backend "azuread-b2c-oauth2" for custom domain should be

BASE_URL = "https://{authority_host}/{tenant_name}.onmicrosoft.com"

but not

BASE_URL = "https://{tenant_name}.{authority_host}/{tenant_name}.onmicrosoft.com"

From Azure documentation:

With Azure AD B2C custom domain the corresponding updated endpoint would look like:

https://login.contoso.com/.onmicrosoft.com//oauth2/v2.0/authorize
https://login.contoso.com/.onmicrosoft.com/oauth2/v2.0/authorize?p=

@nijel
Copy link
Member

nijel commented Jul 13, 2023

This change was done in #777 by @zchoate

@zchoate
Copy link
Contributor

zchoate commented Jul 14, 2023

When I put together the PR, I didn't take into account the custom domains feature of b2c. I was just using b2clogin.com. Does it make sense to create a separate backend like azuread-b2c-custom-oauth2 for custom domains?

@olehy
Copy link

olehy commented Aug 9, 2023

I think the change also broke the URL for endpoints which do not contain a policy parameter, as described in https://learn.microsoft.com/en-us/azure/active-directory-b2c/b2clogin#endpoints-that-are-not-affected

Obviously Microsoft has now (at least) three different ways to compose the base url which need to be distinguished.

@nijel
Copy link
Member

nijel commented Aug 9, 2023

It would also be great to cover this topic in the documentation so that users know which backend to choose in which situation: https://github.com/python-social-auth/social-docs/blob/master/docs/backends/azuread.rst

@Danyal-Faheem
Copy link
Contributor

Hi, has there been any update on this issue. We are still facing the same issue as mentioned by @zahid-arbisoft. There is support for using just the authority host in other languages and frameworks but it breaks for python.

Danyal-Faheem added a commit to Danyal-Faheem/social-core that referenced this issue Feb 3, 2025
fixes python-social-auth#809.

The Authority Host can be defined to be a custom domain as well using front door in Azure. With this, the tenant name is not prefixed to the authority host in the base url.

We update this by prefixing the tenant name with the default authority host only if the authority host is not defined.
@nijel nijel closed this as completed in 3ae54a3 Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

5 participants