身份服务器4使用多个外部身份提供者

时间:2017-02-01 22:45:34

标签: identityserver4

我想将身份服务器4与一堆不同的外部身份提供者一起使用。不只是一个。 例如:一个企业可能将ADFS用于他们的EIP,另一个企业可能会使用AZURE身份等等。在这种情况下,只有一个身份服务器实例访问不同的外部ID提供者。

这是可能的还是曾经有人试过这个。如果没有,您是否知道有这样做的服务。

1 个答案:

答案 0 :(得分:4)

当然这是可能的。您可以根据需要在Startup类中注册尽可能多的外部IdP。请务必查看Identityserver中的示例快速入门存储库。

此代码会将AzureAd和Google注册为外部IdP。 在进行此设置之前,您必须在developers.google和AzureAd中注册您的应用程序以授权您的应用程序。

    app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
    {
        ClientId = Configuration["AzureAd:clientid"],
        Authority = Configuration["AzureAd:authority"],
        ClientSecret = Configuration["AzureAd:secret"],
        PostLogoutRedirectUri = "/signed-out",
        AuthenticationScheme = "AzureAd",
        ResponseType = OpenIdConnectResponseType.CodeIdToken,
        SaveToken = true,
    });

    app.UseGoogleAuthentication(new GoogleOptions
    {
        ClientId = Configuration["Google:clientid"],
        ClientSecret = Configuration["Google:secret"],
        AuthenticationScheme = "Google",
        SaveTokens = true
    });