我们拥有与身份服务器4进行通信的Angular门户,它与我们自己的域兼容。我们要添加对自定义域的支持,为此我们将域名存储在数据库中,每当打开任何角度门户链接时,我们都会从数据库中获取域名并分配给authConfig,如下所示:
Object.assign(authConfig, { issuer: domainNam });
this.oauthService.configure(authConfig);
this.oauthService.tokenValidationHandler = new JwksValidationHandler();
this.oauthService.loadDiscoveryDocumentAndTryLogin().then(() => {
// .... rest of the code
});
它为发行者设置了当前的域名,但它没有重定向到登录页面,而是向我显示以下错误:
链接是这样制作的:
这是怎么回事?
如果未设置发卡行,则可以正常工作,但是当我动态设置发卡行时,就会出现此问题。
authConfig如下:
export const authConfig: AuthConfig = {
// Url of the Identity Provider
issuer: environment.identityServer.authority,
// URL of the SPA to redirect the user to after login
redirectUri: window.location.origin + "/auth-callback",
// The SPA's id. The SPA is registerd with this id at the auth-server
clientId: environment.identityServer.client_id,
// set the scope for the permissions the client should request
// The first three are defined by OIDC. The 4th is a usecase-specific one
scope: environment.identityServer.scope,
logoutUrl: environment.identityServer.authority + '/Account/Logout',
}
答案 0 :(得分:2)
以下是您可以解决的几点:
1)颁发者->授权服务器的颁发者标识符// //即使从当前环境文件中读取也不应该创建任何问题,请确保在相应的环境中设置了适当的密钥
2)redirectUri->您的重定向URL //确保在Identity Manager中配置了此回调,这可能是原因之一
3)授权标头->我相信您已经从Web服务器传递了秘密密钥,请按提示进行良好练习
现在终于,
Object.assign(authConfig, { issuer: domainNam }); // step 1
this.oauthService.configure(authConfig); // step 2
对于上述代码,如果从服务器读取域名,然后进入步骤2,请确保您在步骤awaiting上
我相信,正如您所说,仅当动态设置时,它才起作用,考虑到上述因素,您的身份验证应该可以起作用。