-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is Azure App Service ARR Affinity Required to be Enabled? #1160
Comments
@krispenner transferred this issue to Microsoft.Identity.web. |
Hi @jmprieur thanks for transferring the issue to the appropriate team. Your suggested answer however is not related to my issue of session affinity. It relates to proxies and I already have that part working on my Linux containers. |
@krispenner I though this was related to load balancers? You could ask the ASP.NET Core team? I don't think that this is related to Microsoft.Identity.Web. @navyasric : do you have an idea? |
@jmprieur So after enabling verbose logging for
This causes a failure to authorize and a redirect back to Azure AD which re-authenticates the user and redirects them back to my app, this time hitting the other App Service backend instance and causing the same error above. And into a redirect loop I go. This sounds like the Data Protection keys of ASP.NET Core are not in sync across the instances which are Linux containers. Can you confirm if Although, the fact it says "Error From RemoteAuthentication" makes me think this is Azure AD throwing the error and |
I found this in MS docs regarding the state parameter in the Open ID Connect message. I also found this article which says:
This points the finger in my mind that the data protection keys are not being sync'd across my Azure backend instances automatically. |
So it seems that the ASP .NET Core data protection (DP) keys are not automatically sync'd across backend App Service instances of the same app. I'm sure this is meant to be automatic, but maybe not for Linux based App Services (containers) but only for Windows based web apps. Anyways, I have added my own encryption key to be shared across instances and it's hosted in blob storage and secured via key vault. By ensuring the DP key is shared across all instances of the Linux App Service the Open ID Connect message @jmprieur I'd suggest you make note of this in your documentation for anyone trying to use services.AddDataProtection()
.SetApplicationName("MyApp")
.SetDefaultKeyLifetime(TimeSpan.FromDays(30))
.PersistKeysToAzureBlobStorage(new Uri("https://mystore.blob.core.windows.net/keyrings/master.xml"), new DefaultAzureCredential())
.ProtectKeysWithAzureKeyVault(new Uri("https://myvault.vault.azure.net/keys/MasterEncryptionKey"), new DefaultAzureCredential()); |
Thanks very much @krispenner for these detailed analysis and explanations. |
I have the same issue and we stumbled on the wiki and eventually this issue. While the fix works for us when we scale to 2 instances, anything beyond 2 results in the behavior as described by @krispenner. Any clues there? |
For my web app, the redirect from Azure AD back to the web app after successful sign-in requires that I enable ARR Affinity on the web app if it is scaled out to more than one instance, otherwise an infinite redirect loop between my web app and Azure AD ensues. I don't believe this should be a requirement so I'd like to understand what I have misconfigured. There should be no problem with a different backend instance of a web app handling the redirect back from Azure AD and accepting the JWT token.
Which Version of MSAL are you using ?
Microsoft.Identity.Client 4.30.0
Microsoft.Identity.Web 1.9.1
Microsoft.Identity.WebUI 1.9.1
Platform
netcore 3.1 on Linux Docker container in Azure App Service.
What authentication flow has the issue?
Is this a new or existing app?
This is a new app or experiment
Repro
Web App scaled out to 2 instances, disable ARR Affinity on web app
Expected behavior
App redirects to Azure AD to sign-in user, authenticated user is redirected back to web app and can now use app.
Actual behavior
Web App scaled out to 2 instances, enable ARR Affinity on web app
Expected and Actual behavior
App redirects to Azure AD to sign-in user, authenticated user is redirected back to web app and can now use app.
Web App scaled down to 1 instance, disable ARR Affinity on web app
Expected and Actual behavior
App redirects to Azure AD to sign-in user, authenticated user is redirected back to web app and can now use app.
The text was updated successfully, but these errors were encountered: