public static IServiceCollection AddJwtAuthentication(this IServiceCollection services, FieldOpsSettings fieldOpsSettings) { var key = Encoding.ASCII.GetBytes(fieldOpsSettings.Secret); services.AddAuthentication(x => { x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(x => { x.RequireHttpsMetadata = false; x.SaveToken = true; x.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuer = false, ValidateAudience = false }; }); return(services); }
public IdentityController(UserManager <User> userManager, IOptions <FieldOpsSettings> applicationSettings, IIdentityService identityService) { _userManager = userManager; _identityService = identityService; _fieldOpsSettings = applicationSettings.Value; }