Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. public void ConfigureServices(IServiceCollection services)
  2. {
  3. services.AddSingleton(_ => Configuration);
  4.  
  5. services.AddDbContext<ApplicationDbContext>(options =>
  6. options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
  7.  
  8. services.AddResponseCaching();
  9.  
  10. services.AddIdentity<ApplicationUser, IdentityRole>()
  11. .AddEntityFrameworkStores<ApplicationDbContext>()
  12. .AddDefaultTokenProviders();
  13.  
  14. var secretKey = Configuration.GetSection("AppSettings")["SecretKey"];
  15. var signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(secretKey));
  16. var tokenValidationParameters = new TokenValidationParameters
  17. {
  18. ValidateIssuerSigningKey = true,
  19. IssuerSigningKey = signingKey,
  20. ValidateIssuer = true,
  21. ValidIssuer = "arnvanhoutte",
  22. ValidateAudience = true,
  23. ValidAudience = "User",
  24. ValidateLifetime = true,
  25. ClockSkew = TimeSpan.Zero
  26. };
  27.  
  28. services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
  29. .AddJwtBearer(options =>
  30. {
  31. options.TokenValidationParameters = tokenValidationParameters;
  32. });
  33.  
  34. services.AddWebSocketManager();
  35.  
  36. services.AddMvc();
  37.  
  38. services.AddTransient<Seed>();
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement