-
Notifications
You must be signed in to change notification settings - Fork 218
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
[Feature Request] Id.Web supports CIAM custom user domains #2690
Comments
Hi @jennyf19 - would you like MSAL to drop its restriction on setting the tenant for OIDC authorities? This could help ID.Web looks for the I think the web api use of |
|
This change is breaking my AAD-tenanted auth scenario, which now complains that it can't use TenantId with "Generic" authority. |
@benjaminclewis : when you use |
I wasn't setting Authority, at least not in my appsettings or anywhere explicitly that I'm aware of. I can go back and double check when I have a moment but I worked around my issue by rolling back to 2.17.1 for now. |
I've confirmed I'm not setting Authority, it appears to be getting set in internal Microsoft.Identity.Web code, in MergedOptions.UpdateMergedOptionsFromMicrosoftIdentityApplicationOptions, which gets it as (Instance?.TrimEnd('/') + "/" + TenantId + "/v2.0") if it's null in MicrosoftIdentityApplicationOptions. |
@benjaminclewis : would you mind sharing your appsettings.json or AddMicrosoftWebXXX code? |
|
|
I get the error when calling either tokenAcquisition.GetAccessTokenForAppAsync(scope) or tokenAcquisition.GetAccessTokenForUserAsync(scopes) from an endpoint handler. (But I do NOT get the error when I call tokenAcquisition.GetAccessTokenForAppAsync(scope) in a hosted service that runs at startup) |
would you have a small repro? |
Sorry, not immediately, but if I get some time I can try to cook one up. |
Okay, I've made a smaller project that reproduces the issues, and in doing so I've noticed that the issue is only occurring if I call ITokenAcquisition method(s) first in my hosted service (which works) and then in the endpoint handler (which fails). If I don't start the hosted service the error does not happen in the endpoint handler. If you'd prefer some other format let me know. Note this one requires you have azure app registrations set up for the web api and the downstream service, and needs to have appsettings updated accordingly. |
FWIW, I get the "can't use TenantId with "Generic" authority." when using a GraphSerivceClient via e.g.
my appsettings AzureAD section: "AzureAd": { 2.17.1 does not have this issue. Removing tenantId and including it in the instance doesn't help either. |
This problem is still occurring with latest versions, I still have to use the old version 2.17.1 for my project to run. I suppose I should file a new issue? |
API experience
Add support for CIAM CUD authorities. See https://microsoft-my.sharepoint-df.com/:w:/p/jmprieur/EbtMcuWkuyRKnWTR8Fg9EAsBMn22Sy5Kni6YWOxTfYWjtg?e=GGad0r for spec
Technical details
In MergedOptions:
PreserveAuthority
MergedOptions.ParseAuthorityIfNecessary
, only set themergedOptions.TenantId
ifmergedOptions.PreserveAuthority
is false (as MSAL.NET does not want a tenantId when.WithOidcAuthority
is used)In
AuthorityHelper.BuildCiamAuthorityIfNeeded
, have a new out bool parameterpreserveAuthority
, which will be set to false if the authority is a CiamLogin.com authority and otherwise to trueIn
MicrosoftIdentityWebApiAuthenticationBuilderExtensions.cs
andWebAppExtensions\MicrosoftIdentityWebAppAuthenticationBuilderExtensions.cs
, after callingAuthorityHelper.BuildCiamAuthorityIfNeeded
, setmergedOptions.PreserveAuthority
based on the value of the out parameter.In
TokenAcquisition.BuildConfidentialClientApplicationAsync()
mergedOptions.PreserveAuthority
is true, set the authority tomergedOptions.Authority
and callbuilder.WithOidcAuthority(authority)
,otherwise do as today (WithAuthority, and WithB2CAuthority)
Need to MSAL 4.60.0-preview to get
builder.WithOidcAuthority(authority)
Testing resources
MSAL 4.60.0-preview and a CIAM CUD test tenant can be found at https://microsofteur-my.sharepoint.com/:f:/g/personal/bogavril_microsoft_com/EoEwmcgN3oJAplznhkE-OosBAQc4xl7I2sNVC8TfDFR_JA?e=8M82R9
CIAM CUD is not currently available in the Lab.
The text was updated successfully, but these errors were encountered: