-
Notifications
You must be signed in to change notification settings - Fork 254
Fix OidcIdpSignedAssertionLoader to remove hard dependency on IConfiguration registration #3414
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
Changes from 3 commits
d558326
1e0698b
67ce505
62ef492
7ec62f0
84f632b
59a5f52
e505000
b36c926
ec19f7b
7601075
ff8419c
92bd1ad
24bd420
ceb2c7e
e2f0b44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| using System; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Logging; | ||
| using Microsoft.Extensions.Options; | ||
| using Microsoft.Identity.Abstractions; | ||
|
|
@@ -14,17 +15,17 @@ | |
| { | ||
| private readonly ILogger<OidcIdpSignedAssertionLoader> _logger; | ||
| private readonly IOptionsMonitor<MicrosoftIdentityApplicationOptions> _options; | ||
| private readonly IConfiguration _configuration; | ||
| private readonly IServiceProvider _serviceProvider; | ||
| private readonly ITokenAcquirerFactory _tokenAcquirerFactory; | ||
|
|
||
| public OidcIdpSignedAssertionLoader(ILogger<OidcIdpSignedAssertionLoader> logger, | ||
|
Check failure on line 21 in src/Microsoft.Identity.Web.OidcFIC/OidcIdpSignedAssertionLoader.cs
|
||
| IOptionsMonitor<MicrosoftIdentityApplicationOptions> options, | ||
| IConfiguration configuration, | ||
| IServiceProvider serviceProvider, | ||
| ITokenAcquirerFactory tokenAcquirerFactory) | ||
| { | ||
| _logger = logger; | ||
| _options = options; | ||
| _configuration = configuration; | ||
| _serviceProvider = serviceProvider; | ||
| _tokenAcquirerFactory = tokenAcquirerFactory; | ||
| } | ||
|
|
||
|
|
@@ -61,7 +62,26 @@ | |
|
|
||
| if (string.IsNullOrEmpty(microsoftIdentityApplicationOptions.Instance) && microsoftIdentityApplicationOptions.Authority == "//v2.0") | ||
| { | ||
| _configuration.GetSection(sectionName).Bind(microsoftIdentityApplicationOptions); | ||
| // Get IConfiguration from service provider just-in-time | ||
| IConfiguration? configuration = _serviceProvider.GetService<IConfiguration>(); | ||
| if (configuration == null) | ||
| { | ||
| const string errorMessage = "IConfiguration is not registered in the service collection. " + | ||
| "Please register IConfiguration or see https://aka.ms/ms-id-web/fic-oidc/troubleshoot for more information."; | ||
|
|
||
| if (_logger != null) | ||
| { | ||
| _logger.LogError(42, errorMessage); | ||
| } | ||
| throw new InvalidOperationException(errorMessage); | ||
| } | ||
|
|
||
| if (_logger != null) | ||
| { | ||
| _logger.LogDebug("Binding configuration section '{SectionName}' to MicrosoftIdentityApplicationOptions", sectionName); | ||
| } | ||
|
|
||
| configuration.GetSection(sectionName).Bind(microsoftIdentityApplicationOptions); | ||
| } | ||
|
|
||
| // Special case for Signed assertions with an FmiPath. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.