加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

AngularJS – IdentityServer4.Quickstart.UI – ‘Authenticati

发布时间:2020-12-17 07:02:24 所属栏目:安全 来源:网络整理
导读:我正在实现一个AngularJS应用程序,它将使用IdentityServer4进行授权. 我在.Net Core 2.0应用程序中有一个独立的Angular应用程序,该应用程序调用.net核心应用程序中的api控制器.如果我浏览到http:// localhost:5050 / .well-known / openid-configuration我
我正在实现一个AngularJS应用程序,它将使用IdentityServer4进行授权.

我在.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’之间的模糊引用

演示项目显示添加到github here的问题.

解决方法

我不知道这是多么稳定,但我只是使用指向dev分支的powershell命令,它似乎正在工作.

iex((New-Object System.Net.WebClient).DownloadString(‘https://raw.githubusercontent.com/IdentityServer/IdentityServer4.Quickstart.UI/dev/get.ps1’))

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读