Skip to content
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

[Bug] MergedOptions UpdateMergedOptionsFromMicrosoftIdentityOptions error #1215

Closed
2 of 8 tasks
JadynWong opened this issue May 26, 2021 · 2 comments
Closed
2 of 8 tasks
Labels
bug Something isn't working fixed regression regression between Microsoft Identity Web versions
Milestone

Comments

@JadynWong
Copy link

JadynWong commented May 26, 2021

Which version of Microsoft Identity Web are you using?
Note that to get help, you need to run the latest version.
1.11.0
1.10.0

Where is the issue?

  • Web app
    • Sign-in users
    • Sign-in users and call web APIs
  • Web API
    • Protected web APIs (validating tokens)
    • Protected web APIs (validating scopes)
    • Protected web APIs call downstream web APIs
  • Token cache serialization
    • In-memory caches
    • Session caches
    • Distributed caches
  • Other (please describe)

Is this a new or an existing app?
The app is in development and I have upgraded to a new version of Microsoft Identity Web.

Repro

context.Services.AddAuthentication()
                .AddMicrosoftIdentityWebApp(
                    configuration: configuration,
                    configSectionName: "AzureAd",
                    openIdConnectScheme: OpenIdConnectDefaults.AuthenticationScheme,
                    cookieScheme: null,
                    subscribeToOpenIdConnectMiddlewareDiagnosticsEvents: false
                );
  "AzureAd": {
    "Instance": "https://login.microsoftonline.com/",
    "Domain": "contoso.com",
    "TenantId": "xxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "ClientId": "xxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "ClientSecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "CallbackPath": "/signin-oidc",
    "SignedOutCallbackPath ": "/signout-callback-oidc",
    "ResponseType": "code id_token",
    "Scope": [ "email" ]
  },

builder.Services.AddOptions<OpenIdConnectOptions>(openIdConnectScheme)
.Configure<IServiceProvider, IOptionsMonitor<MergedOptions>, IOptionsMonitor<MicrosoftIdentityOptions>, IOptions<MicrosoftIdentityOptions>>((
options,
serviceProvider,
mergedOptionsMonitor,
msIdOptionsMonitor,
msIdOptions) =>
{
MergedOptions mergedOptions = mergedOptionsMonitor.Get(openIdConnectScheme);
MergedOptions.UpdateMergedOptionsFromMicrosoftIdentityOptions(msIdOptions.Value, mergedOptions);
MergedOptions.UpdateMergedOptionsFromMicrosoftIdentityOptions(msIdOptionsMonitor.Get(openIdConnectScheme), mergedOptions);
MergedOptionsValidation.Validate(mergedOptions);
PopulateOpenIdOptionsFromMergedOptions(options, mergedOptions);
var b2cOidcHandlers = new AzureADB2COpenIDConnectEventHandlers(

if (string.IsNullOrEmpty(mergedOptions.ResponseMode) && !string.IsNullOrEmpty(microsoftIdentityOptions.ResponseMode))
{
mergedOptions.ResponseMode = microsoftIdentityOptions.ResponseMode;
}
if (string.IsNullOrEmpty(mergedOptions.ResponseType) && !string.IsNullOrEmpty(microsoftIdentityOptions.ResponseType))
{
mergedOptions.ResponseType = microsoftIdentityOptions.ResponseType;
}

Expected behavior
ResponseType should is code id_token
Scope should is openid profile email

Actual behavior
ResponseType should is id_token
Scope should is openid profile

Possible solution

 Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme, options =>
{
    options.Scope.Add("email");
    options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
});

Some properties of OpenIdConnectOptions have default values, such as ResponseType,Scope,ResponseMode etc.
There are some problems with the current MergedOptions method.

Additional context / logs / screenshots
code

@jmprieur
Copy link
Collaborator

Thanks @JadynWong for the heads-up and for your analysis

@jmprieur jmprieur added regression regression between Microsoft Identity Web versions bug Something isn't working labels May 26, 2021
@jmprieur jmprieur added this to the 1.12.0 milestone May 26, 2021
@jennyf19 jennyf19 added the fixed label May 28, 2021
@jmprieur
Copy link
Collaborator

jmprieur commented Jun 2, 2021

@JadynWong: this is fixed in 1.12.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed regression regression between Microsoft Identity Web versions
Projects
None yet
Development

No branches or pull requests

3 participants