-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Blazor] More auth fixes #20192
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
[Blazor] More auth fixes #20192
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
20 changes: 20 additions & 0 deletions
20
src/Components/WebAssembly/WebAssembly.Authentication/src/IAccessTokenProviderAccessor.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 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication.Internal | ||
| { | ||
| /// <summary> | ||
| /// This is an internal API that supports the Microsoft.AspNetCore.Components.WebAssembly.Authentication | ||
| /// infrastructure and not subject to the same compatibility standards as public APIs. | ||
| /// It may be changed or removed without notice in any release. | ||
| /// </summary> | ||
| public interface IAccessTokenProviderAccessor | ||
| { | ||
| /// <summary> | ||
| /// This is an internal API that supports the Microsoft.AspNetCore.Components.WebAssembly.Authentication | ||
| /// infrastructure and not subject to the same compatibility standards as public APIs. | ||
| /// It may be changed or removed without notice in any release. | ||
| /// </summary> | ||
| IAccessTokenProvider TokenProvider { get; } | ||
javiercn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
19 changes: 19 additions & 0 deletions
19
src/Components/WebAssembly/WebAssembly.Authentication/src/IRemoteAuthenticationBuilder.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,19 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using Microsoft.AspNetCore.Components.WebAssembly.Authentication; | ||
|
|
||
| namespace Microsoft.Extensions.DependencyInjection | ||
| { | ||
| /// <summary> | ||
| /// An interface for configuring remote authentication services. | ||
| /// </summary> | ||
| /// <typeparam name="TRemoteAuthenticationState">The remote authentication state type.</typeparam> | ||
| /// <typeparam name="TAccount">The account type.</typeparam> | ||
| public interface IRemoteAuthenticationBuilder<TRemoteAuthenticationState, TAccount> | ||
javiercn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| where TRemoteAuthenticationState : RemoteAuthenticationState | ||
| where TAccount : RemoteUserAccount | ||
| { | ||
| IServiceCollection Services { get; } | ||
| } | ||
| } | ||
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
23 changes: 23 additions & 0 deletions
23
src/Components/WebAssembly/WebAssembly.Authentication/src/Models/RemoteUserAccount.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,23 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication | ||
| { | ||
| /// <summary> | ||
| /// A user account. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// The information in this type will be use to produce a <see cref="System.Security.Claims.ClaimsPrincipal"/> for the application. | ||
| /// </remarks> | ||
| public class RemoteUserAccount | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets properties not explicitly mapped about the user. | ||
| /// </summary> | ||
| [JsonExtensionData] | ||
| public IDictionary<string, object> AdditionalProperties { get; set; } | ||
javiercn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
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
17 changes: 17 additions & 0 deletions
17
src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticationBuilder.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,17 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using Microsoft.Extensions.DependencyInjection; | ||
|
|
||
| namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication | ||
| { | ||
| internal class RemoteAuthenticationBuilder<TRemoteAuthenticationState, TAccount> | ||
| : IRemoteAuthenticationBuilder<TRemoteAuthenticationState, TAccount> | ||
| where TRemoteAuthenticationState : RemoteAuthenticationState | ||
| where TAccount : RemoteUserAccount | ||
| { | ||
| public RemoteAuthenticationBuilder(IServiceCollection services) => Services = services; | ||
|
|
||
| public IServiceCollection Services { get; } | ||
| } | ||
javiercn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
55 changes: 55 additions & 0 deletions
55
...nents/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticationBuilderExtensions.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,55 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using Microsoft.AspNetCore.Components.WebAssembly.Authentication; | ||
| using Microsoft.Extensions.DependencyInjection.Extensions; | ||
|
|
||
| namespace Microsoft.Extensions.DependencyInjection | ||
| { | ||
| /// <summary> | ||
| /// Extensions for remote authentication services. | ||
| /// </summary> | ||
| public static class RemoteAuthenticationBuilderExtensions | ||
| { | ||
| /// <summary> | ||
| /// Replaces the existing <see cref="UserFactory{TAccount}"/> with the user factory defined by <typeparamref name="TUserFactory"/>. | ||
| /// </summary> | ||
| /// <typeparam name="TRemoteAuthenticationState">The remote authentication state.</typeparam> | ||
| /// <typeparam name="TAccount">The account type.</typeparam> | ||
| /// <typeparam name="TUserFactory">The new user factory type.</typeparam> | ||
| /// <param name="builder">The <see cref="IRemoteAuthenticationBuilder{TRemoteAuthenticationState, TAccount}"/>.</param> | ||
| /// <returns>The <see cref="IRemoteAuthenticationBuilder{TRemoteAuthenticationState, TAccount}"/>.</returns> | ||
| public static IRemoteAuthenticationBuilder<TRemoteAuthenticationState, TAccount> AddUserFactory<TRemoteAuthenticationState, TAccount, TUserFactory>( | ||
javiercn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| this IRemoteAuthenticationBuilder<TRemoteAuthenticationState, TAccount> builder) | ||
| where TRemoteAuthenticationState : RemoteAuthenticationState, new() | ||
| where TAccount : RemoteUserAccount | ||
| where TUserFactory : UserFactory<TAccount> | ||
| { | ||
| builder.Services.Replace(ServiceDescriptor.Scoped<UserFactory<TAccount>, TUserFactory>()); | ||
|
|
||
| return builder; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Replaces the existing <see cref="UserFactory{Account}"/> with the user factory defined by <typeparamref name="TUserFactory"/>. | ||
| /// </summary> | ||
| /// <typeparam name="TRemoteAuthenticationState">The remote authentication state.</typeparam> | ||
| /// <typeparam name="TUserFactory">The new user factory type.</typeparam> | ||
| /// <param name="builder">The <see cref="IRemoteAuthenticationBuilder{TRemoteAuthenticationState, Account}"/>.</param> | ||
| /// <returns>The <see cref="IRemoteAuthenticationBuilder{TRemoteAuthenticationState, Account}"/>.</returns> | ||
| public static IRemoteAuthenticationBuilder<TRemoteAuthenticationState, RemoteUserAccount> AddUserFactory<TRemoteAuthenticationState, TUserFactory>( | ||
| this IRemoteAuthenticationBuilder<TRemoteAuthenticationState, RemoteUserAccount> builder) | ||
| where TRemoteAuthenticationState : RemoteAuthenticationState, new() | ||
| where TUserFactory : UserFactory<RemoteUserAccount> => builder.AddUserFactory<TRemoteAuthenticationState, RemoteUserAccount, TUserFactory>(); | ||
|
|
||
| /// <summary> | ||
| /// Replaces the existing <see cref="UserFactory{TAccount}"/> with the user factory defined by <typeparamref name="TUserFactory"/>. | ||
| /// </summary> | ||
| /// <typeparam name="TUserFactory">The new user factory type.</typeparam> | ||
| /// <param name="builder">The <see cref="IRemoteAuthenticationBuilder{RemoteAuthenticationState, Account}"/>.</param> | ||
| /// <returns>The <see cref="IRemoteAuthenticationBuilder{RemoteAuthenticationState, Account}"/>.</returns> | ||
| public static IRemoteAuthenticationBuilder<RemoteAuthenticationState, RemoteUserAccount> AddUserFactory<TUserFactory>( | ||
| this IRemoteAuthenticationBuilder<RemoteAuthenticationState, RemoteUserAccount> builder) | ||
| where TUserFactory : UserFactory<RemoteUserAccount> => builder.AddUserFactory<RemoteAuthenticationState, RemoteUserAccount, TUserFactory>(); | ||
| } | ||
| } | ||
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.