如何在Identity Server 4中使用主域进行Openid身份验证


  1. xyz.com
  2. yzx.com
  3. zxy.com

我有这些域,并且正在使用AuthO Openid连接运行身份服务器4应用程序。我的主域是xyz.com,所以如果用户使用另一个域(如yzx.com(登录,只有在AuthO成功登录后,它才会重定向到我的主域名回调路径。因为我只在所有运行的域中注册了主域的回调路径。

参见以下示例:

var primaryBrandOpenIdRedirectURL = SharedResourceConstants.HyperText + primaryBrandHostUrl + pathBase.GetPathBase(HttpContext) + sso.RedirectPath;
var openIdOptions = new OpenIdConnectOptions
{
ClientId = rijndaelEncryption.Decrypt(sso.ClientId),
ClientSecret = rijndaelEncryption.Decrypt(sso.ClientSecret),
Authority = sso.Authority,
SignInScheme = 
IdentityServer4.IdentityServerConstants.ExternalCookieAuthenticationScheme,
ForwardSignOut = sso.ForwardSignOut,
// Call back path should be unique.
CallbackPath = new PathString(sso.RedirectPath),
};
if (!organization.IsDefaultBrand)
{
openIdOptions.Events = new OpenIdConnectEvents()
{
OnRedirectToIdentityProvider = ctx =>
{
ctx.ProtocolMessage.RedirectUri = primaryBrandOpenIdRedirectURL;
return Task.FromResult(0);
}
};
}

这在两个不同的本地主机端口中运行良好,但在暂存过程中面临以下问题。

System.Exception:处理远程登录时遇到错误。

System.Exception:关联失败。

位于System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebugger Notification的Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler `1.d__12.MoveNext(System.Threading.Tasks.Task任务(,偏移量46
,位于IdentityServer4.Hosting.FederatedSignOut.AuthenticationRequestHandlerWrapper.d__6.MoveNext((处,偏移量437
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task任务(,偏移量39(System.Threading.Tasks.Task任务(,偏移量46 ``

当OpenIDConnect身份验证中间件接收到来自IdentityServer的回调时,Correlation failed问题是一个常见错误。

发出初始身份验证请求的客户端也必须是用户登录并同意后浏览器重定向回的客户端。(即必须使用相同的域(

我想每个客户端域都需要在有效的重定向URL中注册像

RedirectUris=新列表(({"https://xyz1.com/signin-oidc","https://xyz2.com/signin-oidc","https://xyz3.com/signin-oidc"};

您还应该检查并确保发送到IdentityServer的ReturnUrl是客户端的真实域,以便浏览器在完成同意部分后可以找到返回的方法。

https://localhost:6001/Account/Login?ReturnUrl=%2Fconnect%2Authorize%2Fcallback%3Client_id%3Authcodeflowclient_dev%26redirect_uri%3https%253A%252F%252Flocalhost%253A5001%252Fsignin oidc%26response_type%3Dcode%26prompt%3DConference%26scope%3Openid%2520配置文件%2520电子邮件%2520offline_。。。

相关内容

最新更新