move subscriptionKey handler to maui
39c7ebd8
Michael Schmitz
committed
3 changed files
SubscriptionKeyHandler.cs
/WPE.App.Authentication.Maui/Business/SubscriptionKeyHandler.cs
/WPE.App.Authentication.Maui/Business/SubscriptionKeyHandler.cs
ServiceCollectionExtensions.cs
/WPE.App.Authentication.Maui/ServiceCollectionExtensions.cs-4+17
/WPE.App.Authentication.Maui/ServiceCollectionExtensions.cs
Add comment 1 using Infsoft.WPE.App.Authentication.Base;
Add comment 2 Plus  using Infsoft.WPE.App.Authentication.Base.Business;
Add comment 3 Plus  using Infsoft.WPE.App.Authentication.Base.Models;
Add comment 2 4 using Infsoft.WPE.App.Authentication.Maui.Business;
Add comment 3 5 using Infsoft.WPE.App.Authentication.Maui.Business.Flow;
Add comment 4 6 using Infsoft.WPE.App.Authentication.Maui.Business.Token;
Add comment 5 7 using Infsoft.WPE.App.Authentication.Maui.Models;
Add comment 6 8 using Microsoft.Extensions.Http;
Add comment 9 Plus  using Microsoft.Maui.Controls;
Add comment 7 10 #if WINDOWS
Add comment 8 11 using Infsoft.WPE.App.Authentication.Maui.Platforms.Windows;
Add comment 9 12 #endif
Add comment 16 19 internal static class ServiceCollectionExtensions
Add comment 17 20 {
Add comment 18 21 /// <summary>
Add comment 19 Minus   /// Add all required authentication services for a native login (using web authenticator)
Add comment 22 Plus   /// Add all required authentication services for a native login (using web authenticator) and the subscriptionKey handler
Add comment 20 23 /// </summary>
Add comment 21 24 /// <param name="services">Service collection to add to</param>
Add comment 22 Minus   /// <param name="config">Allows the configuration of token request endpoints</param>
Add comment 25 Plus   /// <param name="authConfig">Allows the configuration of token request endpoints</param>
Add comment 26 Plus   /// <param name="subscriptionKeyConfig">Allows tzhe configuration of hosts to set a subscriptionKey for</param>
Add comment 23 27 /// <returns>ServiceCollection to chain calls</returns>
Add comment 24 Minus   internal static IServiceCollection AddNativeAuthentication(this IServiceCollection services, Action<AuthenticationConfiguration> config)
Add comment 28 Plus   internal static IServiceCollection AddNativeAuthentication(this IServiceCollection services, Action<AuthenticationConfiguration> authConfig, Action<SubscriptionKeyConfiguration> subscriptionKeyConfig)
Add comment 25 29 {
Add comment 26 30 services.AddOptions();
Add comment 27 31 services.AddAuthorizationCore();
Add comment 38 42 services.AddSingleton<IAuthClient, AuthClient>();
Add comment 39 43 services.AddBaseAuthentication<NativeAuthenticationStateProvider>();
Add comment 40 44
Add comment 41 Minus   services.Configure(config);
Add comment 45 Plus   services.Configure(authConfig);
Add comment 42 46
Add comment 43 47 services.AddTransient<AuthorizationMessageHandler>();
Add comment 44 48 services.ConfigureAll<HttpClientFactoryOptions>(options =>
Add comment 50 54 });
Add comment 51 55 });
Add comment 52 56
Add comment 57 Plus   services.Configure(subscriptionKeyConfig);
Add comment 58 Plus   services.ConfigureAll<HttpClientFactoryOptions>(options =>
Add comment 59 Plus   {
Add comment 60 Plus   options.HttpMessageHandlerBuilderActions.Add(builder =>
Add comment 61 Plus   {
Add comment 62 Plus   builder.AdditionalHandlers.Add(builder.Services
Add comment 63 Plus   .GetRequiredService<SubscriptionKeyHandler>());
Add comment 64 Plus   });
Add comment 65 Plus   });
Add comment 53 66 return services;
Add comment 54 67 }
Add comment 55 68 }
WPE.App.Authentication.Maui.csproj
/WPE.App.Authentication.Maui/WPE.App.Authentication.Maui.csproj
/WPE.App.Authentication.Maui/WPE.App.Authentication.Maui.csproj