【发布时间】:2017-07-13 06:01:51
【问题描述】:
我正在尝试创建一个主从类型配置以使用 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 (Basic Auth),或者他们可以选择使用他们的 AD 帐户使用 Windows 身份验证,在这种情况下他们将被重定向到 MySlaveIdentityServer2 (Windows Auth),或选择任何其他提供商。
一旦用户通过身份验证,他会从提供者服务器收到一个 id_token 并被重定向回 MyMasterIdentityServer0,在该处使用 Provider 和 ProviderUserId 查找外部用户,然后将 access_token 分配给根据他的权限访问应用程序/api。
我面临的问题是 IdentityServer 主从配置对我不起作用,并且在用户被重定向回主服务器时给我一个错误无法取消保护 message.State认证后的服务器。我尝试查找问题,AuthO 也遇到了他们最近修复的相同错误。
收到错误
异常:无法取消对消息的保护。状态
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"
//},
});
基本身份验证服务器客户端配置
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 之外,所有身份验证提供程序都运行良好……甚至 Cloud Demo Identity 服务器也运行良好。谁能给我任何意见或建议?
【问题讨论】:
标签: authentication oauth-2.0 identityserver3 identityserver4 federation