/// <summary> /// Add Gang Authentication services /// </summary> /// <param name="services">Serice collection</param> /// <param name="settings">Setting</param> /// <returns>Service collection</returns> public static IServiceCollection AddGangAuthenticationServices( this IServiceCollection services, IGangAuthenticationSettings settings ) { services.TryAddSingleton <IGangUserStore, GangUserStore>(); services .AddMvcCore(o => { o.EnableEndpointRouting = false; }) .AddApplicationPart(typeof(GangAuthenticationController).Assembly) .AddControllersAsServices() .AddNewtonsoftJson(); return(services .AddSingleton(settings) .AddGangAuthenticationHandler <GangAuthenticationHandler>() .AddTransient <IGangAuthenticationService, GangAuthenticationService>() .AddSingleton <IGangCryptoSettings>(settings) .AddTransient <IGangCryptoService, GangCryptoService>() .AddTransient <IGangCryptoVerificationService, ECES256VerificationService>() .AddTransient <IGangCryptoVerificationService, RSARS256VerificationService>() .AddTransient <IGangTokenService, GangTokenService>()); }
/// <summary> /// Add Gang Authentication services /// /// implementation of IGangAuthenticationUserStore, TUserStore, is added as a singleton /// </summary> /// <typeparam name="TUserStore">User store type</typeparam> /// <param name="services">Serice collection</param> /// <param name="settings">Setting</param> /// <returns>Service collection</returns> public static IServiceCollection AddGangAuthenticationServices <TUserStore>( this IServiceCollection services, IGangAuthenticationSettings settings ) where TUserStore : class, IGangUserStore { return(services .AddSingleton <IGangUserStore, TUserStore>() .AddGangAuthenticationServices(settings)); }
public GangTokenService( IGangAuthenticationSettings settings, IGangSerializationService serializationService) { _serializationService = serializationService; _hasher = new HMACSHA256( Encoding.UTF8.GetBytes(settings.Secret) ); }
public GangAuthenticationService( ILogger <GangAuthenticationService> logger, IGangAuthenticationSettings settings, IGangTokenService tokens, IGangManager manager, IGangUserStore users, IGangCryptoService crypto) { _logger = logger; _settings = settings; _tokens = tokens; _manager = manager; _users = users; _crypto = crypto; }