Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default endpoint in IdentityServer 4

I was working around IdentityServer 4 (1.0.0-beta5).

By default, the endpoint for authentication is: '/connect/token'.

How can I change the default endpoints in IdentityServer, for instance to: '/api/login'?

Thanks

like image 261
Amir Pournasserian Avatar asked Aug 27 '16 22:08

Amir Pournasserian


People also ask

Is IdentityServer4 obsolete?

IdentityServer4 support will last until the end of life of . NET Core 3.1 that means till November 2022.

How do I get access token in IdentityServer4?

Get the client's access token back. With the help of the client Id and secret, the client authenticates with the token endpoint. Resource owner password grant type : You can use the Resource Owner Password to request tokens on behalf of a user to send the user name and password to the token endpoint.

What is a discovery endpoint?

Endpoint Discovery is the process where a specific URL (the "discovery endpoint") is accessed, which returns a directory of endpoints for using the system. Other code can interrogate that directory to find the specific URLs for accessing various resources.

Is IdentityServer paid?

Now the version of IdentityServer being included in Microsoft's popular templates requires that users earning more than $1m per year pay license fees as low as $1,500 per year.


2 Answers

Once you setup Identity Server 4 at Startup - you could use this "hack" and update the endpoint paths:

        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", ""));

Basically - Endpoint's such as TokenEndpoint, AuthorizeEndpoint classes are internally registered once you call AddIdentityServer - when it calls AddDefaultEndPoints method. Now Endpoint's are iterated upon receiving each request to match the requested Url; so changing the path would immediately take effect.

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

like image 160
Rikki Avatar answered Sep 29 '22 20:09

Rikki


Right now you cannot change the endpoint URLs of the protocol endpoints. If you think this is needed, please open an issue on github.

like image 20
leastprivilege Avatar answered Sep 29 '22 20:09

leastprivilege