I use is4aspid template for IdentityServer4. When the server receives a request connect/authorize, called AccountController.Login. Question. Where i might see all default routing? Example for logout? And can i change this? Example, when receives a "connect/authorize", called OtherControl.MyLogin?
-
If you are using IdentityServer4 that means you are using single sign on so all login and logout will be in identityserver. – Nisfan Feb 18 '19 at 08:22
-
1Possible duplicate of [Change default endpoint in IdentityServer 4](https://stackoverflow.com/questions/39186533/change-default-endpoint-in-identityserver-4) – Feb 18 '19 at 08:39
2 Answers
Where i might see all default routing?
There is a discovery endpoint that is used to retrieve metadata about your IdentityServer.
It returns information like the issuer name, key material, supported scopes etc... and you can see the endpoints (token endpoint, userinfo endpoint, etc) there.
When you run your IdentityServer application the discovery endpoint is available via /.well-known/openid-configuration relative to the base address, e.g.:
http://youridentityserver/.well-known/openid-configuration
Example for logout?
"end_session_endpoint": "http://youridentityserver/connect/endsession",
And can i change this?
You cannot change the discovery endpoint URL, it is according on the spec.
Edit
But where can I read the official documentation about this? And can I change this behavior?
Researching about the documentation I could found that you can use the UserInteraction options to reconfigure the routes (I agree that it should be better documented).
It means that you can set your own url (for LoginUrl, LogoutUrl, ConsentUrl, ErrorUrl) to redirect the user.
For example:
I developed a .Net Core application that redirects the user to a /Account/Login route according with the default identityserver4 configuration.
I want to redirect the user to Test/NewLogin route for user login. So, using the UserInteraction I can reconfigure the LoginUrl the in Startup.cs class.
Solution 1: Adding in a SetupIdentityServer options method
public void ConfigureServices(IServiceCollection services)
{
IIdentityServerBuilder builder = services.AddIdentityServer(SetupIdentityServer)
...
}
Below is the implementation of the SetupIdentityServer method:
private static void SetupIdentityServer(IdentityServer4.Configuration.IdentityServerOptions identityServerOptions)
{
identityServerOptions.UserInteraction.LoginUrl = "/Test/NewLogin";
}
Solution 2: I can achieve the same result with this code
public void ConfigureServices(IServiceCollection services)
{
IIdentityServerBuilder builder = services.AddIdentityServer(options => options.UserInteraction.LoginUrl = "/Test/NewLogin"))
...
}
Result:

- 204
- 1
- 8
-
I know about the discovery endpoint. I'm interested in endpoint mapping and controllers in a UI. Intuitively it is clear that when a connection endpint "connect/authorize" is being redirected to the Login method in Account controler. But where can I read the official documentation about this? And can I change this behavior? – Kazus Feb 20 '19 at 14:48
-
I couldn't find details about the endpoint mapping, but I did some updates about how you can change this behavior. I hope it can help you. – Renan Feb 27 '19 at 14:40
I hope you've found your answer after two years but if anyone else is still looking, the default route paths are given in IdentityServer4.Constants - source here https://github.com/IdentityServer/IdentityServer4/blob/main/src/IdentityServer4/src/Constants.cs
This class contains classes called UIConstants, EndpointNames and ProtocolRoutePaths which list the URI paths involved.
Unfortunately this still doesn't directly tell you which controller actions these paths map to but it might get you a bit closer to the truth:
public static class UIConstants
{
// the limit after which old messages are purged
public const int CookieMessageThreshold = 2;
public static class DefaultRoutePathParams
{
public const string Error = "errorId";
public const string Login = "returnUrl";
public const string Consent = "returnUrl";
public const string Logout = "logoutId";
public const string EndSessionCallback = "endSessionId";
public const string Custom = "returnUrl";
public const string UserCode = "userCode";
}
public static class DefaultRoutePaths
{
public const string Login = "/account/login";
public const string Logout = "/account/logout";
public const string Consent = "/consent";
public const string Error = "/home/error";
public const string DeviceVerification = "/device";
}
}
public static class EndpointNames
{
public const string Authorize = "Authorize";
public const string Token = "Token";
public const string DeviceAuthorization = "DeviceAuthorization";
public const string Discovery = "Discovery";
public const string Introspection = "Introspection";
public const string Revocation = "Revocation";
public const string EndSession = "Endsession";
public const string CheckSession = "Checksession";
public const string UserInfo = "Userinfo";
}
public static class ProtocolRoutePaths
{
public const string ConnectPathPrefix = "connect";
public const string Authorize = ConnectPathPrefix + "/authorize";
public const string AuthorizeCallback = Authorize + "/callback";
public const string DiscoveryConfiguration = ".well-known/openid-configuration";
public const string DiscoveryWebKeys = DiscoveryConfiguration + "/jwks";
public const string Token = ConnectPathPrefix + "/token";
public const string Revocation = ConnectPathPrefix + "/revocation";
public const string UserInfo = ConnectPathPrefix + "/userinfo";
public const string Introspection = ConnectPathPrefix + "/introspect";
public const string EndSession = ConnectPathPrefix + "/endsession";
public const string EndSessionCallback = EndSession + "/callback";
public const string CheckSession = ConnectPathPrefix + "/checksession";
public const string DeviceAuthorization = ConnectPathPrefix + "/deviceauthorization";
public const string MtlsPathPrefix = ConnectPathPrefix + "/mtls";
public const string MtlsToken = MtlsPathPrefix + "/token";
public const string MtlsRevocation = MtlsPathPrefix + "/revocation";
public const string MtlsIntrospection = MtlsPathPrefix + "/introspect";
public const string MtlsDeviceAuthorization = MtlsPathPrefix + "/deviceauthorization";
public static readonly string[] CorsPaths =
{
DiscoveryConfiguration,
DiscoveryWebKeys,
Token,
UserInfo,
Revocation
};
}

- 309
- 3
- 10