首页 文章

具有在Mvc应用程序中托管的社交登录的Identity Server 4

提问于
浏览
0

任何人都可以在Identity Server 4中轻松添加社交供应商身份验证,只需几分钟:

public void ConfigureServices( IServiceCollection services ) {
    services.AddMvc();
    services.AddIdentityServer()
        .AddXXX().AddYYY();
    services.AddAuthentication()
        .AddGoogle( "Google", options => {
            options.XXX = XXX;
        } )
        .AddFacebook( "Facebook", options => {
            options.XXX = XXX;
        } );
}

然后在客户端应用程序中添加一些配置(在我们的例子中是Asp.Net Core MVC)...

services.AddAuthentication( options => {
    options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
} )
.AddCookie()
.AddOpenIdConnect( OpenIdConnectDefaults.AuthenticationScheme, options => {
    options.ZZZ = ZZZ;
});

......你有"Social Login"工作 .
就是这样 - 用户尝试进入安全页面,并通过社交供应商按钮(例如Google,Facebook)重定向到IDP登录页面,并在进行身份验证时重定向回安全页面 .

我的挑战正是在这里 - 我想 host 这是 Login page in the client application ,而不是IS4 .
有可能吗?在IS4中应该配置什么?
在客户端应用程序中应该更改什么?

1 回答

  • 0

    嗯,这很难 . IDSVR4将根据社交登录生成令牌 . 如果绕过IDSVR,您将如何生成该令牌?

    你应该做的是创建链接,例如在MVC应用程序中重定向到IDSVR URL(特定于Google / facebook,例如“/ login / facebook”)的Google / Facebook,再次重定向到正确的提供程序,重定向回IDSVR并再次返回到MVC应用程序 .

    用户不会知道他们正在通过IDSVR .

相关问题