public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, Action <JwtSecurityOptions> configureOptions) { if (services == null) { throw new ArgumentNullException(nameof(services)); } var jwtSecurityOptions = new JwtSecurityOptions(); configureOptions(jwtSecurityOptions); var tokenHandler = new TokenHandler(jwtSecurityOptions); services.AddAuthentication( options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(options => { options.TokenValidationParameters = tokenHandler.TokenValidationParameters; }); return(services); }
public TokenHandler(JwtSecurityOptions options) { this.options = options ?? throw new ArgumentNullException(nameof(options)); this.symmetricSecurityKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(options.IssuerSigningKey)); }
public MachineKeyCompatibilityDataFormat(JwtSecurityOptions jwtSecurityOptions) : this(new TokenHandler(jwtSecurityOptions)) { }
public JwtSecureDataFormat(JwtSecurityOptions jwtSecurityOptions) : this(new TokenHandler(jwtSecurityOptions)) { }