Pao*_*o B 6 redirect angularjs openid-connect identityserver4
我正在实现一个AngularJS应用程序,它将使用IdentityServer4进行授权.
我在.Net Core 2.0应用程序中有一个独立的Angular应用程序,该应用程序调用.net核心应用程序中的api控制器.如果我浏览到http://localhost:5050/.well-known/openid-configuration我正在让json返回.
我使用此示例作为我的身份验证服务的基础:
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();
}
Run Code Online (Sandbox Code Playgroud)
在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>
Run Code Online (Sandbox Code Playgroud)
它正试图重定向到:
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
Run Code Online (Sandbox Code Playgroud)
但是我只是希望它重定向到IdentityServer4登录屏幕.我怎样才能做到这一点?任何帮助赞赏.
编辑:
我从这里添加了UI模板:
https://github.com/IdentityServer/IdentityServer4.Quickstart.UI
但是我收到了一些错误,可能是因为我使用的是.Net Core 2.0版本: assemblyref://IdentityServer4 (2.0.0-rc1-update1)
Error CS0104 'AuthenticationProperties' is an ambiguous reference between 'Microsoft.AspNetCore.Authentication.AuthenticationProperties' and 'Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties'
演示项目显示问题已添加到github 这里.
我不知道这有多稳定,但我只是使用指向 dev 分支的 powershell 命令,它似乎正在工作。
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/IdentityServer/IdentityServer4.Quickstart.UI/dev/get.ps1'))
| 归档时间: |
|
| 查看次数: |
793 次 |
| 最近记录: |