asp.net-core - 更改 IdentityServer 4 中的默认端点

标签 asp.net-core .net-core identityserver3 identityserver4

我正在研究 IdentityServer 4 (1.0.0-beta5)。

默认情况下,身份验证端点为:'/connect/token'

如何更改 IdentityServer 中的默认端点,例如:“/api/login”?

谢谢

最佳答案

在启动时设置 Identity Server 4 后 - 您可以使用此“hack”并更新端点路径:

        var builder = services.AddIdentityServer()
            .AddDeveloperSigningCredential()
            .AddInMemoryApiResources(Config.GetApiResources())
            .AddInMemoryClients(Config.GetClients());

        builder.Services
            .Where(service => service.ServiceType == typeof(Endpoint))
            .Select(item => (Endpoint)item.ImplementationInstance)
            .ToList()
            .ForEach(item => item.Path = item.Path.Value.Replace("/connect", ""));

基本上 - 一旦您调用AddIdentityServer,端点(例如TokenEndpoint)、AuthorizeEndpoint类就会在内部注册 - 当它调用AddDefaultEndPoints时em> 方法。现在,Endpoint 在收到每个请求时都会迭代以匹配请求的 Url;因此更改路径会立即生效。

Please note that in the above example - I have removed all the "/connect" values from any of the paths that were prefixed with it.

关于asp.net-core - 更改 IdentityServer 4 中的默认端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39186533/

相关文章:

.net-core - 使用appsettings.json配置Kestrel监听端口Dotnet Core 2预览2

c# - .net core依赖注入(inject)是否支持Lazy<T>

.net-core - Blazor 预览版 9/mono-wasm 内存访问越界 : max string size for DotNet. invokeMethod?

javascript - 在 angularjs 中使用 $http.post() 时出现 CORS 问题

MVC 和身份服务器中的 AJAX 调用

c# - ASP.NET Core MVC - 如何上传选定的图像

c# - MVC 6 - 参数 URL 上的 Web API 2.0 空白

c# - .NET Core 中的多个 Google 身份验证范围取决于 Controller

c# - 在 ASP.NET Core 中的每个操作之前查询数据库以获取角色授权

asp.net - UseIdentityServerBearerTokenAuthentication 不适用于 IdentityServer3