dotnet-dynamic-jwt-bearer/PoweredSoft.DynamicJwtBearer.DynamicAuthority/ServiceCollectionExtensions.cs
2020-07-23 13:10:32 -04:00

27 lines
1.1 KiB
C#

using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
namespace PoweredSoft.DynamicJwtBearer.DynamicAuthority
{
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddDynamicAuthorityJwtBearerResolver<TAuthoritySolver>(this IServiceCollection services)
where TAuthoritySolver : class, IDynamicJwtBearerAuthorityResolver
{
services.AddTransient<IDynamicJwtBearerAuthorityResolver, TAuthoritySolver>();
services.AddSingleton<IDynamicJwtBearerHanderConfigurationResolver, DynamicAuthorityJwtBearerHandlerConfigurationResolver>();
return services;
}
public static AuthenticationBuilder AddDynamicAuthorityJwtBearerResolver<TAuthoritySolver>(this AuthenticationBuilder authenticationBuilder)
where TAuthoritySolver : class, IDynamicJwtBearerAuthorityResolver
{
authenticationBuilder.Services.AddDynamicAuthorityJwtBearerResolver<TAuthoritySolver>();
return authenticationBuilder;
}
}
}