Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. public void ConfigureAuth(IAppBuilder app)
  2. {
  3. // Configure the db context, user manager and signin manager to use a single instance per request
  4. app.CreatePerOwinContext(ApplicationDbContext.Create);
  5. app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
  6. app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
  7.  
  8. // Enable the application to use a cookie to store information for the signed in user
  9. // and to use a cookie to temporarily store information about a user logging in with a third party login provider
  10. // Configure the sign in cookie
  11. app.UseCookieAuthentication(new CookieAuthenticationOptions
  12. {
  13. AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
  14. LoginPath = new PathString("/Account/Login"),
  15. Provider = new CookieAuthenticationProvider
  16. {
  17. // Enables the application to validate the security stamp when the user logs in.
  18. // This is a security feature which is used when you change a password or add an external login to your account.
  19. OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
  20. validateInterval: TimeSpan.FromMinutes(30),
  21. regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
  22. }
  23. });
  24. app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
  25.  
  26. // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
  27. app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));
  28.  
  29. // Enables the application to remember the second login verification factor such as phone or email.
  30. // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from.
  31. // This is similar to the RememberMe option when you log in.
  32. app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);
  33.  
  34. // Uncomment the following lines to enable logging in with third party login providers
  35. //app.UseMicrosoftAccountAuthentication(
  36. // clientId: "",
  37. // clientSecret: "");
  38.  
  39. //app.UseTwitterAuthentication(
  40. // consumerKey: "",
  41. // consumerSecret: "");
  42.  
  43. //app.UseFacebookAuthentication(
  44. // appId: "",
  45. // appSecret: "");
  46.  
  47. //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
  48. //{
  49. // ClientId = "",
  50. // ClientSecret = ""
  51. //});
  52.  
  53. app.UseOpenIdConnectAuthentication(
  54. new OpenIdConnectAuthenticationOptions
  55. {
  56. ClientId = "eca61fd9-f491-4f03-a622-90837bbc1711",
  57. Authority = "https://login.microsoftonline.com/adfei.onmicrosoft.com",
  58. });
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement