我创建基础上,DOTNET新模板“IdentityServer4快速入门用户界面(UI资产专用)”(is4ui)的IdentityServer。
这种运作良好,与服务器呈现MVC应用程序一起,但我不能让它使用hellojs一个SPA工作。
我用的URL摆弄从Identity Server的显示来获取登录页。登录逻辑运行良好,但我认为任何一个小片缺少propertly重定向到我的客户端应用程序与访问令牌。
这是我使用初始化hellojs的代码:
const AuthorityUrl = 'http://localhost:5000';
hello.init({
'openidconnectdemo': {
oauth: {
version: '2',
auth: AuthorityUrl + '/Account/Login',
grant: AuthorityUrl + '/Grant'
},
scope_delim: ' '
}
});
hello.init({
openidconnectdemo: this.authConfig.clientId
});
这是登录代码
hello.login('openidconnectdemo', {
redirect_uri: this.authConfig.redirectUrl,
scope: `openid profile`,
response_type: 'token',
display: 'page',
});
在这段代码中的AccountController,身份服务器试图重定向到应用程序,但这种失败的RETURNURL为空:
if (Url.IsLocalUrl(model.ReturnUrl))
{
return Redirect(model.ReturnUrl);
}
else if (string.IsNullOrEmpty(model.ReturnUrl))
{
return Redirect("~/");
}
else
{
// user might have clicked on a malicious link - should be logged
throw new Exception("invalid return URL");
}
我是不是要修改身份服务器,以让他们一起工作或者是有什么遗漏的客户端部分?
感谢您的任何意见!
我可能会建议使用OIDC客户端-JS,因为它是一个全面落实OIDC的,应该更容易获得工作。
这就是说,它看起来像你的第一个问题在这里的是,身份验证URL应该在UI的授权端点,而不是指向符号 - 即它应该是/connect/authorize
而非/account/login
。