我已经构建了IdentityServer4的实现,利用Implicit Flow集成了运行ASP.NET Core的ASP Identity。(我们稍后将更改为 PKCE 配置,但无论如何。)该应用程序管理跨多个运行ASP.NET/AngularJS/OIDC-Client的 Web 应用程序的用户登录。在IIS Express上本地运行所有内容时,一切都按预期工作。我可以登录,注销,默默刷新,生活美好。但是,在部署到Azure之后,我陷入了无限重定向循环,试图登录,我束手无策。
第一次调用受保护的 Web 资源会将我重定向回登录服务。没关系。登录后,我按预期被发送到网络资源 - 但是,这里是重定向循环开始的地方。
从Application Insights上的IdentityServer日志中,我读到如下消息;
Client list checked and origin: "https://webapp.net" is allowed.CorsPolicyService allowed origin: "https://webapp.net"Client configuration validation for client "webclient" succeeded.Token validation success
我可以看到声明类型和用户信息包含预期值,并且GET requestto"https://loginservice.net/-well-known/openid-configuration"返回 OK(具有预期的配置)。我还验证了access和id 令牌是否有效,再次包含预期的数据。
但是,POST requestto"https://loginservice.net/connect/accesstokenvalidation"仍然失败,出现 404。
我的 Web 应用程序上的OIDC-Client配置如下:
vm.userManager = new Oidc.UserManager({
authority: authorityUrl,
redirect_uri: windowLocation + '/callback.html',
silent_redirect_uri: windowLocation + '/silent.html',
post_logout_redirect_uri: windowLocation + '/index.html',
client_id: 'appsimplicit',
scope: 'openid profile role appsmanagement',
response_type: 'id_token token',
revokeAccessTokenOnSignout: true,
automaticSilentRenew: true,
filterProtocolClaims: true,
checkSessionInterval: 2000
});
我的callback.html看起来像这样:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<script src="/js/oidc-client.min.js"></script>
<script>
new Oidc.UserManager().signinRedirectCallback().then(function(user) {
window.location = window.location.protocol + "//" + window.location.host + "/";
}).catch(function(err) {
console.log(err.message);
});
</script>
</body>
</html>
我能做些什么来解决这个问题?相同的行为在不同的浏览器中持续存在;Firefox、Chrome、Edge .. 我不知道为什么它在本地工作但没有部署到 Azure。