IdentityServer gets into infinite loop of authentication
Asked Answered
U

1

5

I have the following client set up in IdentityServer:

new Client
{
    ClientName = "My web application",
    Enabled = true,
    ClientId = "mywebapp",
    ClientSecrets = new List<ClientSecret>
    {
        new ClientSecret("somesecret")
    },

    Flow = Flows.Hybrid,

    ClientUri = "https://app.mydomain.com",

    RedirectUris = new List<string>
    {
        "oob://localhost/wpfclient",
        "http://localhost:2672/",
        "https://app.mydomain.com"
    }
}

And it is hosted online, let's say https://auth.mydomain.com/core.

Trying to modify the MVC OWIN Client (Hybrid) sample client to log-in to the above identity server, in Startup.cs I modified the ClientId, ClientSecret and RedirectUri to match the client settings in IdSrv. Now when I try to navigate to a page that requires authorization, I am redirected to IdentityServer's URL. When I log-in, the breakpoint hits at AuthorizationCodeReceived notification in the client's Startup.cs and then gets into a loop. The browser's status shows:

Waiting for localhost...
Waitnig for auth.mydomain.com...
Waiting for localhost...
Waitnig for auth.mydomain.com...
...

and so on and never finishes the log-in. Why is this happening? Please help.

Thanks!

Unleash answered 21/4, 2015 at 18:44 Comment(0)
S
11

Most probably this is caused by mixing http and https in redirects. Please use one scheme consistently and check the scheme on browser address-bar.

Schelling answered 22/4, 2015 at 8:59 Comment(3)
wooh, yes that was it! :)Unleash
After a long time with this issue this solved it. Since I'm using Azure I found there was a little add in I could download to force https everytimeCourtesan
Came across this post and your answer many times in the course of the last day or two trying to figure the redirect loop out. "Can't possibly be that in my case" I scoffed. It was.Responsum

© 2022 - 2024 — McMap. All rights reserved.