Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddSingleton(_ => Configuration);
- services.AddDbContext<ApplicationDbContext>(options =>
- options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
- services.AddResponseCaching();
- services.AddIdentity<ApplicationUser, IdentityRole>()
- .AddEntityFrameworkStores<ApplicationDbContext>()
- .AddDefaultTokenProviders();
- var secretKey = Configuration.GetSection("AppSettings")["SecretKey"];
- var signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(secretKey));
- var tokenValidationParameters = new TokenValidationParameters
- {
- ValidateIssuerSigningKey = true,
- IssuerSigningKey = signingKey,
- ValidateIssuer = true,
- ValidIssuer = "arnvanhoutte",
- ValidateAudience = true,
- ValidAudience = "User",
- ValidateLifetime = true,
- ClockSkew = TimeSpan.Zero
- };
- services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
- .AddJwtBearer(options =>
- {
- options.TokenValidationParameters = tokenValidationParameters;
- });
- services.AddWebSocketManager();
- services.AddMvc();
- services.AddTransient<Seed>();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement