private static IdentityBuilder GetConfiguredIdentityBuilder <TUser, TRole>(IServiceCollection services, AuthorizationSettings authSettings) where TUser : User, new() where TRole : Role, new() { return(services.AddIdentity <TUser, TRole>(opt => { opt.Password.RequireDigit = authSettings.StrongSecurityPassword; opt.Password.RequireNonAlphanumeric = authSettings.StrongSecurityPassword; opt.Password.RequireLowercase = authSettings.StrongSecurityPassword; opt.Password.RequireUppercase = authSettings.StrongSecurityPassword; opt.SignIn.RequireConfirmedAccount = authSettings.ConfirmationRequired; opt.Password.RequiredLength = authSettings.MinPasswordLength; opt.Lockout.AllowedForNewUsers = true; opt.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(authSettings.MinutesToUnlock); opt.Lockout.MaxFailedAccessAttempts = authSettings.MaxAttemptsToLock; opt.User.RequireUniqueEmail = true; }) .AddDefaultTokenProviders()); }
private static IdentityBuilder RegisterAuthorization <TUser, TRole>(this IServiceCollection services, string privateKey, AuthorizationSettings authSettings) where TUser : User, new() where TRole : Role, new() { services.AddSingleton(authSettings); services.AddTransient <ISecuritySettings>(x => new SecuritySettings(privateKey)); SetupJwtAuthentication(services, authSettings, privateKey); SetJwtAuthorization(services); SetupTypedServices <TUser, TRole>(services); SetupUserTypedServices <TUser>(services); SetupRoleTypedServices <TRole>(services); SetupExternalProviders(services, authSettings); var identityBuilder = GetConfiguredIdentityBuilder <TUser, TRole>(services, authSettings); return(identityBuilder); }
public RoleService(AuthorizationSettings authorizationSettings, RoleManager <TRole> roleManager) : base(authorizationSettings) { _roleManager = roleManager; }
public AuthorizationSettingsBuilder() { AuthorizationSettings = new AuthorizationSettings(); }
public UserService(AuthorizationSettings authorizationSettings, SignInManager <TUser> signInManager, UserManager <TUser> userManager) : this(authorizationSettings, signInManager, userManager, null) { }
public TokenHelper(AuthorizationSettings authorizationSettings) { _authorizationSettings = authorizationSettings; }