identityserver4 - 创建重定向到身份服务器登录页面的登录按钮
问题描述
我有一个 mvc 应用程序,它是客户端应用程序;然后我有一个身份服务器。
这是身份服务器的配置:
public static void AddIdentityServerContext(this IServiceCollection services, string connectionString)
{
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true; //Add this line
services.AddIdentityServer(options =>
{
options.UserInteraction.LoginUrl = "/Signin/Identifier";
...
})
...
}
这里是客户端应用程序的配置:
public void ConfigureServices(IServiceCollection services)
{
...
.AddOpenIdConnect("oidc", options =>
{
options.Authority = "https://localhost:5001"; //IdentityServer
options.ClientId = "mvc";
options.ClientSecret = "secret";
options.ResponseType = "code";
options.SaveTokens = true; //SaveTokens is used to persist the tokens from IdentityServer in the cookie
options.Scope.Add("api1");
options.Scope.Add("offline_access");
options.Scope.Add("email");
});
}
现在在我的 MVC 客户端应用程序中,我想在身份服务器上的登录页面上创建一个登录按钮重定向,但我想避免在我的 cshtml 页面上以这种方式插入链接:
<a href= "https://localhost:5001/Signin/Identifier">Login</a>
我看到这个页面: https ://docs.identityserver.io/en/latest/quickstarts/4_javascript_client.html
我看到存在一些用于在基于 javascript 的应用程序上支持 oidc 协议的js 。我想服务器端也可能存在某些东西。
请问有什么帮助吗?
谢谢
解决方案
推荐阅读
- python - 查找 Python 递归引用
- python - 从 python 和 adb 中找到 android 元素
- api - 从 LastFm 下载完整的数据导出以用于推荐系统
- java - 项目构建错误:Non-resolvable parent POM: Failure to transfer org.springframework.boot:spring-boot-starter-parent:
- javascript - d3.js - 强制模拟拖动不随鼠标移动
- bash - 在 Jenkins 中使用 Jenkinsfile 运行一组 linux 命令
- hdl - 凿子中的 typedef
- javascript - Socket.IO与服务器多次连接
- javascript - 节点 csv-parser 返回变量
- python - 如何在 sqlalchemy 中将默认值设置为自定义类型?