启动后启用/禁用身份验证选项

时间:2013-12-06 08:33:40

标签: c# asp.net-mvc openid asp.net-mvc-5 owin

我想创建一个自定义CMS,管理员可以在其管理面板中选择所有可能的登录选项。但我只能在我的Startup.cs中为OWIN设置第三方登录:

public partial class Startup
{
    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: "00000000000000000",
            clientSecret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

        app.UseTwitterAuthentication(
            consumerKey: "xxxxxxxxxxxxxxxxxxxxxx",
            consumerSecret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

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

        app.UseGoogleAuthentication();
    }
}

我希望从正在运行的应用中启用和禁用这些登录选项。因此在启动后。这是可能的,如果是的话,怎么样?

1 个答案:

答案 0 :(得分:0)

大多数登录流程都是由用户从列表中选择一个auth提供程序触发的。你可以只显示/隐藏该列表中的项目。