我在.Net Core 2.0应用程序中有一个独立的Angular应用程序,该应用程序调用.net核心应用程序中的api控制器.如果我浏览到http:// localhost:5050 / .well-kNown / openid-configuration我将返回json.
我使用this示例作为我的身份验证服务的基础:
function authService() { var config = { authority: "http://localhost:5050",client_id: "js",redirect_uri: "http://localhost:5050/LocalizationAdmin/callback.html",response_type: "id_token token",scope: "openid profile api1",post_logout_redirect_uri: "http://localhost:5050/LocalizationAdmin/index.html" }; var mgr = new Oidc.UserManager(config); mgr.getUser().then(function (user) { if (user) { log("User logged in",user.profile); } else { log("User not logged in"); } }); var service = { login: login,logout: logout,}; return service; function login() { mgr.signinRedirect(); }
在callback.html中我添加了:
<body> <script src="scripts/oidc-client.js"></script> <script> new Oidc.UserManager().signinRedirectCallback().then(function () { window.location = "index.html"; }).catch(function (e) { console.error(e); }); </script> </body>
它正试图重定向到:
http://localhost:5050/account/login?returnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Djs%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A5050%252FLocalizationAdmin%252Fcallback.html%26response_type%3Did_token%2520token%26scope%3Dopenid%2520profile%2520api1%26state%3Dd526351a26f74202badb7685022a6549%26nonce%3D6c858921378645ca8fcad973eb26cc72
但是我只是希望它重定向到IdentityServer4登录屏幕.我怎样才能做到这一点?任何帮助赞赏.
编辑:
我从这里添加了UI模板:
https://github.com/IdentityServer/IdentityServer4.Quickstart.UI
但是我收到了一些错误,可能是因为我使用的是.Net Core 2.0版本:assemblyref:// IdentityServer4(2.0.0-rc1-update1)
错误CS0104’CommonifyProperties’是’Microsoft.AspNetCore.Authentication.AuthenticationProperties’和’Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties’之间的模糊引用
解决方法
iex((New-Object System.Net.WebClient).DownloadString(‘https://raw.githubusercontent.com/IdentityServer/IdentityServer4.Quickstart.UI/dev/get.ps1’))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。