1
votes

When running Identity Server 4 with a custom loginurl and going to a page on the idsrv itself, for example /grants page. My page is reirected to 'http://localhost:5000/Account/Login?ReturnUrl=%2Fgrants' and not to 'http://localhost:5005/'

I also tried to set the CookieAuthenticationOptions from asp net core authentication settings but without succes. Aldo it's also set by the idsrv itself.. still.

This is the documentation that I used http://docs.identityserver.io/en/release/topics/signin.html#login-workflow

I'm using this configuration startup:

var builder = services.AddIdentityServer(options => {
  options.UserInteraction.LoginUrl = "http://localhost:5005/";
})
.AddInMemoryIdentityResources(Config.Ids)
.AddInMemoryApiResources(Config.Apis)
.AddInMemoryClients(Config.Clients);

And this my logging output:

[15:34:09 Information] IdentityServer4.Startup
You are using the in-memory version of the persisted grant store. This will store consent decisions, authorization codes, refresh and reference tokens in memory only. If you are using any of those features in production, you want to switch to a different store implementation.

[15:34:14 Information] IdentityServer4.Startup
Using the default authentication scheme idsrv for IdentityServer

[15:34:14 Debug] IdentityServer4.Startup
Using idsrv as default ASP.NET Core scheme for authentication

[15:34:14 Debug] IdentityServer4.Startup
Using idsrv as default ASP.NET Core scheme for sign-in

[15:34:14 Debug] IdentityServer4.Startup
Using idsrv as default ASP.NET Core scheme for sign-out

[15:34:14 Debug] IdentityServer4.Startup
Using idsrv as default ASP.NET Core scheme for challenge

[15:34:14 Debug] IdentityServer4.Startup
Using idsrv as default ASP.NET Core scheme for forbid

[15:34:24 Debug] IdentityServer4.Startup
Login Url: http://localhost:5005/

[15:34:24 Debug] IdentityServer4.Startup
Login Return Url Parameter: ReturnUrl

[15:34:24 Debug] IdentityServer4.Startup
Logout Url: /Account/Logout

[15:34:24 Debug] IdentityServer4.Startup
ConsentUrl Url: /consent

[15:34:24 Debug] IdentityServer4.Startup
Consent Return Url Parameter: returnUrl

[15:34:24 Debug] IdentityServer4.Startup
Error Url: /home/error

[15:34:24 Debug] IdentityServer4.Startup
Error Id Parameter: errorId
1

1 Answers

0
votes

The LoginUrl should be local url which identity server could help redirecting user to login , you can check the source code , it would check whether that url is local url :

options.LoginPath = ExtractLocalUrl(_idsrv.UserInteraction.LoginUrl);

private static string ExtractLocalUrl(string url)
{
    if (url.IsLocalUrl())
    {
        if (url.StartsWith("~/"))
        {
            url = url.Substring(1);
        }

        return url;
    }

    return null;
}