/OwinOAuthProvidersDemo/App_Start/Startup.Auth.cs

https://github.com/tomasherceg/OwinOAuthProviders · C# · 82 lines · 27 code · 17 blank · 38 comment · 0 complexity · b79228ea8bd8deadb89c57d7dd4ec84a MD5 · raw file

  1. using System;
  2. using Microsoft.AspNet.Identity;
  3. using Microsoft.Owin;
  4. using Microsoft.Owin.Security.Cookies;
  5. using Owin;
  6. using Owin.Security.Providers.GitHub;
  7. using Owin.Security.Providers.GooglePlus;
  8. using Owin.Security.Providers.GooglePlus.Provider;
  9. using Owin.Security.Providers.LinkedIn;
  10. using Owin.Security.Providers.Yahoo;
  11. using Owin.Security.Providers.OpenID;
  12. using Owin.Security.Providers.Steam;
  13. namespace OwinOAuthProvidersDemo
  14. {
  15. public partial class Startup
  16. {
  17. // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
  18. public void ConfigureAuth(IAppBuilder app)
  19. {
  20. // Enable the application to use a cookie to store information for the signed in user
  21. app.UseCookieAuthentication(new CookieAuthenticationOptions
  22. {
  23. AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
  24. LoginPath = new PathString("/Account/Login")
  25. });
  26. // Use a cookie to temporarily store information about a user logging in with a third party login provider
  27. app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
  28. // Uncomment the following lines to enable logging in with third party login providers
  29. //app.UseMicrosoftAccountAuthentication(
  30. // clientId: "",
  31. // clientSecret: "");
  32. //app.UseTwitterAuthentication(
  33. // consumerKey: "",
  34. // consumerSecret: "");
  35. //app.UseFacebookAuthentication(
  36. // appId: "",
  37. // appSecret: "");
  38. //app.UseGoogleAuthentication();
  39. //app.UseLinkedInAuthentication("", "");
  40. //app.UseYahooAuthentication("", "");
  41. //app.UseGitHubAuthentication("", "");
  42. //var options = new GooglePlusAuthenticationOptions
  43. //{
  44. // ClientId = "",
  45. // ClientSecret = "",
  46. // RequestOfflineAccess = true,
  47. // Provider = new GooglePlusAuthenticationProvider
  48. // {
  49. // OnAuthenticated = async context => System.Diagnostics.Debug.WriteLine(String.Format("Refresh Token: {0}", context.RefreshToken))
  50. // }
  51. //};
  52. //options.MomentTypes.Add("http://schemas.google.com/AddActivity");
  53. //options.MomentTypes.Add("http://schemas.google.com/CheckInActivity");
  54. //options.MomentTypes.Add("http://schemas.google.com/BuyActivity");
  55. //app.UseGooglePlusAuthentication(options);
  56. //app.UseOpenIDAuthentication("http://me.yahoo.com/", "Yahoo");
  57. //app.UseOpenIDAuthentication("https://openid.stackexchange.com/", "StackExchange");
  58. //app.UseOpenIDAuthentication("https://www.google.com/accounts/o8/id", "Google");
  59. //app.UseSteamAuthentication(applicationKey: "");
  60. //app.UseOpenIDAuthentication("http://orange.fr", "Orange");
  61. // Use OpenId provider login uri instead of discovery uri
  62. //app.UseOpenIDAuthentication("http://openid.orange.fr/server", "Orange", true);
  63. }
  64. }
  65. }