Esempio n. 1
0
        public static void RegisterAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Logon")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            app.UseMicrosoftAccountAuthentication(
                clientId: WebConfigurationManager.AppSettings["social:LiveClientId"],
                clientSecret: WebConfigurationManager.AppSettings["social:LiveClientSecret"]);

            app.UseTwitterAuthentication(
                consumerKey: WebConfigurationManager.AppSettings["social:TwitterConsumerKey"],
                consumerSecret: WebConfigurationManager.AppSettings["social:TwitterConsumerSecret"]);

            app.UseFacebookAuthentication(
                appId: WebConfigurationManager.AppSettings["social:FaceBookAppId"],
                appSecret: WebConfigurationManager.AppSettings["social:FacebookAppSecret"]);

            //TODO: Deactivated due to Google no longer support OAuth2
            //app.UseGoogleAuthentication();
        }
        public void ConfigureWebAuth(IAppBuilder app)
        {
            //Utilisation de cookie pour stocker les informations sur les utilisateurs authentifiés
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                LoginPath          = new PathString("/Account/Login"),
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie
            });

            // Utilisation d'un cookie pour le stockage des info temporaires des utilisateurs authentifiés
            // via un fournisseur externe
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Activation du fournisseur d'authentification Microsoft
            app.UseMicrosoftAccountAuthentication(
                clientId: "00000000481106FF",
                clientSecret: "MqwDmwpeGTezV6o4sJdgVKIfZm76TZt6");

            // Activation du fournisseur d'authentification Facebook
            app.UseFacebookAuthentication(
                appId: "636293909765104",
                appSecret: "807a0a17eeaa20dabc1bd72f1be33775");

            // Activation du fournisseur d'authentification Google
            app.UseGoogleAuthentication();
        }
Esempio n. 3
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "000000004411CDA7",
                clientSecret: "1wdlteJjzoEmDTCbghxzXn9Ww8gHE1e4");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            app.UseGoogleAuthentication();
        }
Esempio n. 4
0
        public static void UsePortalsAuthentication <TUser>(this IAppBuilder app, StartupSettingsManager <TUser> manager)
            where TUser : CrmUser
        {
            CryptoConfig.AddAlgorithm(typeof(RSAPKCS1SHA256SignatureDescription), "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");

            if (manager.MicrosoftAccount != null)
            {
                app.UseMicrosoftAccountAuthentication(manager.MicrosoftAccount);
            }
            if (manager.Twitter != null)
            {
                app.UseTwitterAuthentication(manager.Twitter);
            }
            if (manager.Facebook != null)
            {
                app.UseFacebookAuthentication(manager.Facebook);
            }
            if (manager.Google != null)
            {
                app.UseGoogleAuthentication(manager.Google);
            }

            if (manager.LinkedIn != null)
            {
                app.UseLinkedInAuthentication(manager.LinkedIn);
            }
            if (manager.Yahoo != null)
            {
                app.UseYahooAuthentication(manager.Yahoo);
            }

            if (manager.WsFederationOptions != null)
            {
                foreach (var options in manager.WsFederationOptions)
                {
                    app.UseWsFederationAuthentication(options);
                }
            }

            if (manager.Saml2Options != null)
            {
                foreach (var options in manager.Saml2Options)
                {
                    app.UseSaml2Authentication(options);
                }
            }

            if (manager.OpenIdConnectOptions != null)
            {
                foreach (var options in manager.OpenIdConnectOptions)
                {
                    app.UseOpenIdConnectAuthentication(options);
                }
            }

            if (manager.AzureAdOptions != null)
            {
                app.UseOpenIdConnectAuthentication(manager.AzureAdOptions);
            }
        }
        // Para obtener más información para configurar la autenticación, visite http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Permitir que la aplicación use una cookie para almacenar información para el usuario que inicia sesión
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Quitar los comentarios de las siguientes líneas para habilitar el inicio de sesión con proveedores de inicio de sesión de terceros

            // Microsoft => https://account.live.com/developers/applications
            app.UseMicrosoftAccountAuthentication(
                clientId: "000000004C111F35",
                clientSecret: "deMeyaE3qw25PVxxH79ndrTfwyeVk9Ua");

            // Twitter => https://dev.twitter.com/
            app.UseTwitterAuthentication(
               consumerKey: "ZfAxJLtSy18Vc3ueOOA76w",
               consumerSecret: "EpEGdYKF2emLS6eouoPeiJe6tJi5C2pSOkBDnbUDKY");

            // Facebook => https://developers.facebook.com/apps/
            app.UseFacebookAuthentication(
               appId: "562262000476246",
               appSecret: "097b95d01c1f6942a3c08560c69a8848");

            app.UseGoogleAuthentication();
        }
        public void ConfigureWebAuth(IAppBuilder app)
        {
            //Utilisation de cookie pour stocker les informations sur les utilisateurs authentifiés
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                LoginPath = new PathString("/Account/Login"),
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie
            });

            // Utilisation d'un cookie pour le stockage des info temporaires des utilisateurs authentifiés
            // via un fournisseur externe
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Activation du fournisseur d'authentification Microsoft
            app.UseMicrosoftAccountAuthentication(
                clientId: "00000000481106FF",
                clientSecret: "MqwDmwpeGTezV6o4sJdgVKIfZm76TZt6");

            // Activation du fournisseur d'authentification Facebook
            app.UseFacebookAuthentication(
               appId: "636293909765104",
               appSecret: "807a0a17eeaa20dabc1bd72f1be33775");

            // Activation du fournisseur d'authentification Google
            app.UseGoogleAuthentication();
        }
Esempio n. 7
0
        public void Configuration(IAppBuilder app)
        {
            var unity = UnityConfig.GetConfiguredContainer();
            var config = new HttpConfiguration();
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
            config.MapHttpAttributeRoutes();
            config.DependencyResolver = new UnityDependencyResolver(unity);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
            app.UseOAuthBearerTokens(new OAuthAuthorizationServerOptions
            {
                AllowInsecureHttp = true,
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                ApplicationCanDisplayErrors = true,
                AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
                Provider = new OAuthProvider("self", () => unity.Resolve<IUserPasswordStore<User, Guid>>(), unity.Resolve<IPasswordHasher>()),
                TokenEndpointPath = new PathString("/Token"),
            });
            var settings = ConfigurationManager.AppSettings;
            app.UseMicrosoftAccountAuthentication(settings.Get("MicrosoftClientId"), settings.Get("MicrosoftClientSecret"))
               .UseTwitterAuthentication(settings.Get("TwitterConsumerKey"), settings.Get("TwitterConsumerSecret"))
               .UseFacebookAuthentication(settings.Get("FacebookAppId"), settings.Get("FacebookAppSecret"))
               .UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions
               {
                   ClientId = settings.Get("GoogleClientId"),
                   ClientSecret = settings.Get("GoogleClientSecret")
               });

            app.UseWebApi(config);
            AutoMapperConfig.Configure();
        }
