我正在尝试使用IdentityServer4创建一个主从属类型配置进行身份验证,如下所示
MyMasterIdentityServer0 (Master) - receives id_token and gives access_token
|---> MySlaveIdentityServer1 (Basic Auth)
|---> MySlaveIdentityServer2 (Windows Auth)
|---> MySlaveIdentityServer3 (SmartCard Certificate Auth)
|---> MySlaveIdentityServer4 (SAML SSO Auth)
|---> Cloud Demo IdentityServer
|---> Google Auth
|---> Facebook Auth
|---> Microsoft Auth
|---> Twitter Auth
我的所有应用程序和API都会指向 MyMasterIdentityServer0
并进行身份验证用户可以使用上述任何提供商进行身份验证选择。他们可以选择用户名/密码,在这种情况下,他们应该被重定向到 MySlaveIdentityServer1(基本身份验证),或者他们可以选择使用他们的AD帐户使用Windows身份验证,在这种情况下,他们将被重定向到 MySlaveIdentityServer2(Windows Auth),或选择任何其他提供商。
一旦用户通过身份验证,他就会从提供者服务器收到一个id_token,并被重定向回 MyMasterIdentityServer0 ,其中使用Provider和ProviderUserId查找外部用户,然后给予access_token根据他的权限访问applications / api。
我遇到的问题是IdentityServer主从配置对我不起作用,当用户被重定向回主设备时,我发现错误无法取消保护message.State 验证后的服务器。我试着查找问题,AuthO也遇到了他们最近修复的同样的错误。
收到错误
异常:无法取消保护message.State
IdentityServer-Master配置
// WORKING
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
AuthenticationScheme = "ID4DemoCloud",
DisplayName = "Login with ID4DemoCloud",
SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme,
SignOutScheme = IdentityServerConstants.SignoutScheme,
Authority = "https://demo.identityserver.io/",
ClientId = "implicit",
TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name",
RoleClaimType = "role"
},
//Events = new OpenIdConnectEvents() { }
});
// NOT WORKING
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
AuthenticationScheme = "MySlaveIdentityServer1BasicAuth",
DisplayName = "Login with MySlaveIdentityServer1 Basic Auth",
SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme,
SignOutScheme = IdentityServerConstants.SignoutScheme,
Authority = "http://localhost:5100/",
ClientId = "MyMasterIdentityServer0",
ClientSecret = "secret",
RequireHttpsMetadata = false,
//TokenValidationParameters = new TokenValidationParameters
//{
// NameClaimType = "name",
// RoleClaimType = "role"
//},
});
基本Auth服务器客户端配置
public static class Clients
{
public static IEnumerable<Client> GetClients()
{
return new[]
{
new Client
{
ClientId = "MyMasterIdentityServer0",
ClientName = "My Master IdentityServer 0",
ClientSecrets = new List<Secret> { new Secret("secret".Sha256()) },
AllowedGrantTypes = GrantTypes.Implicit,
AllowedScopes = new List<string>
{
StandardScopes.OpenId,
StandardScopes.Profile
},
RequireConsent = false,
AllowOfflineAccess = false,
RedirectUris = new [] { "http://localhost:5000/signin-oidc" }
}
};
}
}
除了内部部署的MySlaveIdentityServers 1,2,3和4之外,所有auth提供程序都正常工作......甚至Cloud Demo Identity服务器工作正常。任何人都可以给我任何建议或建议吗?