AngularJS - IdentityServer4.Quickstart.UI - 'AuthenticationProperties' 是一个不明确的引用
AngularJS - IdentityServer4.Quickstart.UI - 'AuthenticationProperties' is an ambiguous reference
我正在实施一个 AngularJS 应用程序,它将使用 IdentityServer4 进行授权。
我在 .Net Core 2.0 应用程序中有一个独立的 Angular 应用程序,它调用 .net Core 应用程序中的 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)
Error CS0104 'AuthenticationProperties' is an ambiguous reference between 'Microsoft.AspNetCore.Authentication.AuthenticationProperties' and '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'))
你可能想看看与 2.0.0-rc1-update1 相关的快速入门,它可以在开发分支上找到:
https://github.com/IdentityServer/IdentityServer4/tree/dev/docs/quickstarts
因为它们也已更新。
我正在实施一个 AngularJS 应用程序,它将使用 IdentityServer4 进行授权。
我在 .Net Core 2.0 应用程序中有一个独立的 Angular 应用程序,它调用 .net Core 应用程序中的 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)
Error CS0104 'AuthenticationProperties' is an ambiguous reference between 'Microsoft.AspNetCore.Authentication.AuthenticationProperties' and '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'))
你可能想看看与 2.0.0-rc1-update1 相关的快速入门,它可以在开发分支上找到: https://github.com/IdentityServer/IdentityServer4/tree/dev/docs/quickstarts 因为它们也已更新。