Skip to content
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

AAD Auth Provider stuck in sign in loop #38

Closed
DavidLee-Arinco opened this issue Aug 3, 2023 · 10 comments
Closed

AAD Auth Provider stuck in sign in loop #38

DavidLee-Arinco opened this issue Aug 3, 2023 · 10 comments

Comments

@DavidLee-Arinco
Copy link

Describe the issue

Infra and code successfully deployed, but when using the AAD Auth Provider, it appears to get stuck in sign in loop.
Have confirmed that the AAD App Registration is successfully issuing an auth token, and what looks like to be session tokens back to next-auth but upon hitting the /chat endpoint it gets sent back to login screen

Screenshots 📷

image

image

@thivy
Copy link
Contributor

thivy commented Aug 4, 2023

@DavidLee-Arinco Could you please check the .env.local file and remove the comment next to the NEXTAUTH_URL

It's seems to be causing the error. I will update the documentation to remove those comments

image

@mroyster
Copy link

mroyster commented Aug 4, 2023

I had the same and fixed by adding environment variable (in Web App Config) to set NEXTAUTH_URL to point to URL. For some reason mine was missing the https at the start.

@Nettitude-MS
Copy link

Sorry, I cannot see how you have managed to fix the issue with just adding HTTPS into the App Setting for the NEXTAUTH_URL variable.

I've added this, as I am suffering with the same issue, and all I receive when browsing back to the site is a error such as the below:

image

If I remove the 'HTTPS://' from the variable, I get the login screen once again but the loop still occurs.

I've checked my redirect URI and I am confident that the login attempts are completing as I can see the application successfully authenticating into my tenancy via my UPN so I think this must be a configuration setting somewhere.

@stalejohnsen
Copy link

I get the exact same issue as @Nettitude-MS

@oliverlabs
Copy link
Contributor

oliverlabs commented Aug 4, 2023

@Nettitude-MS , your error is due to a COSMOS DB variable not being set properly.

as for the OPs issue, @mroyster provided the right answer - the NEXTAUTH_URL must contain https://.

@PedroGuerraPT
Copy link

PedroGuerraPT commented Aug 4, 2023

@Nettitude-MS , your error is due to a COSMOS DB variable not being set properly.

as for the OPs issue, @mroyster provided the right answer - the NEXTAUTH_URL must contain https://.

Thanks for pointing into the right direction @oliverlabs.

The One Click Azure Deployment actually creates the App Settings AZURE_COSMOSEDB_KEY and AZURE_COSMOSEDB_URI (notice the extra E letter), and the code appears to refer the env vars AZURE_COSMOSDB_KEY and AZURE_COSMOSDB_URI as seen here: https://github.com/microsoft/azurechatgpt/blob/6c76fb9b3239ddd751905755267115f5e9e5b0dd/src/features/common/cosmos.ts#L8C32-L8C50

Might be worth revising the ARM Template and the env var reference here as well:

https://github.com/microsoft/azurechatgpt/blob/6c76fb9b3239ddd751905755267115f5e9e5b0dd/README.md?plain=1#L240
https://github.com/microsoft/azurechatgpt/blob/6c76fb9b3239ddd751905755267115f5e9e5b0dd/README.md?plain=1#L239

@thivy
Copy link
Contributor

thivy commented Aug 5, 2023

Please updated the Azure App service application settings that matches the env.local

There were few typos and it's fixed

@aawaheed
Copy link

aawaheed commented Aug 7, 2023

image
I am also facing the same issue of Login loop when running on Azure. With local settings, it works fine using the same ADFS application.

image

@aawaheed
Copy link

aawaheed commented Aug 7, 2023

image I am also facing the same issue of Login loop when running on Azure. With local settings, it works fine using the same ADFS application.

image

I fixed the above issue by adding https:// as mentioned here #62 (comment)

@thivy
Copy link
Contributor

thivy commented Aug 7, 2023

Hi All,

There were few issues due to typos in the env.local file. We've fixed and merged to main branch.

Could you please check?

  1. All your local env.local names matches env.example
  2. All your app settings matches env.example
  3. As mentioned above Ensure the NEXTAUTH_URL has https:// at the start. We've also updated the ARM and Bicep template to fix this.

@thivy thivy closed this as completed Aug 7, 2023
QDAP-Fred referenced this issue in QDAP-DATAAI/qchat Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants