johnny 5
johnny 5

Reputation: 21005

IdentityServer4 How does oidc know where to redirect to from configuration

I'm running the Javascript Client example of IdentityServer4, the configuration looks like this:

var config = {
    authority: "https://localhost:44350",
    client_id: "Js",
    redirect_uri: "http://localhost:5003/callback.html",
    response_type: "id_token token",
    scope:"openid profile Api1",
    post_logout_redirect_uri : "http://localhost:5003/index.html",
};

The Authority points to my instance of IdentityServer4 when I click the Login button, I am redirected to the Account/Login route in the project.

I'm looking every where yet I do not see where or how it knows to redirect to that route, where is the configuration for this?

Upvotes: 0

Views: 387

Answers (1)

Lutando
Lutando

Reputation: 5010

It knows because there is a mapping with the interaction URLs which are specified as part of the IdentityServer Options. To configure these urls to match your controllers you can do something like this in ConfigureServices:

services.AddIdentityServer(options =>
{
    options.UserInteraction = new UserInteractionOptions
    {
        //ensure that the url strings have a leading slash
        LoginUrl = "/foo/bar",<-foo/bar maps to your controller in charge of route [foo/bar]
        LogoutUrl = "/baz"
    }
}

Hope this helps.

Upvotes: 2

Related Questions