Esempio n. 8
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "0000000040110865",
                clientSecret: "sk6T9LprRnHlnk74IJmz6z5NcAjyGKtm");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            app.UseFacebookAuthentication(
                appId: "244418352318084",
                appSecret: "f39b49a290337ef6d848723cea64507b");

            app.UseGoogleAuthentication();
        }
Esempio n. 9
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "a7e5363e-7adc-48b5-a925-84665bf76967",
                clientSecret: "364a5meOOG6tWd3tn818ocz");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            var google = new GoogleOAuth2AuthenticationOptions
            {
                ClientId     = "1083928209918-uc5k68p9qv7plnmnfh7281ke46s60apd.apps.googleusercontent.com",
                ClientSecret = "f0fkgJpiB46SraSHQeenxeRd"
            };

            app.UseGoogleAuthentication(google);
        }
Esempio n. 10
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            var context = System.Web.HttpContext.Current;

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: WebConfigurationManager.AppSettings["MicrosoftAuthClientId"] ?? "1",
                clientSecret: WebConfigurationManager.AppSettings["MicrosoftAuthClientSecret"] ?? "1");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            app.UseGoogleAuthentication();
        }
Esempio n. 11
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login"),
                Provider           = new CookieAuthenticationProvider
                {
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers

            app.UseMicrosoftAccountAuthentication(
                clientId: "000000004C1180DA",
                clientSecret: "jOSds3NsLxWVSHf9w03-Njfj0DKqm0jm");

            app.UseGoogleAuthentication();

            app.UseYahooAuthentication("dj0yJmk9anFzSjRoNnFmc3dxJmQ9WVdrOWJrNVFjVTlRTkhFbWNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD1mYg--", "1118b72e19968acd0f33580d725dd7b5ca4967aa");
        }
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie, isPersistent: true);

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers
            string microsoftClientId = ConfigurationManager.AppSettings["microsoft_clientid"];
            string microsoftClientSecret = ConfigurationManager.AppSettings["microsoft_clientsecret"];
            if (microsoftClientId != null && microsoftClientSecret != null)
            {
                app.UseMicrosoftAccountAuthentication(microsoftClientId, microsoftClientSecret);
            }

            string twitterConsumerKey = ConfigurationManager.AppSettings["twitter_consumerkey"];
            string twitterConsumerSecret = ConfigurationManager.AppSettings["twitter_consumersecret"];
            if (twitterConsumerKey != null && twitterConsumerSecret != null)
            {
                app.UseTwitterAuthentication(twitterConsumerKey, twitterConsumerSecret);
            }

            string fbAppId = ConfigurationManager.AppSettings["facebook_appid"];
            string fbAppSecret = ConfigurationManager.AppSettings["facebook_appsecret"];
            if (fbAppId != null && fbAppSecret != null)
            {
                app.UseFacebookAuthentication(fbAppId, fbAppSecret);
            }

            app.UseGoogleAuthentication();
        }
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            app.UseMicrosoftAccountAuthentication(
                clientId: ConfigurationManager.AppSettings["MsAccountClientId"],
                clientSecret: ConfigurationManager.AppSettings["MsAccountClientSecret"]);

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            //app.UseGoogleAuthentication();
        }
Esempio n. 14
0
        public void Configuration(IAppBuilder app)
        {
            app.CreatePerOwinContext <AppDbContext>(AppDbContext.Create);
            app.CreatePerOwinContext <AppUserManager>(AppUserManager.Create);
            app.CreatePerOwinContext <AppSignInManager>(AppSignInManager.Create);

            app.UseCookieAuthentication(
                new CookieAuthenticationOptions()
            {
                //AuthenticationMode = AuthenticationMode.Active,
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login")
            }
                );
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            //https://developers.facebook.com/apps/
            //https://localhost:44349/signin-facebook
            app.UseFacebookAuthentication("195976144194610", "7c91f8bfd89f0b1bf3e0cf2e0dfa69fb");

            //https://apps.dev.microsoft.com/#/appList
            //https://localhost:44349/signin-microsoft
            app.UseMicrosoftAccountAuthentication("59359d74-e18f-4a5c-b21a-6f4d7753d392", "rB0ZE3CcxUyYosUrtPYFUTH");

            //https://vk.com/apps?act=manage
            //https://localhost:44349/signin-vkontakte
            app.UseVkontakteAuthentication("5775688", "RY21KkaQXtgWJPcTjPJ9");

            //https://github.com/settings/developers
            //https://localhost:44349/signin-github
            app.UseGithubAuthentication("8ab02bf3204e39faacdc", "e96c920a1130d8d9b9708e4d8adf06ca0898ab13");

            app.UseTwitterAuthentication("123", "321");
        }
Esempio n. 15
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "000000004C172782",
                clientSecret: "9rjrusF64Ws2Ksd67DVgyPgd0101i4jw");

            app.UseTwitterAuthentication(
                consumerKey: "QBAhakLsIl794uEEAX8csF3tP",
                consumerSecret: "ML44lD3gjDWfF1VR2SRmYa8Ic0VPUEk9FwraEBs0iP3awfvKuS");

            app.UseFacebookAuthentication(
                appId: "523635924470241",
                appSecret: "ef29066fd82cb20e746b52c00c7e34a7");

            app.UseGoogleAuthentication(new Microsoft.Owin.Security.Google.GoogleOAuth2AuthenticationOptions() {   ClientId = "122905730574.apps.googleusercontent.com", ClientSecret = "AjLf5P2WiGXIQrKqeTBRifAr" });
        }
Esempio n. 16
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // 3rd party providers
            var microsoftAppId = ConfigurationManager.AppSettings["MicrosoftAppId"];
            var microsoftAppSecret = ConfigurationManager.AppSettings["MicrosoftAppSecret"];
            if (microsoftAppId != null && microsoftAppSecret != null)
                app.UseMicrosoftAccountAuthentication(microsoftAppId, microsoftAppSecret);

            var twitterAppId = ConfigurationManager.AppSettings["TwitterAppId"];
            var twitterAppSecret = ConfigurationManager.AppSettings["TwitterAppSecret"];
            if (twitterAppId != null && twitterAppSecret != null)
                app.UseTwitterAuthentication(twitterAppId, twitterAppSecret);

            var facebookAppId = ConfigurationManager.AppSettings["FacebookAppId"];
            var facebookAppSecret = ConfigurationManager.AppSettings["FacebookAppSecret"];
            if (facebookAppId != null && facebookAppSecret != null)
                app.UseFacebookAuthentication(facebookAppId, facebookAppSecret);

            app.UseGoogleAuthentication();
        }
Esempio n. 17
0
        // For more information on configuring authentication, please visit https://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext <ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login"),
                Provider           = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // 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.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            string microsoftClientId     = Util.Config.TryGetEnvironmentVariable("MicrosoftClientId");
            string microsoftClientSecret = Util.Config.TryGetEnvironmentVariable("MicrosoftClientSecret");

            app.UseMicrosoftAccountAuthentication(
                clientId: microsoftClientId,
                clientSecret: microsoftClientSecret);

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");
            string facebookAppId     = Util.Config.TryGetEnvironmentVariable("FacebookAppId");
            string facebookAppSecret = Util.Config.TryGetEnvironmentVariable("FacebookAppSecret");

            app.UseFacebookAuthentication(
                appId: facebookAppId,
                appSecret: facebookAppSecret);

            string googleClientId     = Util.Config.TryGetEnvironmentVariable("GoogleClientId");
            string googleClientSecret = Util.Config.TryGetEnvironmentVariable("GoogleClientSecret");

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId     = googleClientId,
                ClientSecret = googleClientSecret
            });
        }
