How to authorize with Azure Front Door URL using Azure AD?

Ametkhan 15 Reputation points
2023-01-16T13:51:32.9133333+00:00

Hi everyone!
I've got a static web app which is tied with an Azure Front Door. I'm trying to set up authorization via Front Door and got some problem here.
After authentication I stuck on this url https://identity.2.azurestaticapps.net/.auth/login/done with error code 401: Unauthorized. Without Front Door authorization works fine.
My hunch was that there is some kind of problem with redirect uri.

In my app registration I've added redirect uri to my Azure Front Door URL:

I haven't idea where there is could be a problem, so I will be glad for any help.

Azure Front Door
Azure Front Door
An Azure service that provides a cloud content delivery network with threat protection.
850 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,173 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sudipta Chakraborty 1,116 Reputation points
    2023-01-16T14:05:21.5166667+00:00
    0 comments No comments

  2. GitaraniSharma-MSFT 50,021 Reputation points Microsoft Employee Moderator
    2023-01-19T18:20:49.2933333+00:00

    Hello @Ametkhan ,

    I understand that you have a static web app which is tied with an Azure Front Door and when accessing the login page, after authentication you are getting stuck on this URL "https://identity.2.azurestaticapps.net/.auth/login/done" with Unauthorized error code 401.

    Looking at your statement "Without Front Door authorization works fine", I believe you have manually configured Azure Front Door for your static web app.

    We have a doc which shows how to manually configure Azure Front Door for Azure Static Web Apps as below:

    https://learn.microsoft.com/en-us/azure/static-web-apps/front-door-manual

    And it recommends disabling Front Door's caching policies from trying to cache authentication and authorization-related pages.

    Refer: https://learn.microsoft.com/en-us/azure/static-web-apps/front-door-manual#disable-cache-for-auth-workflow

    After you disable cache for auth workflow, you need to update your Static web app configuration file to:

    • Restrict traffic to your site only through Front Door.
    • Restrict traffic to your site only from your Front Door instance.
    • Define which domains can access your site.
    • Disable caching for secured routes.

    Refer: https://learn.microsoft.com/en-us/azure/static-web-apps/front-door-manual#update-static-web-app-configuration

    We also have a documentation with the Static web apps configuration information as below:

    https://learn.microsoft.com/en-us/azure/static-web-apps/configuration

    And it also mentions that if you set up manual integration with Azure Front Door, you may want to disable caching for your secured routes and disable cache for authenticated paths.

    To disable Azure Front Door caching for secured routes, add "Cache-Control": "no-store" to the route header definition.

    Request you to check your Azure Front Door and Static web app configuration and make sure all the above configurations are done at your end correctly.

    Kindly let us know if the above helps or you need further assistance on this issue.


    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.