コード例 #1
0
        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());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public RoleService(AuthorizationSettings authorizationSettings, RoleManager <TRole> roleManager)
     : base(authorizationSettings)
 {
     _roleManager = roleManager;
 }
コード例 #4
0
 public AuthorizationSettingsBuilder()
 {
     AuthorizationSettings = new AuthorizationSettings();
 }
コード例 #5
0
 public UserService(AuthorizationSettings authorizationSettings, SignInManager <TUser> signInManager, UserManager <TUser> userManager)
     : this(authorizationSettings, signInManager, userManager, null)
 {
 }
コード例 #6
0
 public TokenHelper(AuthorizationSettings authorizationSettings)
 {
     _authorizationSettings = authorizationSettings;
 }