Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure AD login - how to allow user to change Azure account if cached account is wrong for my application

Tags:

Basic scenario: Azure AD is used as just an authentication provider a web app, the identity retrieved from azure is matched by email to a local identity and a forms auth cookie is issued for api authorization against the app's webapi.

Problem: If a user has multiple azure accounts, they may be pre-authenticated when they come to my app. In this case, when the redirect back to my app occurs there may be no matching user and login cannot complete.

Desired Solution: If the cached azure account is invalid for my app, I would like to direct the user back to the microsoft login page with a chance to manually type in their credentials

How do I achieve this, and is there something wrong with this flow? It seems currently the only way for the user to get into my app is to go to azure and log out of the bad account. What other methods could achieve a better user experience? Should I use the auth token from azure and log the user out programatically and then back to azure for another go around? Can I hint for azure to prompt the user even if they are logged in already?

like image 227
Josh Avatar asked Jul 02 '19 00:07

Josh


People also ask

How do I change from a local user profile to using an Azure AD connected profile?

Join the computer to Azure AD using the following steps: Settings > Access Work or School > Click Connect > Select “Join this device to Azure Active Directory” > Enter the user's email and password > Select sign in > Click Join > Sign out of the local admin account > Sign in with the AAD account using email/password.

How do I enable application proxy in Azure?

Sign in as an administrator in the Azure classic portal. Go to Active Directory and select the directory in which you want to enable Application Proxy. Select Configure from the directory page, and scroll down to Application Proxy. Toggle Enable Application Proxy Services for this Directory to Enabled.

How does Azure AD application proxy work?

After a successful sign-in, Azure AD sends a token to the user's client device. The client sends the token to the Application Proxy service, which retrieves the user principal name (UPN) and security principal name (SPN) from the token. Application Proxy then sends the request to the Application Proxy connector.


1 Answers

I discovered that I really wanted the prompt=select_account flag on the redirect to azure, but the library I was using made it difficult to determine how to set this. I am using the ms-adal-angular6 library, which is a wrapper for azure-activedirectory-library-for-js.

After digging through the code I found a config property that was not documented called extraQueryParameter which when I set to "prompt=select_account" got the behavior close enough to what is needed.

Ultimately the user must select their account every time, instead of just when the account is wrong. I could most likely get tricky with the error response and redirect back a second time with prompt=select_account to get the behavior I was looking for, although the library doesn't make it easy to change this on the fly either so I may stick with it always on.

like image 58
Josh Avatar answered Sep 30 '22 19:09

Josh