Esempio n. 18
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "0000000044189525",
                clientSecret: "o4iVs0qr3b7-pEzFY4hcdOzMza7lchvy");

            app.UseTwitterAuthentication(
                consumerKey: "dKTJV7W0ehIsF9Aqg4kKBNQqi",
                consumerSecret: "2UJem1Ig1fVscsVUiM30jjwnoZHTzpf0Nd1c1WH3OIjL7fxZSz");

            app.UseVkontakteAuthentication("5445557", "9ktOlEbsK0PKDQERfbX0", "email,audio");

            app.UseFacebookAuthentication(
                appId: "1132958306748373",
                appSecret: "a669ee46cdc0d19705332d9dd43378a9");

            app.UseGoogleAuthentication(clientId: "637443079528-hdv21jbom72q19m6bkq0bjjma2c9lknn.apps.googleusercontent.com",
                                        clientSecret: "M78YLMp1T9ake8imJ7iZrPx5");
        }
Esempio n. 19
0
        public void ConfigureAuth(IAppBuilder app)
        {
            app.CreatePerOwinContext(() => new DurandalAuthDbContext());
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

            //Enable Cors support in the Web API. Should go before the activation of Bearer tokens
            //http://aspnetwebstack.codeplex.com/discussions/467315
            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enable the application to use bearer tokens to authenticate users
            // Enabling 3 components:
            // 1. Authorization Server middleware. For creating the bearer tokens
            // 2. Application bearer token middleware. Will atuthenticate every request with Authorization : Bearer header
            // 3. External bearer token middleware. For external providers
            app.UseOAuthBearerTokens(OAuthOptions);

            app.UseMicrosoftAccountAuthentication(ConfigurationManager.AppSettings["MicrosoftKey"], ConfigurationManager.AppSettings["MicrosoftSecret"]);

            app.UseTwitterAuthentication(ConfigurationManager.AppSettings["TwitterKey"], ConfigurationManager.AppSettings["TwitterSecret"]);

            app.UseFacebookAuthentication(ConfigurationManager.AppSettings["FacebookKey"], ConfigurationManager.AppSettings["FacebookSecret"]);

            app.UseGoogleAuthentication();       
        }
Esempio n. 20
0
        private static void EnableAuthenticationProviders(IAppBuilder app)
        {
            var enabledProviders =
                WebConfigurationManager.AppSettings["AuthenticationProviders"].Split(',')
                .Select(x => x.Trim())
                .Where(x => !string.IsNullOrWhiteSpace(x)).ToList();

            if (IsEnabled("Microsoft", enabledProviders))
            {
                app.UseMicrosoftAccountAuthentication(GetMicrosoftAuthenticationOptions());
            }
            if (IsEnabled("Twitter", enabledProviders))
            {
                app.UseTwitterAuthentication(GetTwitterAuthenticationOptions());
            }
            if (IsEnabled("Facebook", enabledProviders))
            {
                app.UseFacebookAuthentication(GetFacebookAuthenticationOptions());
            }
            if (IsEnabled("Google", enabledProviders))
            {
                app.UseGoogleAuthentication(GetGoogleAuthenticationOptions());
            }

            foreach (var provider in enabledProviders.Where(x => x.StartsWith("WsFederation")))
            {
                app.UseWsFederationAuthentication(GetWsFederationOptions(provider));
            }
        }
Esempio n. 21
0
        public void ConfigureAuth(IAppBuilder app)
        {
            app.CreatePerOwinContext(() => new DurandalAuthDbContext());
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

            //Enable Cors support in the Web API. Should go before the activation of Bearer tokens
            //http://aspnetwebstack.codeplex.com/discussions/467315
            app.UseCors(CorsOptions.AllowAll);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enable the application to use bearer tokens to authenticate users
            // Enabling 3 components:
            // 1. Authorization Server middleware. For creating the bearer tokens
            // 2. Application bearer token middleware. Will atuthenticate every request with Authorization : Bearer header
            // 3. External bearer token middleware. For external providers
            app.UseOAuthBearerTokens(OAuthOptions);

            app.UseMicrosoftAccountAuthentication(
                ConfigurationManager.AppSettings["MicrosoftKey"],
                ConfigurationManager.AppSettings["MicrosoftSecret"]);

            app.UseTwitterAuthentication(
                ConfigurationManager.AppSettings["TwitterKey"],
                ConfigurationManager.AppSettings["TwitterSecret"]);

            app.UseFacebookAuthentication(
                ConfigurationManager.AppSettings["FacebookKey"],
                ConfigurationManager.AppSettings["FacebookSecret"]);

            app.UseGoogleAuthentication();
        }
Esempio n. 22
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "000000004C172782",
                clientSecret: "9rjrusF64Ws2Ksd67DVgyPgd0101i4jw");

            app.UseTwitterAuthentication(
                consumerKey: "QBAhakLsIl794uEEAX8csF3tP",
                consumerSecret: "ML44lD3gjDWfF1VR2SRmYa8Ic0VPUEk9FwraEBs0iP3awfvKuS");

            app.UseFacebookAuthentication(
                appId: "523635924470241",
                appSecret: "ef29066fd82cb20e746b52c00c7e34a7");

            app.UseGoogleAuthentication(new Microsoft.Owin.Security.Google.GoogleOAuth2AuthenticationOptions()
            {
                ClientId = "122905730574.apps.googleusercontent.com", ClientSecret = "AjLf5P2WiGXIQrKqeTBRifAr"
            });
        }
Esempio n. 23
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "000000004C10DD37",
                clientSecret: "RYELs9crdp8Eebca5YeO0cQQBzbsyGN8");

            app.UseTwitterAuthentication(
               consumerKey: "LHpUEuCYelGiT1zYJrHTDw",
               consumerSecret: "VZnwWxOfzFv9K9FOrfirz2fhD47wgSMo5m41zV3Has");

            app.UseFacebookAuthentication(
               appId: "207117879494713",
               appSecret: "a9496a24c4a27bb5b3ecbb9805306afc");

            app.UseGoogleAuthentication();
        }
Esempio n. 24
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "000000004C111DB7",
                clientSecret: "KSzUymCU0bPhZ0HyQbtWz58pBU0sIsF0" );

            //app.UseTwitterAuthentication(
            //    consumerKey: "",
            //    consumerSecret: "");

            //app.UseFacebookAuthentication(
            //    appId: "",
            //    appSecret: "");

            //app.UseGoogleAuthentication();
        }
Esempio n. 25
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication( new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString( "/Account/Login" )
            } );
            app.UseExternalSignInCookie( DefaultAuthenticationTypes.ExternalCookie );

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "000000004810F526",
                clientSecret: "f8LRRVF20XHwK6N58e4I9r99SEC7Ao0S" );

            app.UseTwitterAuthentication(
               consumerKey: "PqRSqRIrWw8EJty1Gat0ZA",
               consumerSecret: "gsElizO6qYGPA1RMApWdp1BpsmfvRYXXBWmd0hs8" );

            app.UseFacebookAuthentication(
               appId: "449783478408068",
               appSecret: "a058d3068f6b29bc0149e5987b9e823a" );

            app.UseGoogleAuthentication();
        }
Esempio n. 26
0
        private void ConfigureAuth(IAppBuilder app)
        {
            app.MapSignalR();

            var cookieOptions = new CookieAuthenticationOptions
            {
                LoginPath = new PathString("/Account/Login")
            };

            app.UseCookieAuthentication(cookieOptions);

            app.SetDefaultSignInAsAuthenticationType(cookieOptions.AuthenticationType);

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions
            {
                ClientId     = "713668382610-k78pothi94ohd6jj0ha6fj2kopc3u1lc.apps.googleusercontent.com",
                ClientSecret = "xtqVIrE5U992a_fUGcSjg4I0"
            });

            app.UseFacebookAuthentication(
                appId: "000000000000000",
                appSecret: "000000000000000");

            app.UseMicrosoftAccountAuthentication(
                clientId: "426f62526f636b73",
                clientSecret: "57686f6120447564652c2049495320526f636b73");
        }
Esempio n. 27
0
        // For more information on configuring authentication, please visit https://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext <ApplicationSignInManager>(ApplicationSignInManager.Create);
            app.CreatePerOwinContext <ApplicationRoleManager>(ApplicationRoleManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Login/Login"),
                Provider           = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager, DefaultAuthenticationTypes.ApplicationCookie))
                }
            });

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure the application for OAuth based flow
            PublicClientId = "self";
            OAuthOptions   = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath         = new PathString("/Token"),
                Provider                  = new ApplicationOAuthProvider(PublicClientId),
                AuthorizeEndpointPath     = new PathString("/api/Account/ExternalLogin"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                // In production mode set AllowInsecureHttp = false
                AllowInsecureHttp = true
            };

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "23e184df-eb8a-4d95-939e-eb7de7f98fe6",
                clientSecret: "g_.b4..1_r6r.X909B7Df.qBqDK2kflfxZ");

            //app.UseTwitterAuthentication(
            //    consumerKey: "",
            //    consumerSecret: "");

            //app.UseFacebookAuthentication(
            //    appId: "",
            //    appSecret: "");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});
        }
Esempio n. 28
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "0000000040110865",
                clientSecret: "sk6T9LprRnHlnk74IJmz6z5NcAjyGKtm");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            app.UseFacebookAuthentication(
               appId: "244418352318084",
               appSecret: "f39b49a290337ef6d848723cea64507b");

            app.UseGoogleAuthentication();
        }
Esempio n. 29
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            app.UseCors(new CorsOptions {PolicyProvider = new CustomOwinCorsPolicyProvider()});

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
            
            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: ConfigurationManager.AppSettings.Get("OAuthMicrosoftKey"),
                clientSecret: ConfigurationManager.AppSettings.Get("OAuthMicrosoftSecret"));

            app.UseTwitterAuthentication(
                consumerKey: ConfigurationManager.AppSettings.Get("OAuthTwitterKey"),
                consumerSecret: ConfigurationManager.AppSettings.Get("OAuthTwitterSecret"));

            app.UseFacebookAuthentication(
                appId: ConfigurationManager.AppSettings.Get("OAuthFacebookKey"),
                appSecret: ConfigurationManager.AppSettings.Get("OAuthFacebookSecret"));

            app.UseGoogleAuthentication();
        }
Esempio n. 30
0
 public void Configuration(IAppBuilder app)
 {
     // Para obtener más información sobre cómo configurar la aplicación, visite https://go.microsoft.com/fwlink/?LinkID=316888
     app.UseCookieAuthentication(
         new Microsoft.Owin.Security.Cookies.CookieAuthenticationOptions()
     {
         //especificamos el tipo de autenticacion que vamos a necesitar
         AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
         //login path indica que debe cambiar al status 401 unauthorized por el status 302 el cual nos redicrecciona a una ruta especifica
         LoginPath = new PathString("/account/login")
     }
         );
     ///utilizamos una cookie para autenticacion externa de la siguiente manera
     ///utilizaremos proveedores de servicios de autenticacion como facebook y google
     app.UseExternalSignInCookie(
         DefaultAuthenticationTypes.ExternalCookie ///utilizamos una cookie externa
         );
     ///utilizaremos una cookie externa para poder logearnos en nuestra aplicacion
     app.UseFacebookAuthentication(appId: "176463290452727", appSecret: "9ba12df78212eea0b7944726fb34bb96");
     ///utilizaremos una cookie externa de microsoft account para logearnos
     app.UseMicrosoftAccountAuthentication(clientId: "some one", clientSecret: "some one");
     ///utilizamos una ccokie externa para logearnos con google
     app.UseGoogleAuthentication(clientId: "some one", clientSecret: "some one");
     //twitter autgentication cookie
 }
Esempio n. 31
0
 private static void ProcessSiginOption(IAppBuilder app, SigininOptionConfig signinConfig)
 {
     switch (signinConfig.SigninOption)
     {
         case SigninOption.MicrosoftAccount:
             app.UseMicrosoftAccountAuthentication(
                 clientId: signinConfig.IdOrKey,
                 clientSecret: signinConfig.Secret);
             break;
         case SigninOption.Twitter:
             app.UseTwitterAuthentication(
                consumerKey: signinConfig.IdOrKey,
                consumerSecret: signinConfig.Secret);
             break;
         case SigninOption.Facebook:
             app.UseFacebookAuthentication(
                appId: signinConfig.IdOrKey,
                appSecret: signinConfig.Secret);
             break;
         case SigninOption.Google:
             app.UseGoogleAuthentication(
                 clientId: signinConfig.IdOrKey,
                 clientSecret: signinConfig.Secret);
             break;
         default:
             break;
     }
 }
Esempio n. 32
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "000000004C10FE6B",
                clientSecret: "000000004C10FE6B");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            app.UseFacebookAuthentication(
                appId: "1444102912469389",
                appSecret: "ea379b32315aec0d73f7d103c49cd552");

            app.UseGoogleAuthentication();
        }
Esempio n. 33
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            //// Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "000000004816C85F",
            //    clientSecret: "LSWTjIJiG32Ys0-xkWdd5EZxitajKUIk");

            //new
            app.UseMicrosoftAccountAuthentication(new MicrosoftAccountAuthenticationOptions()
            {
                ClientId     = "000000004816C85F",
                ClientSecret = "LSWTjIJiG32Ys0-xkWdd5EZxitajKUIk",
                Provider     = new LinqToMicrosoftAuthenticationProvider(),
                Scope        = { "wl.basic", "wl.emails" }
                //
            });
            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            //app.UseGoogleAuthentication();
        }
Esempio n. 34
0
        public void SetAllConfiguredAuthProviders(IAppBuilder app)
        {
            foreach (AuthProvider provider in (ConfigurationManager.GetSection("authenticationProviders") as AuthProviders).Providers)
            {
                switch (provider.ProviderName)
                {
                case "Twitter":
                    app.UseTwitterAuthentication(consumerKey: provider.Key, consumerSecret: provider.Secret);
                    break;

                case "Facebook":
                    app.UseFacebookAuthentication(appId: provider.Key, appSecret: provider.Secret);
                    break;

                case "Microsoft":
                    app.UseMicrosoftAccountAuthentication(clientId: provider.Key, clientSecret: provider.Secret);
                    break;

                case "Google":
                    app.UseGoogleAuthentication();
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 35
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
#if DEBUG
                ExpireTimeSpan = TimeSpan.FromDays(30),
#endif
                LoginPath  = new PathString("/Account/Login"),
                CookieName = GlobalConstants.AuthCookieName
            });

            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            //// Uncomment the following lines to enable logging in with third party login providers

            string appId     = ConfigurationManager.AppSettings.Get("AzureAuthAppId");
            string appSecret = ConfigurationManager.AppSettings.Get("AzureAuthAppSecret");

            app.UseMicrosoftAccountAuthentication(
                clientId: appId,
                clientSecret: appSecret);

            //// app.UseTwitterAuthentication(
            ////   consumerKey: "",
            ////   consumerSecret: "");

            //// app.UseFacebookAuthentication(
            ////   appId: "",
            ////   appSecret: "");

            //app.UseGoogleAuthentication();
        }
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "000000004810BE56",
                clientSecret: "bAORWpckUYsxBZACJUsiIxJNAE3r7S2x");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            app.UseGoogleAuthentication();
        }
Esempio n. 37
0
        // 有关配置身份验证的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkId=301883
        public void ConfigureAuth(IAppBuilder app)
        {
            // 配置数据库上下文、用户管理器和登录管理器,以便为每个请求使用单个实例
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext <ApplicationSignInManager>(ApplicationSignInManager.Create);

            // 使应用程序可以使用 Cookie 来存储已登录用户的信息
            // 使用 Cookie 临时存储有关某个用户使用第三方登录提供程序进行登录的信息
            // 配置登录 Cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login"),
                Provider           = new CookieAuthenticationProvider
                {
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            // 使用 Cookie 临时存储有关某个用户使用第三方登录提供程序进行登录的信息
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // 使应用程序可以在双重身份验证过程中验证第二因素时暂时存储用户信息。
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // 使应用程序可以记住第二登录验证因素,例如电话或电子邮件。
            // 选中此选项后,登录过程中执行的第二个验证步骤将保存到你登录时所在的设备上。
            // 此选项类似于在登录时提供的“记住我”选项。
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // 取消注释以下行可允许使用第三方登录提供程序登录
            app.UseMicrosoftAccountAuthentication(
                clientId: "123",
                clientSecret: "123");

            app.UseTwitterAuthentication(
                consumerKey: "123",
                consumerSecret: "123");

            app.UseFacebookAuthentication(
                appId: "123",
                appSecret: "123");

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId     = "123",
                ClientSecret = "123"
            });

            app.UseTencentAuthentication(new TencentAuthenticationOptions()
            {
                AppId     = "122",
                AppSecret = "1212"
            });
        }
Esempio n. 38
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext <ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login"),
                Provider           = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // 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.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Keys altered for security

            // https://apps.dev.microsoft.com
            app.UseMicrosoftAccountAuthentication(
                clientId: "xxxxxx-afb4-4364-8a4e-2698be5233d1",
                clientSecret: "xxxxxxxxxxxx");

            // https://apps.twitter.com/
            app.UseTwitterAuthentication(
                consumerKey: "y0QjP0vDMCeQ0etOb3ckJcocB",
                consumerSecret: "gMfxlEilLMkVqxrfa5TF53tuIqTrjYrDyXiGhDpTOWvaz19Hqk");

            // https://developers.facebook.com/apps/
            app.UseFacebookAuthentication(
                appId: "4444444444444",
                appSecret: "xxxxxxxxxxxxxxx");

            // https://console.developers.google.com/
            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId     = "xxxxxxxx-n4ap4qq6cr9m0jeo36gv5fdh4djqh89q.apps.googleusercontent.com",
                ClientSecret = "xxxxxxxxxxxxx"
            });
        }
Esempio n. 39
0
        // For more information on configuring authentication, please visit https://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext <ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login"),
                Provider           = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // 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.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            //Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "bf87512c-10ee-4a92-adde-b21eaa661573",
                clientSecret: "ibntmTPPKSP983#lwA09}[-"
                );

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");


            //for facebook oauth//
            //app.UseFacebookAuthentication(
            //   appId: "280457412811651",
            //   appSecret: "92f309a359675da1ef9743b3bee7db6e"
            //   );

            //google authentication//
            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId     = "989291589758-oh6lv19lb8de6co2s35cn7v5kuobemoa.apps.googleusercontent.com",
                ClientSecret = "k02mL9lgoMDfOVdQ1oJ_FW4F"
            });
        }
Esempio n. 40
0
 public static void UseMicrosoftAccountAuthentication(IAppBuilder app)
 {
     if (!string.IsNullOrWhiteSpace(AppConfig.MicrosoftAPIKey) && !string.IsNullOrWhiteSpace(AppConfig.MicrosoftSecretKey))
     {
         app.UseMicrosoftAccountAuthentication(
             clientId: AppConfig.MicrosoftAPIKey,
             clientSecret: AppConfig.MicrosoftSecretKey);
     }
 }
Esempio n. 41
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Allow all CORS requests
            app.UseCors(CorsOptions.AllowAll);

            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(RestContext.Create);
            app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure the application for OAuth based flow
            PublicClientId = "self";
            OAuthOptions   = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath         = new PathString("/Token"),
                Provider                  = new ApplicationOAuthProvider(PublicClientId),
                AuthorizeEndpointPath     = new PathString("/api/Account/ExternalLogin"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                // In production mode set AllowInsecureHttp = false
                AllowInsecureHttp = true
            };

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers
            var microsoftAuthentication = new MicrosoftAccountAuthenticationOptions();

            microsoftAuthentication.ClientId     = "000000004C16836C";
            microsoftAuthentication.ClientSecret = "R2GPxr8k-dIftBnAEhLRXLjuTsiIxNpl";
            app.UseMicrosoftAccountAuthentication(microsoftAuthentication);

            var twitterAuthentication = new TwitterAuthenticationOptions();

            twitterAuthentication.ConsumerKey    = "wOS8t5pPraOLwTH79OlgyttW6";
            twitterAuthentication.ConsumerSecret = "gj9iMcmsixA8UvcsTRqxxoCkzkrpDKc4vuzKGpFjTRiNv3aldl";
            app.UseTwitterAuthentication(twitterAuthentication);

            var facebookAuthenticationOptions = new FacebookAuthenticationOptions();

            facebookAuthenticationOptions.AppId     = "1645027742443677";
            facebookAuthenticationOptions.AppSecret = "baf2eea96164855d5e0d436c6e4c9365";
            app.UseFacebookAuthentication(facebookAuthenticationOptions);

            var googleAuthenticationOptions = new GoogleOAuth2AuthenticationOptions();

            googleAuthenticationOptions.ClientId     = "867920998848-h8vsdddu2o8dkv72243d8phu599dejgt.apps.googleusercontent.com";
            googleAuthenticationOptions.ClientSecret = "k25jN1BX4bBtWxlNbaBMeIIk";
            googleAuthenticationOptions.CallbackPath = new PathString("/signin-google");
            googleAuthenticationOptions.Provider     = new GoogleOAuth2AuthenticationProvider();
            googleAuthenticationOptions.Scope.Add("email");
            app.UseGoogleAuthentication(googleAuthenticationOptions);
        }
Esempio n. 42
0
        // For more information on configuring authentication, please visit https://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext <ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login"),
                Provider           = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, User, int>(
                        validateInterval: TimeSpan.FromMinutes(2),
                        regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager),
                        getUserIdCallback: (id) => int.Parse(id.GetUserId()))
                },
                ExpireTimeSpan = TimeSpan.FromDays(3)
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // 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.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(new MicrosoftAccountAuthenticationOptions()
            {
                ClientId     = ConfigurationManager.AppSettings["ClientIdMicrosoft"],
                ClientSecret = ConfigurationManager.AppSettings["ClientSecretMicrosoft"],
                Scope        = { "wl.basic", "wl.emails" }
            });

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId     = ConfigurationManager.AppSettings["ClientIdGoogle"],
                ClientSecret = ConfigurationManager.AppSettings["ClientSecretGoogle"],
            });
        }
Esempio n. 43
0
        protected override void AttachToOwinApp(IGalleryConfigurationService config, IAppBuilder app)
        {
            var options = new MicrosoftAccountAuthenticationOptions();

            options.Scope.Add("wl.emails");
            options.Scope.Add("wl.signin");
            Config.ApplyToOwinSecurityOptions(options);
            app.UseMicrosoftAccountAuthentication(options);
        }
Esempio n. 44
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and role manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext <ApplicationRoleManager>(ApplicationRoleManager.Create);
            app.CreatePerOwinContext <ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login"),
                Provider           = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser, string>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager),
                        // Need to add THIS line because we added the third type argument (int) above:
                        getUserIdCallback: (claim) => claim.GetUserId())
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // 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.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "abc",
                clientSecret: "abc");

            app.UseTwitterAuthentication(
                consumerKey: "abc",
                consumerSecret: "abc");

            app.UseFacebookAuthentication(
                appId: "abc",
                appSecret: "abc");

            app.UseGoogleAuthentication(
                clientId: "732381010129-js5u5k5qras0mkdma1o0hc36htluekn4.apps.googleusercontent.com",
                clientSecret: "bcGDRieg1Kr0YoMqlPwe09QO");

            app.UseWeChatAuthentication(
                appId: "abc", appSecret: "abc"
                );
        }
Esempio n. 45
0
        public void MicrosoftAuthenticationWithProviderConfiguration(IAppBuilder app)
        {
            app.UseAuthSignInCookie();

            var option = new MicrosoftAccountAuthenticationOptions()
            {
                ClientId     = "000000004C0F442C",
                ClientSecret = "EkXbW-Vr6Rqzi6pugl1jWIBsDotKLmqR",
                Provider     = new MicrosoftAccountAuthenticationProvider()
                {
                    OnAuthenticated = async context =>
                    {
                        await Task.Run(() =>
                        {
                            Assert.Equal <string>("ValidAccessToken", context.AccessToken);
                            Assert.Equal <string>("ValidRefreshToken", context.RefreshToken);
                            Assert.Equal <string>("Owinauthtester", context.FirstName);
                            Assert.Equal <string>("fccf9a24999f4f4f", context.Id);
                            Assert.Equal <string>("Owinauthtester", context.LastName);
                            Assert.Equal <string>("Owinauthtester Owinauthtester", context.Name);
                            Assert.NotNull(context.User);
                            Assert.Equal <string>(context.Id, context.User.SelectToken("id").ToString());
                            context.Identity.AddClaim(new Claim("Authenticated", "true"));
                        });
                    },
                    OnReturnEndpoint = async context =>
                    {
                        await Task.Run(() =>
                        {
                            if (context.Identity != null && context.SignInAsAuthenticationType == "Application")
                            {
                                context.Identity.AddClaim(new Claim("ReturnEndpoint", "true"));
                                context.Identity.AddClaim(new Claim(context.Identity.RoleClaimType, "Guest", ClaimValueTypes.String));
                            }
                            else if (context.Identity == null)
                            {
                                context.Identity = new ClaimsIdentity("Microsoft", "Name_Failed", "Role_Failed");
                                context.SignInAsAuthenticationType = "Application";
                            }
                        });
                    },
                    OnApplyRedirect = context =>
                    {
                        context.Response.Redirect(context.RedirectUri + "&custom_redirect_uri=custom");
                    }
                },
                BackchannelHttpHandler          = new MicrosoftChannelHttpHandler(),
                BackchannelCertificateValidator = new CustomCertificateValidator(),
                StateDataFormat = new CustomStateDataFormat(),
            };

            option.Scope.Add("wl.basic");
            option.Scope.Add("wl.signin");

            app.UseMicrosoftAccountAuthentication(option);
            app.UseExternalApplication("Microsoft");
        }
Esempio n. 46
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
                ,
                Provider = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser, int>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager), getUserIdCallback: (id) => (id.GetUserId<int>()))
                }
            }
            );
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // 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.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "0000000044168C24",
                clientSecret: "rLRmutBi-lmK6LYFOpMhwLIqKjBYz0YQ");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            app.UseFacebookAuthentication(
               appId: "1508306016149534",
               appSecret: "2663a9a27fa5af04c7192a35d9151a96");

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId = "117337387843-ggvs13ctb4j8t5v578hbkgijbaj05jt0.apps.googleusercontent.com",
                ClientSecret = "z7pLeAJ71X0Wn3xcyfjNJr9S"
            });
        }
Esempio n. 47
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            var msAuthOptions = new MicrosoftAccountAuthenticationOptions();
            msAuthOptions.Scope.Add("wl.basic");
            msAuthOptions.Scope.Add("wl.emails");
            msAuthOptions.ClientId = ConfigurationManager.AppSettings["msClientId"];
            msAuthOptions.ClientSecret = ConfigurationManager.AppSettings["msClientSecret"];
            app.UseMicrosoftAccountAuthentication(msAuthOptions);

            //            app.UseTwitterAuthentication(
            //                consumerKey: ConfigurationManager.AppSettings["consumerKey"],
            //                consumerSecret: ConfigurationManager.AppSettings["consumerSecret"]
            //            );

            var fbAuthOptions = new FacebookAuthenticationOptions
            {
                AppId = ConfigurationManager.AppSettings["fbAppId"],
                AppSecret = ConfigurationManager.AppSettings["fbAppSecret"]
            };

            fbAuthOptions.Scope.Add("email");
            fbAuthOptions.Scope.Add("public_profile");
            fbAuthOptions.Scope.Add("user_friends");
            fbAuthOptions.Provider = new FacebookAuthenticationProvider
            {
                OnAuthenticated = context =>
                {
                    context.Identity.AddClaim(new Claim("FacebookAccessToken", context.AccessToken));
                    return Task.FromResult(true);
                }
            };
            app.UseFacebookAuthentication(fbAuthOptions);

            app.UseGoogleAuthentication(
                clientId: ConfigurationManager.AppSettings["googleClientId"],
                clientSecret: ConfigurationManager.AppSettings["googleClientSecret"]
            );

            app.UseLinkedInAuthentication(new LinkedInAuthenticationOptions
            {
                ClientId = ConfigurationManager.AppSettings["linkedinClientId"],
                ClientSecret = ConfigurationManager.AppSettings["linkedinClientSecret"]
            });
        }
Esempio n. 48
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(AppDbContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                SlidingExpiration = false,
                ExpireTimeSpan = TimeSpan.FromDays(30),
                Provider = new CookieAuthenticationProvider
                {
                    OnValidateIdentity =
                        SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, User>(
                            validateInterval: TimeSpan.FromMinutes(30),
                            regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseGoogleAuthentication("1058035413863-pmbgn6n7slu0nph17l96nu65r9oeuqui.apps.googleusercontent.com", "J5wsfYCsgClB9G5miL7Bj8A7");

            var facebookOptions = new FacebookAuthenticationOptions()
            {
                AppId = "899746186808173",
                AppSecret = "4a339373d1748469a27a021c376a6ac2",
                BackchannelHttpHandler = new FacebookBackChannelHandler(),
                UserInformationEndpoint = "https://graph.facebook.com/v2.4/me?fields=id,name,email,first_name,last_name,location"
            };

            facebookOptions.Scope.Add("email");

            app.UseFacebookAuthentication(facebookOptions);

            var microsoftOptions = new MicrosoftAccountAuthenticationOptions
            {
                Caption = "Live",
                ClientId = "000000004018626B",
                ClientSecret = "0JN-2FYhsi4z-NnskF3C97A63nSJbkW8"
            };
            microsoftOptions.Scope.Add("wl.basic");
            microsoftOptions.Scope.Add("wl.emails");

            app.UseMicrosoftAccountAuthentication(microsoftOptions);
        }
Esempio n. 49
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {

            DataProtectionProvider = app.GetDataProtectionProvider();

            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(() => DependencyResolver.Current.GetService<ApplicationUserManager>());

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.  
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // 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.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "000000004013A8D8",
                clientSecret: "5WdUBURuFxFwMa9v97z-qbEXzvq42Nf9");

            app.UseTwitterAuthentication(
               consumerKey: "0000000044116236",
               consumerSecret: "nLut0Tya491C9y9m0bdmAPrbbrnS41yJ");

            app.UseFacebookAuthentication(
               appId: "0000000044116236",
               appSecret: "nLut0Tya491C9y9m0bdmAPrbbrnS41yJ");

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId = "654419548573-ik27lh6k0ml1r9urk6g83d9aqk3un8kl.apps.googleusercontent.com",
                ClientSecret = "GLGWXVGCiilth7kncoIMaAP0"
            });
        }
Esempio n. 50
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable CORS
            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);

            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure the application for OAuth based flow
            PublicClientId = "self";
            OAuthOptions = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath = new PathString("/Token"),
                Provider = new ApplicationOAuthProvider(PublicClientId),
                AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                AllowInsecureHttp = true
            };

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers

            app.UseMicrosoftAccountAuthentication(
                clientId: ConfigurationManager.AppSettings["MicrosoftClientId"],
                clientSecret: ConfigurationManager.AppSettings["MicrosoftClientSecret"]);

            app.UseTwitterAuthentication(new TwitterAuthenticationOptions
                    {
                        ConsumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"],
                        ConsumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"],
                        CallbackPath = new PathString("/signin-twitter")
                    });

            //app.UseFacebookAuthentication(
            //    appId: "",
            //    appSecret: "");

            //app.UseGoogleAuthentication();

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId = ConfigurationManager.AppSettings["GoogleClientID"],
                ClientSecret = ConfigurationManager.AppSettings["GoogleClientSecret"]
            });
        }
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Allow all CORS requests
            app.UseCors(CorsOptions.AllowAll);

            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(RestContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure the application for OAuth based flow
            PublicClientId = "self";
            OAuthOptions = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath = new PathString("/Token"),
                Provider = new ApplicationOAuthProvider(PublicClientId),
                AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                // In production mode set AllowInsecureHttp = false
                AllowInsecureHttp = true
            };

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers
            var microsoftAuthentication = new MicrosoftAccountAuthenticationOptions();
            microsoftAuthentication.ClientId = "000000004C16836C";
            microsoftAuthentication.ClientSecret = "R2GPxr8k-dIftBnAEhLRXLjuTsiIxNpl";
            app.UseMicrosoftAccountAuthentication(microsoftAuthentication);

            var twitterAuthentication = new TwitterAuthenticationOptions();
            twitterAuthentication.ConsumerKey = "wOS8t5pPraOLwTH79OlgyttW6";
            twitterAuthentication.ConsumerSecret = "gj9iMcmsixA8UvcsTRqxxoCkzkrpDKc4vuzKGpFjTRiNv3aldl";
            app.UseTwitterAuthentication(twitterAuthentication);

            var facebookAuthenticationOptions = new FacebookAuthenticationOptions();
            facebookAuthenticationOptions.AppId = "1645027742443677";
            facebookAuthenticationOptions.AppSecret = "baf2eea96164855d5e0d436c6e4c9365";
            app.UseFacebookAuthentication(facebookAuthenticationOptions);

            var googleAuthenticationOptions = new GoogleOAuth2AuthenticationOptions();
            googleAuthenticationOptions.ClientId = "867920998848-h8vsdddu2o8dkv72243d8phu599dejgt.apps.googleusercontent.com";
            googleAuthenticationOptions.ClientSecret = "k25jN1BX4bBtWxlNbaBMeIIk";
            googleAuthenticationOptions.CallbackPath = new PathString("/signin-google");
            googleAuthenticationOptions.Provider = new GoogleOAuth2AuthenticationProvider();
            googleAuthenticationOptions.Scope.Add("email");
            app.UseGoogleAuthentication(googleAuthenticationOptions);
        }
Esempio n. 52
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // 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.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "b1f89752-eb18-42f8-8187-7fb74b05e2fc",
                clientSecret: "ESv93WB+MErPIznlzZ/AikG0rn4R6DGCRWA9RGqNz7o=");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId = "650809303331-2d9cd4lekf9hgppai1hdrpe5o9o53bof.apps.googleusercontent.com",
                ClientSecret = "wBaZiloDcgRDm9ODGwxGHMV5"
            });
        }
Esempio n. 53
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(Context.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/AdminPanel/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // 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.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "000000004815E13C",
                clientSecret: "h2jG9dG7qusT7dPqjHCZ0PNKrm7dD73x");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            app.UseFacebookAuthentication(
               appId: "1667067060190436",
               appSecret: "73ecf0ce5b089f1867fd091b062946d5");

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId = "329545325360-lqal1v9hjpe2innh5bqlokr2761h7ggb.apps.googleusercontent.com",
                ClientSecret = "5SEH8PWPQ0fO1RN6AMYHoQNm"
            });
        }
Esempio n. 54
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // 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.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: WebConfigurationManager.AppSettings["MyMicrosoftAppId"],
                clientSecret: WebConfigurationManager.AppSettings["MyMicrosoftAppSecret"]);

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});
        }
Esempio n. 55
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure the application for OAuth based flow
            PublicClientId = "self";
            OAuthOptions = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath = new PathString("/Token"),
                Provider = new ApplicationOAuthProvider(PublicClientId),
                AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                // In production mode set AllowInsecureHttp = false
                AllowInsecureHttp = true
            };

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Sign in with Microsoft ID
            var msOptions = new MicrosoftAccountAuthenticationOptions
            {
                ClientId = WebConfigurationManager.AppSettings["MicrosoftIDClientID"],
                ClientSecret = WebConfigurationManager.AppSettings["MicrosoftIDClientSecret"]
            };
            msOptions.Scope.Clear();
            msOptions.Scope.Add("wl.signin");
            app.UseMicrosoftAccountAuthentication(msOptions);

            //app.UseTwitterAuthentication(
            //    consumerKey: "",
            //    consumerSecret: "");

            //app.UseFacebookAuthentication(
            //    appId: "",
            //    appSecret: "");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});
        }
Esempio n. 56
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(IdentityDb.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity =
                        SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                            TimeSpan.FromMinutes(30), (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // 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.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                "000000004815C014",
                "qYWEvTzEuv8-ovV2yphYkaBPiuOUemxT");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            app.UseFacebookAuthentication("1603197636622128", "a833175eff940deef89b4af038bb901f");

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions
            {
                ClientId = "534031097691-ql1ma2va1tigeu8nbh819c4nr4c9uiqd.apps.googleusercontent.com",
                ClientSecret = "G5-RvwRQFAa6_DDkuNng2hzN"
            });
        }
Esempio n. 57
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party sign in provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/SignIn"),
                ExpireTimeSpan = TimeSpan.FromMinutes(30),
                SlidingExpiration = true
            });

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            //app.UseGoogleAuthentication();

            var gitHubAuthOpt = JsonConvert.DeserializeObject<GitHubAuthenticationOptions>(AppSettings.Key.GitHub);
            if (gitHubAuthOpt.ClientId.Contains("*") == false)
            {
                app.UseGitHubAuthentication(gitHubAuthOpt);
            }
            
            var msAuthOpt = JsonConvert.DeserializeObject<MicrosoftAccountAuthenticationOptions>(AppSettings.Key.Microsoft);
            if (msAuthOpt.ClientId.Contains("*") == false)
            {
                app.UseMicrosoftAccountAuthentication(msAuthOpt);
            }

            #region Uncomment the following lines to enable logging in with third party sign in providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});
            #endregion
        }
Esempio n. 58
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            app.UseCors(CorsOptions.AllowAll);
            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(EntityModel.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

            // Configure the application for OAuth based flow
            PublicClientId = "self";
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
            OAuthOptions = new OAuthAuthorizationServerOptions
                           {
                               TokenEndpointPath = new PathString("/API/Token"),
                               Provider = new ApplicationOAuthProvider(PublicClientId),
                               AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
                               AccessTokenExpireTimeSpan = TimeSpan.FromDays(30),
                               AllowInsecureHttp = true
                           };

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);
            app.SetDefaultSignInAsAuthenticationType(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            var microsoftOptions = new MicrosoftAccountAuthenticationOptions
                                   {
                                       ClientId = "000000004012ABA5",
                                       ClientSecret = "9KHkk7OfuYwr06NpsaBKEZxD0wfQZgE2"
                                   };
            microsoftOptions.Scope.Add("wl.emails");
            var facebookOptions = new FacebookAuthenticationOptions
            {
                AppId = "775625759162004",
                AppSecret = "d411869c0707a273d6530a6a9cc592f7"
            };
            facebookOptions.Scope.Add("email");

            var googleOptions = new GoogleOAuth2AuthenticationOptions()
                                {
                                    ClientId =
                                        "469646760415-qfrnioi99r3bmcfpsi7997m1h6qgj0b3.apps.googleusercontent.com",
                                    ClientSecret = "9YdAukql7ZKrm6RUI4hfXA7S"
                                };

            app.UseFacebookAuthentication(facebookOptions);
            app.UseMicrosoftAccountAuthentication(microsoftOptions);
            app.UseGoogleAuthentication(googleOptions);
        }
Esempio n. 59
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864

        #region methods

        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext<MyUserManager>(MyUserManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(
                new CookieAuthenticationOptions
                {
                    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                    LoginPath = new PathString("/Account/Login"),
                    Provider = new CookieAuthenticationProvider
                    {
                        OnValidateIdentity =
                            SecurityStampValidator.OnValidateIdentity<MyUserManager, MyUser, long>(
                                TimeSpan.FromMinutes(30),
                                (manager, user) => user.GenerateUserIdentityAsync(manager),
                                identity => long.Parse(identity.GetUserId()))
                    }
                });

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "",
                clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});
        }
Esempio n. 60
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/LogOn")
            });

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            var googleClientId = string.Empty;
            var googleSecret = string.Empty;
            var microsoftClientId = string.Empty;
            var microsoftSecret = string.Empty;

            googleClientId = System.Configuration.ConfigurationManager.AppSettings["GoogleOAuthClientId"];
            googleSecret = System.Configuration.ConfigurationManager.AppSettings["GoogleOAuthClientSecret"];
            microsoftClientId = System.Configuration.ConfigurationManager.AppSettings["MicrosoftOAuthClientId"];
            microsoftSecret = System.Configuration.ConfigurationManager.AppSettings["MicrosoftOAuthClientSecret"];

            // https://console.developers.google.com/apis
            if(!String.IsNullOrEmpty(googleClientId) & !String.IsNullOrEmpty(googleSecret))
            {
                app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
                {
                    ClientId = googleClientId,
                    ClientSecret = googleSecret
                });
            }

            // https://apps.dev.microsoft.com
            if (!String.IsNullOrEmpty(microsoftClientId) & !String.IsNullOrEmpty(microsoftSecret))
            {
                app.UseMicrosoftAccountAuthentication(new MicrosoftAccountAuthenticationOptions()
                {
                    ClientId = microsoftClientId,
                    ClientSecret = microsoftSecret,
                    Scope = { "wl.basic", "wl.emails" }
                });
            }

            AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;
        }