【发布时间】:2019-06-29 04:35:27
【问题描述】:
我基于 dotnet new 模板“IdentityServer4 Quickstart UI (UI assets only)”(is4ui) 创建了一个 IdentityServer。
这与服务器渲染的 MVC 应用程序一起工作得很好,但我无法让它与使用 hellojs 的 SPA 一起工作。
我正在摆弄 url 以从 Identity Server 显示登录页面。登录逻辑运行良好,但我认为缺少任何小块以正确地使用访问令牌重定向到我的客户端应用程序。
这是我用来初始化 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 中的这段代码中,Identity Server 尝试重定向到应用程序,但由于 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");
}
我是否必须修改 Identity Server 才能让它们一起工作,还是客户端部分缺少某些东西?
感谢您的建议!
【问题讨论】:
标签: single-page-application identityserver4 openid-connect hello.js