-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add dotnet user-jwts tool and runtime support #41520
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
bf23154
Add dotnet dev-jwts tool
captainsafia 6961df5
Add dotnet dev-jwts tool
captainsafia 212cf04
Address feedback from review
captainsafia 3ae682e
Rename project file
captainsafia 5f5c040
Write auth config to app settings
captainsafia 2675c50
Address more feedback
captainsafia c37a2a6
:seal:
captainsafia 212b42f
Apply suggestions from code review
captainsafia ef45270
Address more feedback
captainsafia 751c1d7
Add framework support for authentication changes
captainsafia 6562366
Add tests for user-jwts CLI and react to feedback
captainsafia 672fb64
Move ConsoleTable implementation to avoid conflicts in ProjectTemplates
captainsafia bd19796
Update existing auth tests and fix middleware registration
captainsafia 1f3a990
Update AzureAdB2C tests and auth app builder
captainsafia 23e9b0c
Fix build and move registration check
captainsafia f0aa386
Fix up resolution for Certificate test sources
captainsafia 98b504f
Fix write stream configuration for writing key material
captainsafia 50a3cda
Fix handling missing config section when processing options
captainsafia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#nullable enable | ||
Microsoft.AspNetCore.Builder.WebApplication.Use(System.Func<Microsoft.AspNetCore.Http.RequestDelegate!, Microsoft.AspNetCore.Http.RequestDelegate!>! middleware) -> Microsoft.AspNetCore.Builder.IApplicationBuilder! | ||
Microsoft.AspNetCore.Builder.WebApplicationBuilder.Authentication.get -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder! | ||
static Microsoft.Extensions.Hosting.GenericHostBuilderExtensions.ConfigureWebHostDefaults(this Microsoft.Extensions.Hosting.IHostBuilder! builder, System.Action<Microsoft.AspNetCore.Hosting.IWebHostBuilder!>! configure, System.Action<Microsoft.Extensions.Hosting.WebHostBuilderOptions!>! configureOptions) -> Microsoft.Extensions.Hosting.IHostBuilder! |
48 changes: 48 additions & 0 deletions
48
src/DefaultBuilder/src/WebApplicationAuthenticationBuilder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Microsoft.AspNetCore.Authentication; | ||
|
||
internal class WebApplicationAuthenticationBuilder : AuthenticationBuilder | ||
{ | ||
public bool IsAuthenticationConfigured { get; private set; } | ||
captainsafia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public WebApplicationAuthenticationBuilder(IServiceCollection services) : base(services) { } | ||
|
||
public override AuthenticationBuilder AddPolicyScheme(string authenticationScheme, string? displayName, Action<PolicySchemeOptions> configureOptions) | ||
{ | ||
RegisterServices(authenticationScheme); | ||
return base.AddPolicyScheme(authenticationScheme, displayName, configureOptions); | ||
} | ||
|
||
public override AuthenticationBuilder AddRemoteScheme<TOptions, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] THandler>(string authenticationScheme, string? displayName, Action<TOptions>? configureOptions) | ||
{ | ||
RegisterServices(authenticationScheme); | ||
return base.AddRemoteScheme<TOptions, THandler>(authenticationScheme, displayName, configureOptions); | ||
} | ||
|
||
public override AuthenticationBuilder AddScheme<TOptions, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] THandler>(string authenticationScheme, string? displayName, Action<TOptions>? configureOptions) | ||
{ | ||
RegisterServices(authenticationScheme); | ||
return base.AddScheme<TOptions, THandler>(authenticationScheme, displayName, configureOptions); | ||
} | ||
|
||
public override AuthenticationBuilder AddScheme<TOptions, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] THandler>(string authenticationScheme, Action<TOptions>? configureOptions) | ||
{ | ||
RegisterServices(authenticationScheme); | ||
return base.AddScheme<TOptions, THandler>(authenticationScheme, configureOptions); | ||
} | ||
|
||
private void RegisterServices(string authenticationScheme) | ||
{ | ||
if (!IsAuthenticationConfigured) | ||
{ | ||
IsAuthenticationConfigured = true; | ||
Services.AddAuthentication(authenticationScheme); | ||
Services.AddAuthorization(); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Http/Authentication.Abstractions/src/IAuthenticationConfigurationProvider.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace Microsoft.AspNetCore.Authentication; | ||
|
||
/// <summary> | ||
/// Provides an interface for implmenting a construct that provides | ||
/// access to specific configuration sections. | ||
/// </summary> | ||
public interface IAuthenticationConfigurationProvider | ||
{ | ||
/// <summary> | ||
/// Returns the specified <see cref="ConfigurationSection"/> object. | ||
/// </summary> | ||
/// <param name="authenticationScheme">The path to the section to be returned.</param> | ||
/// <returns>The specified <see cref="ConfigurationSection"/> object, or null if the requested section does not exist.</returns> | ||
IConfiguration GetAuthenticationSchemeConfiguration(string authenticationScheme); | ||
} |
2 changes: 2 additions & 0 deletions
2
src/Http/Authentication.Abstractions/src/PublicAPI.Unshipped.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
#nullable enable | ||
Microsoft.AspNetCore.Authentication.IAuthenticationConfigurationProvider | ||
Microsoft.AspNetCore.Authentication.IAuthenticationConfigurationProvider.GetAuthenticationSchemeConfiguration(string! authenticationScheme) -> Microsoft.Extensions.Configuration.IConfiguration! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Security/Authentication/Core/src/DefaultAuthenticationConfigurationProvider.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace Microsoft.AspNetCore.Authentication; | ||
|
||
internal sealed class DefaultAuthenticationConfigurationProvider : IAuthenticationConfigurationProvider | ||
{ | ||
private readonly IConfiguration _configuration; | ||
|
||
public DefaultAuthenticationConfigurationProvider(IConfiguration configuration) | ||
{ | ||
_configuration = configuration; | ||
} | ||
|
||
public IConfiguration GetAuthenticationSchemeConfiguration(string authenticationScheme) | ||
{ | ||
return _configuration.GetSection($"Authentication:Schemes:{authenticationScheme}"); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.