diff --git a/src/Components/WebAssembly/Authentication.Msal/src/Microsoft.Authentication.WebAssembly.Msal.csproj b/src/Components/WebAssembly/Authentication.Msal/src/Microsoft.Authentication.WebAssembly.Msal.csproj index 4b27caa77b8a..1d260d7d3c96 100644 --- a/src/Components/WebAssembly/Authentication.Msal/src/Microsoft.Authentication.WebAssembly.Msal.csproj +++ b/src/Components/WebAssembly/Authentication.Msal/src/Microsoft.Authentication.WebAssembly.Msal.csproj @@ -1,4 +1,4 @@ - + @@ -6,6 +6,7 @@ $(DefaultNetCoreTargetFramework) Authenticate your Blazor webassembly applications with Azure Active Directory and Azure Active Directory B2C true + true @@ -16,6 +17,10 @@ + + + + $(MSBuildThisFileDirectory)Interop\ diff --git a/src/Components/WebAssembly/Authentication.Msal/src/MsalDefaultOptionsConfiguration.cs b/src/Components/WebAssembly/Authentication.Msal/src/MsalDefaultOptionsConfiguration.cs index c98c6f871e82..db81a1202641 100644 --- a/src/Components/WebAssembly/Authentication.Msal/src/MsalDefaultOptionsConfiguration.cs +++ b/src/Components/WebAssembly/Authentication.Msal/src/MsalDefaultOptionsConfiguration.cs @@ -44,7 +44,7 @@ public void Configure(RemoteAuthenticationOptions options) public void PostConfigure(string name, RemoteAuthenticationOptions options) { - if (string.Equals(name, Options.DefaultName)) + if (string.Equals(name, Options.DefaultName, StringComparison.Ordinal)) { Configure(options); } diff --git a/src/Components/WebAssembly/Authentication.Msal/src/MsalWebAssemblyServiceCollectionExtensions.cs b/src/Components/WebAssembly/Authentication.Msal/src/MsalWebAssemblyServiceCollectionExtensions.cs index 4889f8cc502f..30b86c3c0767 100644 --- a/src/Components/WebAssembly/Authentication.Msal/src/MsalWebAssemblyServiceCollectionExtensions.cs +++ b/src/Components/WebAssembly/Authentication.Msal/src/MsalWebAssemblyServiceCollectionExtensions.cs @@ -2,11 +2,13 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Diagnostics.CodeAnalysis; using Microsoft.AspNetCore.Components.WebAssembly.Authentication; using Microsoft.Authentication.WebAssembly.Msal; using Microsoft.Authentication.WebAssembly.Msal.Models; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; +using static Microsoft.AspNetCore.Internal.LinkerFlags; namespace Microsoft.Extensions.DependencyInjection { @@ -48,7 +50,7 @@ public static IRemoteAuthenticationBuilderThe . /// A callback to configure the . /// The . - public static IRemoteAuthenticationBuilder AddMsalAuthentication(this IServiceCollection services, Action> configure) + public static IRemoteAuthenticationBuilder AddMsalAuthentication(this IServiceCollection services, Action> configure) where TRemoteAuthenticationState : RemoteAuthenticationState, new() where TAccount : RemoteUserAccount { diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/IRemoteAuthenticationPathsProvider.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/IRemoteAuthenticationPathsProvider.cs index 2294d7af225e..d598a097fa81 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/IRemoteAuthenticationPathsProvider.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/IRemoteAuthenticationPathsProvider.cs @@ -1,7 +1,7 @@ // 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 +namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication { /// /// This is an internal API that supports the Microsoft.AspNetCore.Components.WebAssembly.Authentication diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/Microsoft.AspNetCore.Components.WebAssembly.Authentication.csproj b/src/Components/WebAssembly/WebAssembly.Authentication/src/Microsoft.AspNetCore.Components.WebAssembly.Authentication.csproj index dbc2d3a1a8b9..88bc97fb01c8 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/Microsoft.AspNetCore.Components.WebAssembly.Authentication.csproj +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/Microsoft.AspNetCore.Components.WebAssembly.Authentication.csproj @@ -18,6 +18,10 @@ + + + + $(MSBuildThisFileDirectory)Interop\ diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/QueryStringHelper.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/QueryStringHelper.cs index 4986e0bf041b..8af2a4e57275 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/QueryStringHelper.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/QueryStringHelper.cs @@ -1,11 +1,12 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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; +using System.Text.Encodings.Web; namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication { - internal class QueryStringHelper + internal static class QueryStringHelper { public static string GetParameter(string queryString, string key) { diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticationBuilderExtensions.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticationBuilderExtensions.cs index 058166a8c782..826b2eb612b0 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticationBuilderExtensions.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticationBuilderExtensions.cs @@ -49,7 +49,7 @@ public static class RemoteAuthenticationBuilderExtensions /// The new user factory type. /// The . /// The . - public static IRemoteAuthenticationBuilder AddAccountClaimsPrincipalFactory( + public static IRemoteAuthenticationBuilder AddAccountClaimsPrincipalFactory<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TAccountClaimsPrincipalFactory>( this IRemoteAuthenticationBuilder builder) where TAccountClaimsPrincipalFactory : AccountClaimsPrincipalFactory => builder.AddAccountClaimsPrincipalFactory(); } diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticatorViewCore.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticatorViewCore.cs index f285301e9e6a..096c52d690d4 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticatorViewCore.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticatorViewCore.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Rendering; -using Microsoft.AspNetCore.Components.WebAssembly.Authentication.Internal; using Microsoft.JSInterop; namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication @@ -103,9 +102,7 @@ public class RemoteAuthenticatorViewCore : ComponentBase w /// /// Gets or sets a default to use as fallback if an has not been explicitly specified. /// -#pragma warning disable PUB0001 // Pubternal type in public API [Inject] internal IRemoteAuthenticationPathsProvider RemoteApplicationPathsProvider { get; set; } -#pragma warning restore PUB0001 // Pubternal type in public API /// /// Gets or sets a default with the current user. diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AccessTokenResult.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AccessTokenResult.cs index 8fe4a707b0a9..b30581322ec1 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AccessTokenResult.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AccessTokenResult.cs @@ -1,8 +1,6 @@ // 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; - namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication { /// diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AccountClaimsPrincipalFactory.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AccountClaimsPrincipalFactory.cs index 008834ffa024..5cafba2576d4 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AccountClaimsPrincipalFactory.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AccountClaimsPrincipalFactory.cs @@ -16,7 +16,6 @@ public class AccountClaimsPrincipalFactory where TAccount : RemoteUser { private readonly IAccessTokenProviderAccessor _accessor; -#pragma warning disable PUB0001 // Pubternal type in public API /// /// Initialize a new instance of . /// diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/DefaultRemoteApplicationPathsProvider.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/DefaultRemoteApplicationPathsProvider.cs index b3bf0800bded..665efb43ff9f 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/DefaultRemoteApplicationPathsProvider.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/DefaultRemoteApplicationPathsProvider.cs @@ -1,7 +1,6 @@ // 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.Internal; using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs index def3ff132dd0..55b75e86b9e9 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs @@ -2,12 +2,13 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Diagnostics.CodeAnalysis; using System.Security.Claims; -using System.Text.Json; using System.Threading.Tasks; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.Extensions.Options; using Microsoft.JSInterop; +using static Microsoft.AspNetCore.Internal.LinkerFlags; namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication { @@ -17,7 +18,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication /// The state to preserve across authentication operations. /// The type of the . /// The options to be passed down to the underlying JavaScript library handling the authentication operations. - public class RemoteAuthenticationService : + public class RemoteAuthenticationService : AuthenticationStateProvider, IRemoteAuthenticationService, IAccessTokenProvider diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/SignOutSessionStateManager.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/SignOutSessionStateManager.cs index f48ae2c994ff..a47e075adc0b 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/SignOutSessionStateManager.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/SignOutSessionStateManager.cs @@ -13,11 +13,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication public class SignOutSessionStateManager { private readonly IJSRuntime _jsRuntime; - private static readonly JsonSerializerOptions _serializationOptions = new JsonSerializerOptions - { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - PropertyNameCaseInsensitive = true, - }; + private static readonly JsonSerializerOptions _serializationOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web); /// /// Initialize a new instance of . diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/WebAssemblyAuthenticationServiceCollectionExtensions.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/WebAssemblyAuthenticationServiceCollectionExtensions.cs index 898cc7eac42b..ca8c023d9e8c 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/WebAssemblyAuthenticationServiceCollectionExtensions.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/WebAssemblyAuthenticationServiceCollectionExtensions.cs @@ -2,12 +2,14 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.WebAssembly.Authentication; using Microsoft.AspNetCore.Components.WebAssembly.Authentication.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; +using static Microsoft.AspNetCore.Internal.LinkerFlags; namespace Microsoft.Extensions.DependencyInjection { @@ -25,7 +27,8 @@ public static class WebAssemblyAuthenticationServiceCollectionExtensions /// The configuration options of the underlying provider being used for handling the authentication operations. /// The to add the services to. /// The where the services were registered. - public static IRemoteAuthenticationBuilder AddRemoteAuthentication(this IServiceCollection services) + public static IRemoteAuthenticationBuilder AddRemoteAuthentication( + this IServiceCollection services) where TRemoteAuthenticationState : RemoteAuthenticationState where TAccount : RemoteUserAccount where TProviderOptions : class, new() @@ -65,7 +68,8 @@ public static IRemoteAuthenticationBuilder /// The to add the services to. /// An action that will configure the . /// The where the services were registered. - public static IRemoteAuthenticationBuilder AddRemoteAuthentication(this IServiceCollection services, Action> configure) + public static IRemoteAuthenticationBuilder AddRemoteAuthentication( + this IServiceCollection services, Action> configure) where TRemoteAuthenticationState : RemoteAuthenticationState where TAccount : RemoteUserAccount where TProviderOptions : class, new() @@ -85,7 +89,8 @@ public static IRemoteAuthenticationBuilder /// The to add the services to. /// An action that will configure the . /// The where the services were registered. - public static IRemoteAuthenticationBuilder AddOidcAuthentication(this IServiceCollection services, Action> configure) + public static IRemoteAuthenticationBuilder AddOidcAuthentication( + this IServiceCollection services, Action> configure) { return AddOidcAuthentication(services, configure); } @@ -97,7 +102,8 @@ public static IRemoteAuthenticationBuilderThe to add the services to. /// An action that will configure the . /// The where the services were registered. - public static IRemoteAuthenticationBuilder AddOidcAuthentication(this IServiceCollection services, Action> configure) + public static IRemoteAuthenticationBuilder AddOidcAuthentication( + this IServiceCollection services, Action> configure) where TRemoteAuthenticationState : RemoteAuthenticationState, new() { return AddOidcAuthentication(services, configure); @@ -111,7 +117,8 @@ public static IRemoteAuthenticationBuilderThe to add the services to. /// An action that will configure the . /// The where the services were registered. - public static IRemoteAuthenticationBuilder AddOidcAuthentication(this IServiceCollection services, Action> configure) + public static IRemoteAuthenticationBuilder AddOidcAuthentication( + this IServiceCollection services, Action> configure) where TRemoteAuthenticationState : RemoteAuthenticationState, new() where TAccount : RemoteUserAccount { @@ -127,7 +134,7 @@ public static IRemoteAuthenticationBuilder /// The where the services were registered. public static IRemoteAuthenticationBuilder AddApiAuthorization(this IServiceCollection services) { - return AddApiauthorizationCore(services, configure: null, Assembly.GetCallingAssembly().GetName().Name); + return AddApiAuthorizationCore(services, configure: null, Assembly.GetCallingAssembly().GetName().Name); } /// @@ -139,7 +146,7 @@ public static IRemoteAuthenticationBuilder AddApiAuthorization(this IServiceCollection services) where TRemoteAuthenticationState : RemoteAuthenticationState, new() { - return AddApiauthorizationCore(services, configure: null, Assembly.GetCallingAssembly().GetName().Name); + return AddApiAuthorizationCore(services, configure: null, Assembly.GetCallingAssembly().GetName().Name); } /// @@ -149,11 +156,12 @@ public static IRemoteAuthenticationBuilderThe account type. /// The to add the services to. /// The where the services were registered. - public static IRemoteAuthenticationBuilder AddApiAuthorization(this IServiceCollection services) + public static IRemoteAuthenticationBuilder AddApiAuthorization( + this IServiceCollection services) where TRemoteAuthenticationState : RemoteAuthenticationState, new() where TAccount : RemoteUserAccount { - return AddApiauthorizationCore(services, configure: null, Assembly.GetCallingAssembly().GetName().Name); + return AddApiAuthorizationCore(services, configure: null, Assembly.GetCallingAssembly().GetName().Name); } /// @@ -162,9 +170,10 @@ public static IRemoteAuthenticationBuilder /// The to add the services to. /// An action that will configure the . /// The where the services were registered. - public static IRemoteAuthenticationBuilder AddApiAuthorization(this IServiceCollection services, Action> configure) + public static IRemoteAuthenticationBuilder AddApiAuthorization( + this IServiceCollection services, Action> configure) { - return AddApiauthorizationCore(services, configure, Assembly.GetCallingAssembly().GetName().Name); + return AddApiAuthorizationCore(services, configure, Assembly.GetCallingAssembly().GetName().Name); } /// @@ -174,10 +183,11 @@ public static IRemoteAuthenticationBuilderThe to add the services to. /// An action that will configure the . /// The where the services were registered. - public static IRemoteAuthenticationBuilder AddApiAuthorization(this IServiceCollection services, Action> configure) + public static IRemoteAuthenticationBuilder AddApiAuthorization( + this IServiceCollection services, Action> configure) where TRemoteAuthenticationState : RemoteAuthenticationState, new() { - return AddApiauthorizationCore(services, configure, Assembly.GetCallingAssembly().GetName().Name); + return AddApiAuthorizationCore(services, configure, Assembly.GetCallingAssembly().GetName().Name); } /// @@ -188,14 +198,15 @@ public static IRemoteAuthenticationBuilderThe to add the services to. /// An action that will configure the . /// The where the services were registered. - public static IRemoteAuthenticationBuilder AddApiAuthorization(this IServiceCollection services, Action> configure) + public static IRemoteAuthenticationBuilder AddApiAuthorization( + this IServiceCollection services, Action> configure) where TRemoteAuthenticationState : RemoteAuthenticationState, new() where TAccount : RemoteUserAccount { - return AddApiauthorizationCore(services, configure, Assembly.GetCallingAssembly().GetName().Name); + return AddApiAuthorizationCore(services, configure, Assembly.GetCallingAssembly().GetName().Name); } - private static IRemoteAuthenticationBuilder AddApiauthorizationCore( + private static IRemoteAuthenticationBuilder AddApiAuthorizationCore( IServiceCollection services, Action> configure, string inferredClientId) diff --git a/src/Components/WebAssembly/testassets/WasmLinkerTest/WasmLinkerTest.csproj b/src/Components/WebAssembly/testassets/WasmLinkerTest/WasmLinkerTest.csproj index 9bce87106cfe..978ad91b8215 100644 --- a/src/Components/WebAssembly/testassets/WasmLinkerTest/WasmLinkerTest.csproj +++ b/src/Components/WebAssembly/testassets/WasmLinkerTest/WasmLinkerTest.csproj @@ -1,4 +1,4 @@ - + $(DefaultNetCoreTargetFramework) browser-wasm @@ -12,6 +12,8 @@ + +