Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Active Directory login redirect loop

I need to allow users to login through Corp network to access an internal web application.

I've followed all the steps given in the official documentation and it works fine.

However, a strange error that I am getting while logging in is that the authentication pages goes into a redirect loop every other day.

As per now the immediate fix for me is to change the Application/Client ID for the application in my web.config file.

<add key="ClientId" value="Enter_the_Application_Id_here" />
<add key="redirectUri" value="Enter_the_Redirect_URL_here" />
<add key="Tenant" value="common" />
<add key="Authority" value="https://login.microsoftonline.com/{0}/v2.0" />

So as of now, I've got 2 different Applications created in Microsoft Identity Platform and I reuse the same App Id (switching them every time one stops working) and as soon as I change the App Id, the login starts working.

Not sure if I am missing something, but haven't found anything related to this exact problem other than a few like https://github.com/aspnet/Security/issues/219 which does not work for me. And to my understanding and suggestions over the internet if this was a Permission related issue, it should never allow login but it does.

like image 583
Cyberpks Avatar asked Mar 19 '18 07:03

Cyberpks


2 Answers

Turns out that it was an issue with configuration of the AD.

I went to my Azure App Service > Settings > Authentication/Authorization and created a new AD App, and used the App ID of this app in my web application and it is now working fine.

like image 86
Cyberpks Avatar answered Sep 21 '22 05:09

Cyberpks


It sounds strange that your corp login is in a loop. is it possible that it goes to your app but so 'fast' you don't notice it. I'm saying this because I have a web app and had a similar loop. and I found that the process was:

  1. your app wants to login,
  2. go to the corp login and do the login process,
  3. To the app with the token,
  4. Again to the corp login (still not fully sure why)
  5. Back to the app with the token and then you are logged in

But if you check your login to soon. At step 3 it won't know it is logged in yet, so it goes back to step 1. hence the loop.

If your login sequence is auto triggered on app startup it could be the same as what I got.

Greetings Glenn

like image 35
Kiwi Avatar answered Sep 18 '22 05:09

Kiwi