| | 1 | | using Syki.Back.Features.Cross.CreateUser; |
| | 2 | |
|
| | 3 | | namespace Syki.Back.Configs; |
| | 4 | |
|
| | 5 | | public static class IdentityConfigs |
| | 6 | | { |
| | 7 | | public static void AddIdentityConfigs(this IServiceCollection services) |
| | 8 | | { |
| 2 | 9 | | services.AddIdentity<SykiUser, SykiRole>() |
| 2 | 10 | | .AddEntityFrameworkStores<SykiDbContext>() |
| 2 | 11 | | .AddDefaultTokenProviders(); |
| | 12 | |
|
| 2 | 13 | | services.Configure<DataProtectionTokenProviderOptions>(options => |
| 2 | 14 | | { |
| 2 | 15 | | options.TokenLifespan = TimeSpan.FromHours(1); |
| 4 | 16 | | }); |
| | 17 | |
|
| 2 | 18 | | services.Configure<IdentityOptions>(options => |
| 2 | 19 | | { |
| 2 | 20 | | options.User.RequireUniqueEmail = true; |
| 2 | 21 | | options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_@.+ |
| 4 | 22 | | }); |
| | 23 | |
|
| 2 | 24 | | services.Configure<IdentityOptions>(options => |
| 2 | 25 | | { |
| 2 | 26 | | options.Password.RequiredLength = 8; // The minimum length. |
| 2 | 27 | | options.Password.RequireDigit = true; // Requires a number between 0-9. |
| 2 | 28 | | options.Password.RequireLowercase = true; // Requires a lowercase character. |
| 2 | 29 | | options.Password.RequireUppercase = true; // Requires an uppercase character. |
| 2 | 30 | | options.Password.RequireNonAlphanumeric = true; // Requires a non-alphanumeric character (@, %, #, !, &, $, |
| 2 | 31 | | options.Password.RequiredUniqueChars = 1; // Requires the minimum number of distinct characters. |
| 4 | 32 | | }); |
| | 33 | |
|
| 2 | 34 | | services.Configure<IdentityOptions>(options => |
| 2 | 35 | | { |
| 2 | 36 | | options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5); // The amount of time a user is locked out |
| 2 | 37 | | options.Lockout.MaxFailedAccessAttempts = 3; // The number of failed access attempts un |
| 2 | 38 | | options.Lockout.AllowedForNewUsers = true; // Determines if a new user can be locked |
| 4 | 39 | | }); |
| 2 | 40 | | } |
| | 41 | | } |