-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Add IAuthenticationConfigurationProvider.GetAuthenticationConfiguration
#41989
Comments
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
Why does this need the schemes as a first class property? |
It makes sense to me to have every key we support under Authentication as a first-class property. I suppose on alternative is to store an |
Do we need a strongly typed object model on authentication configuration for every top level configuration property? I think we should keep this type simple. It's a way to get access to the top level auth config section, and the config section for a scheme. Otherwise, it's no longer an interface but instead a poco like AuthenticationOptions. GetAuthenticationConfiguration should be a property. |
API Review Notes:
namespace Microsoft.AspNetCore.Authentication;
public interface IAuthenticationConfigurationProvider
{
- public IConfiguration GetAuthenticationConfiguration();
+ public IConfiguration Authentication { get; }
+ public IConfiguration AuthenticationSchemes { get; }
} |
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
Here's the proposed diff from the originally approved API if I'm reading this correctly: namespace Microsoft.AspNetCore.Authentication;
public interface IAuthenticationConfigurationProvider
{
public IConfiguration Authentication { get; }
- public IConfiguration AuthenticationSchemes { get; }
}
+ public static class AuthenticationConfigurationProviderExtensions
+ {
+ public static IConfiguration GetSchemeConfiguration(this IAuthenticationConfigurationProvider provider, string authenticationScheme);
+ } Is there a benefit of calling It does seem a little weird to call |
Yep, and to provide an abstraction over getting the scheme from the provider, which we will be using in all the different options from config implementations (e.g.
Sure. That works. |
Approved API (relative to what's currently checked in): namespace Microsoft.AspNetCore.Authentication;
public interface IAuthenticationConfigurationProvider
{
- IConfiguration GetAuthenticationSchemeConfiguration(string authenticationScheme);
+ IConfiguration AuthenticationConfiguration { get; }
}
+ public static class AuthenticationConfigurationProviderExtensions
+ {
+ public static IConfiguration GetSchemeConfiguration(this IAuthenticationConfigurationProvider provider, string authenticationScheme);
+ } |
Closed via #41987. |
To support reading default schemes from configuration, we need to add an API to IAuthenticationConfigurationProvider that allows us to extract the root Authentication property from configuration.
The PR also adds a set of shared constants for use in the user-jwts CLI and the runtime with regarding to accessing these configuration keys.
Risks
Low, we've discussed adding this is a follow-up item from preview5.
Pull Request
#41987
Proposed API
namespace Microsoft.AspNetCore.Authentication; public interface IAuthenticationConfigurationProvider { + public IConfiguration Authentication { get; } }
namespace Microsoft.AspNetCore.Authentication; public static class AuthenticationConfigurationProviderExtensions { + public static IConfiguration GetSchemeConfiguration(this IAuthenticationConfigurationProvider provider, string authenticationScheme); }
Sample Usage
An end-user can implement a custom
IAuthenticationConfigurationProvider
to point to where the top-level configuration key in their application is.Sample Config
In our
ConfigureOptions
implementation, we use theGetSchemeConfiguration
extension method to access individual schemesThe text was updated successfully, but these errors were encountered: