当前位置: 首页>>代码示例>>C#>>正文


C# IAppBuilder.UseGitHubAuthentication方法代码示例

本文整理汇总了C#中IAppBuilder.UseGitHubAuthentication方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.UseGitHubAuthentication方法的具体用法?C# IAppBuilder.UseGitHubAuthentication怎么用?C# IAppBuilder.UseGitHubAuthentication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAppBuilder的用法示例。


在下文中一共展示了IAppBuilder.UseGitHubAuthentication方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType("ExternalCookie");
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "ExternalCookie",
                AuthenticationMode = AuthenticationMode.Passive,
                CookieName = ".AspNet.ExternalCookie",
                ExpireTimeSpan = TimeSpan.FromMinutes(5),
            });

            var options = new GitHubAuthenticationOptions
            {
                ClientId = "your cliend in",
                ClientSecret = "your client secret",
                Provider = new GitHubAuthenticationProvider
                {
                    OnAuthenticated = context =>
                    {
                        context.Identity.AddClaim(new Claim("urn:token:github", context.AccessToken));

                        return Task.FromResult(true);
                    }
                }
            };
            app.UseGitHubAuthentication(options);

            app.MapSignalR();
        }
开发者ID:zlich,项目名称:OAuthPopupAuthentication,代码行数:29,代码来源:Startup.cs

示例2: ConfigureAuth

        // Дополнительные сведения о настройке проверки подлинности см. по адресу: http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Включение использования файла cookie, в котором приложение может хранить информацию для пользователя, выполнившего вход,
            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: "",
            //    clientSecret: "");

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

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

            app.UseGitHubAuthentication(
                clientId: "",
                clientSecret: "");

            //app.UseGoogleAuthentication();
        }
开发者ID:Raisky34,项目名称:MySite,代码行数:31,代码来源:Startup.Auth.cs

示例3: ConfigureAuth

        public void ConfigureAuth(IAppBuilder app)
        {
            app.CreatePerOwinContext(WebAppContainer.Container.Resolve<UserManager<ApplicationUser>>);

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    OnValidateIdentity =
                        SecurityStampValidator.OnValidateIdentity<UserManager<ApplicationUser>, ApplicationUser>(TimeSpan.FromMinutes(30),
                            (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            app.UseOAuthBearerTokens(OAuthOptions);

            var gitHubOptions = new GitHubAuthenticationOptions
            {
                ClientId = CloudConfigurationManager.GetSetting("GitHub.ClientId"),
                ClientSecret = CloudConfigurationManager.GetSetting("GitHub.ClientSecret"),
            };

            app.UseGitHubAuthentication(gitHubOptions);
        }
开发者ID:modulexcite,项目名称:Fooidity,代码行数:28,代码来源:Startup.Auth.cs

示例4: ConfigureAuth

        // 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.UseSignInCookies();

            // 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();

            var settings = ConfigurationManager.AppSettings;

            app.UseGitHubAuthentication(
                settings["oauth.gitHub.clientId"],
                settings["oauth.gitHub.clientSecret"]);

            app.UseStackExchangeAuthentication(
                settings["oauth.stackExchange.clientId"],
                settings["oauth.stackExchange.clientSecret"],
                settings["oauth.stackExchange.key"],
                settings["oauth.stackExchange.site"]);
        }
开发者ID:kazimanzurrashid,项目名称:Community.Owin.Security,代码行数:34,代码来源:Startup.Auth.cs

示例5: ConfigureAuth

        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType("ExternalCookie");
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "ExternalCookie",
                AuthenticationMode = AuthenticationMode.Passive,
                CookieName = ".AspNet.ExternalCookie",
                ExpireTimeSpan = TimeSpan.FromMinutes(5),
            });

            var options = new GitHubAuthenticationOptions
            {
                ClientId = ConfigurationManager.AppSettings["ClientId"],
                ClientSecret = ConfigurationManager.AppSettings["ClientSecret"],
                Provider = new GitHubAuthenticationProvider
                {
                    OnAuthenticated = context =>
                    {
                        context.Identity.AddClaim(new Claim("urn:github:token", context.AccessToken));
                        context.Identity.AddClaim(new Claim("urn:github:username", context.UserName));

                        return Task.FromResult(true);
                    }
                }
            };
            options.Scope.Add("user:email");
            options.Scope.Add("repo");

            app.UseGitHubAuthentication(options);
        }
开发者ID:mikeparker,项目名称:prcreator,代码行数:32,代码来源:Startup.Auth.cs

示例6: ConfigureAuth

        // 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: "000000004417C021",
            //    clientSecret: "mpzPpPhYhWDNmuRGowFJcXoMB6tTbSWF");

            app.UseTwitterAuthentication(
               consumerKey: "PWmtzEvBdTMfJ2GJWBDA1WEny",
               consumerSecret: "p7z1mcC5wsT1mdsiRVkio93M3hRdeNjQPP8ifpfmfTh8Lko3Uw");

            app.UseFacebookAuthentication(
               appId: "1679103069041937",
               appSecret: "5fe2a7ca3317a1fe43ee538fc972c481");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "795097649471-u3lc8eva98ho7lpk6a95kvhs463ddltr.apps.googleusercontent.com",
            //    ClientSecret = "aszuOjxGqphSJ8DE13d6nu_u"
            //});

            app.UseLinkedInAuthentication("77cqvvlk8h3zrt", "OeXSfuGYk15VpDer");

            app.UseGitHubAuthentication(
                clientId: "a7764ab9ebbf06896f50",
                clientSecret: "db5bf16e5a1481c1d2eb4e3c4828de7d72d931dc");
        }
开发者ID:cdrose15,项目名称:Budgeter,代码行数:59,代码来源:Startup.Auth.cs

示例7: ConfigureAuth

        // 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);

            // Enable logging in with GitHub
            app.UseGitHubAuthentication(
                clientId: "4ac29bea3cbc9f317ada",
                clientSecret: "0c93df4a12f33c9b9450e46af1cf0612ce1878f4");

            // 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 = ""
            //});
        }
开发者ID:mpaktiti,项目名称:asp-net-oauth-github,代码行数:58,代码来源:Startup.Auth.cs

示例8: Configuration

        public void Configuration(IAppBuilder application)
        {
            application.SetDefaultSignInAsAuthenticationType(DefaultAuthenticationTypes.ApplicationCookie);
            application.UseCookieAuthentication(new CookieAuthenticationOptions()
            {
                AuthenticationMode = AuthenticationMode.Active,
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/"),
            });

            var options = new GitHubAuthenticationOptions()
            {
                AuthenticationMode = AuthenticationMode.Active,
                AuthenticationType = "GitHub",
                SignInAsAuthenticationType = application.GetDefaultSignInAsAuthenticationType(),

                ClientId = ConfigurationManager.AppSettings["clientId"],
                ClientSecret = ConfigurationManager.AppSettings["clientSecret"],

                Provider = new GitHubAuthenticationProvider
                {
                    OnAuthenticated = context =>
                    {
                        context.Identity.AddClaim(new Claim("urn:github:avatar_url", context.User["avatar_url"].ToString()));
                        context.Identity.AddClaim(new Claim("urn:github:acess_token", context.AccessToken));

                        return Task.FromResult(0);
                    }
                }
            };

            options.Scope.Clear();

            application.UseGitHubAuthentication(options);

            var builder = new ContainerBuilder();
            builder.RegisterHubs(Assembly.GetExecutingAssembly());
            var container = builder.Build();

            application.Map("/signalr", map =>
             {
                 map.UseCors(CorsOptions.AllowAll);
                 var hubConfiguration = new HubConfiguration()
                 {
                     Resolver = new AutofacDependencyResolver(container)
                 };
                 map.RunSignalR(hubConfiguration);
             }).UseNancy(new NancyOptions()
             {
                 Bootstrapper = new Bootstrapper(container)
             });
        }
开发者ID:retran,项目名称:hackathon-async-chat,代码行数:52,代码来源:Startup.cs

示例9: ConfigureAuth

        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864

        /// <summary>
        /// Configures the authentication.
        /// </summary>
        /// <param name="app">The application.</param>
        /// <exception cref="OverflowException"><paramref>
        ///         <name>value</name>
        ///     </paramref>
        ///     is less than <see cref="F:System.TimeSpan.MinValue"/> 
        /// or greater than <see cref="F:System.TimeSpan.MaxValue"/>.-or-<paramref>
        ///         <name>value</name>
        ///     </paramref>
        ///     is <see cref="F:System.Double.PositiveInfinity"/>.
        /// -or-<paramref>
        ///         <name>value</name>
        ///     </paramref>
        ///     is <see cref="F:System.Double.NegativeInfinity"/>.</exception>
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(DataContext.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
                {
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, User, int>
                        (TimeSpan.FromMinutes(30),
                        (manager, user) => user.GenerateUserIdentityAsync(manager),
                        ident => ident.GetUserId<int>()),

                    //**** This what I did ***//
                    OnException = context => 
                    {
                        Console.WriteLine(context.Exception.Message);
                        throw context.Exception;
                    }
                }
            });

            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.UseGitHubAuthentication("1bfcefabf8915347782a", "db683ecf2f28f09f65432e9cff972673d9d3a522");

            app.UseRedditAuthentication("t3xal_3BqrnFEg", "FcyBUZI88TkQe_ydgvy5fU1J3a8");

            app.UseFacebookAuthentication("1627454327496577", "1423363bfda5af73029608170b7b0e34");

            app.UseGoogleAuthentication("136994307495-35s7hbhm9jkn43mis7dnqnjl3ooapflu.apps.googleusercontent.com", "wZvoCl-d_AQ2MpzGd-3fxmCY");
        }
开发者ID:shoff,项目名称:zanshin,代码行数:69,代码来源:Startup.Auth.cs

示例10: ConfigureAuth

        // 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(SiteDbContext.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);

            // If we are in debug mode, return
            if (DebugExtensions.IsDebug()) return;

            /*
                The Following Code will not be run in Debug mode
            */

            // Setup Github
            var options = new GitHubAuthenticationOptions
            {
                ClientId = ConfigurationManager.AppSettings["GitHubClientId"],
                ClientSecret = ConfigurationManager.AppSettings["GitHubSecret"]
            };

            // Register GitHub Auth
            app.UseGitHubAuthentication(options);
        }
开发者ID:davericher,项目名称:cst8256-FinalProject,代码行数:51,代码来源:Startup.Auth.cs

示例11: ConfigureAuth

        // 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
        }
开发者ID:KatsuYuzu,项目名称:clickonce-get,代码行数:50,代码来源:Startup.Auth.cs

示例12: ConfigureAdditionalIdentityProviders2

        public static void ConfigureAdditionalIdentityProviders2(IAppBuilder app, string signInAsType)
        {
            var gitHub = new GitHubAuthenticationOptions
            {
                AuthenticationType = "GitHub",
                SignInAsAuthenticationType = signInAsType,
                ClientId = "XXXXXXXXX",
                ClientSecret = "XXXXXXXXX",
            };
            app.UseGitHubAuthentication(gitHub);

            var fb = new FacebookAuthenticationOptions
            {
                AuthenticationType = "Facebook",
                SignInAsAuthenticationType = signInAsType,
                AppId = "XXXXXXXXX",
                AppSecret = "XXXXXXXXX",
                Scope = {"email"}
            };
            app.UseFacebookAuthentication(fb);

            var google = new GoogleOAuth2AuthenticationOptions
            {
                AuthenticationType = "Google",
                SignInAsAuthenticationType = signInAsType,
                ClientId = "XXXXXXXXX",
                ClientSecret = "XXXXXXXXX",
                Scope = {"email"}
            };
            app.UseGoogleAuthentication(google);

            var cosign2 = new CosignAuthenticationOptions
            {
                AuthenticationType = "Cosign",
                SignInAsAuthenticationType = signInAsType,
                CosignServer = "weblogin.umich.edu",
                CosignServicePort = 6663,
                IdentityServerHostInstance = "core2",
            #if DEBUG
                ClientServer = "devservername"
            #else
                ClientServer = "prodservernameu"
            #endif
            };
            app.UseCosignAuthentication(cosign2);
        }
开发者ID:kvoyk,项目名称:IdSrvHost,代码行数:46,代码来源:Startup.cs

示例13: ConfigureAuthentication

        public static void ConfigureAuthentication(IAppBuilder app)
        {
            app.UseSignInCookies();

            var settings = ConfigurationManager.AppSettings;

            app.UseGitHubAuthentication(
                settings["oAuth.github.clientId"],
                settings["oAuth.github.clientSecret"]);

            app.UseTwitterAuthentication(
                settings["oAuth.twitter.consumerKey"],
                settings["oAuth.twitter.consumerSecret"]);

            app.UseFacebookAuthentication(
                settings["oAuth.facebook.appId"],
                settings["oAuth.facebook.appSecret"]);

            app.UseGoogleAuthentication();
        }
开发者ID:kazimanzurrashid,项目名称:textuml-dotnet,代码行数:20,代码来源:Startup.Authtication.cs

示例14: ConfigureAuth

        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // 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")
            });

            // MAKE SURE PROVIDERS KEYS ARE SET IN the CodePasteKeys.json FILE
            if (App.Secrets.GoogleClientId == null)
                throw new ArgumentException("External Logon Provider keys appear to be missing. Please update the values in the separate configuration file.");

            // these values are stored in CodePasteKeys.json
            // and are NOT included in repro - autocreated on first load
            if (!string.IsNullOrEmpty(App.Secrets.GoogleClientId))
            {
                app.UseGoogleAuthentication(
                    clientId: App.Secrets.GoogleClientId,
                    clientSecret: App.Secrets.GoogleClientSecret);
            }

            if (!string.IsNullOrEmpty(App.Secrets.TwitterConsumerKey))
            {
                app.UseTwitterAuthentication(
                    consumerKey: App.Secrets.TwitterConsumerKey,
                    consumerSecret: App.Secrets.TwitterConsumerSecret);
            }

            if (!string.IsNullOrEmpty(App.Secrets.GitHubClientId))
            {
                app.UseGitHubAuthentication(
                    clientId: App.Secrets.GitHubClientId,
                    clientSecret: App.Secrets.GitHubClientSecret);
            }

            AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;
        }
开发者ID:rioka,项目名称:CodePaste.NET,代码行数:41,代码来源:Startup.cs

示例15: ConfigureAuth

        // 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: "0000000040181C5C",
                clientSecret: "gmydiwWtqcot01cJ2XyZoI2KBnKTBUdm");

            app.UseTwitterAuthentication(
               consumerKey: "SK3LDbUmOap2Ar6pcmDGNKSwe",
               consumerSecret: "je1NuzQXsVTcEgBOg7EJ4n2iuYVamk9lnmo3J9ht5bGAInYEEO");

            app.UseFacebookAuthentication(
               appId: "750180768446665",
               appSecret: "38e213a04e757f301095ddaf5e1da5b8");

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId = "991404432161-h4rom7b9niup83f4n8sockesnsuekfga.apps.googleusercontent.com",
                ClientSecret = "fTiLMtI45pFs3P9AexBjcit3"
            });

            app.UseLinkedInAuthentication(
                "77tiymodj809nm",
                "z2gout8EuDo4IHHt");

            app.UseGitHubAuthentication(new GitHubAuthenticationOptions()
            {
                ClientId = "a3c17e9c4e0215cd117d",
                ClientSecret = "64d88d8c65ad4af2663289ac8abcebe760864ff0"
            });

            //app.UseYahooAuthentication(new YahooAuthenticationOptions
            //{
            //    ConsumerKey = "dj0yJmk9N1RVQXJOUko4aEtxJmQ9WVdrOU5UWXhOVkI2TXpBbWNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD1mYw--",
            //    ConsumerSecret = "9f7c7ad36277ad1d36b6237dfbdb7283af4611fa"
            //});
        }
开发者ID:justinrhammonds,项目名称:Blog,代码行数:69,代码来源:Startup.Auth.cs


注:本文中的IAppBuilder.UseGitHubAuthentication方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。