Skip to content

protected web api with GetAadIssuerValidator #189

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

Open
jrmcdona opened this issue Mar 14, 2021 · 1 comment
Open

protected web api with GetAadIssuerValidator #189

jrmcdona opened this issue Mar 14, 2021 · 1 comment
Labels
answered question Further information is requested

Comments

@jrmcdona
Copy link

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ x] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

I am using .NET 5.0 and trying to validate the issuer. Do we have any samples doing this? I have not figure out how to get the service provider (IServiceProvider) in order to call GetRequiredService,

                MicrosoftIdentityIssuerValidatorFactory microsoftIdentityIssuerValidatorFactory =
                **_serviceProvider**.GetRequiredService<MicrosoftIdentityIssuerValidatorFactory>();

                options.TokenValidationParameters.IssuerValidator = microsoftIdentityIssuerValidatorFactory.GetAadIssuerValidator(options.Authority).Validate;
@jmprieur jmprieur added the question Further information is requested label Mar 15, 2021
@jmprieur
Copy link
Contributor

@jrmcdona
IOptions has several generic overrides that can provide you the types you want by dependency injection

See:
https://github.com/AzureAD/microsoft-identity-web/blob/fe47497f97f2956ac238cd18034666934cc9ec8d/src/Microsoft.Identity.Web/WebApiExtensions/MicrosoftIdentityWebApiAuthenticationBuilderExtensions.cs#L172-L173

         // Change the authentication configuration to accommodate the Microsoft identity platform endpoint (v2.0).
            builder.Services.AddOptions<JwtBearerOptions>(jwtBearerScheme)
                .Configure<IServiceProvider, IOptionsMonitor<MicrosoftIdentityOptions>>((options, serviceProvider, microsoftIdentityOptionsMonitor) =>
                {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants