Azure App Service secured by AAD Angular callback

sapuntp 1 Reputation point
2021-03-04T23:03:05.63+00:00

I have an Azure App Service with an Angular App as Docker container.
Everything works fine.

Now I want to add a security layer and activate the AAD authentication in the App Service configuration.
I have added the Azure identity provider and I can login and everything works without problems for the first time.

But when I try to open the app again I am being redirect to the Azure login but after that redirected to "https://mydomain.com/.auth/login/aad/callback" and nothing happens.
On the browser console I can see the following messages.

Access to fetch at 'https://login.windows.net/...' (redirected from 'https://mydomain.com/...') from origin 'https://mydomain.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I have my own authentication with JWT Tokens in my angular app and don´t want to use an integrated solution for now.
I only want to use the App Service authentication as a basic authentication but it only works the first time or if I delete my browser cache.

I am not sure what I am doing wrong. Can anyone help me?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,933 questions
Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Marilee Turscak-MSFT 37,206 Reputation points Microsoft Employee Moderator
    2021-03-09T00:16:10.283+00:00

    Hi @sapuntp ,

    Please check under the API settings > CORS > "Allowed origins" and add your Angular app hosted domain.

    75593-image.png

    See also:
    How can I enable CORS on my Azure app?
    Fix CORS error on Angular project deployed on Azure Web App
    Ways to fix the CORS error


  2. JamesTran-MSFT 36,906 Reputation points Microsoft Employee Moderator
    2021-03-09T00:28:55.233+00:00

    @sapuntp
    Thank you for your post and I apologize for the delayed response!

    When it comes to the error message that you received, I was able to find a Stack Overflow issue with the same error. It looks like one customer was using the App Service Authentication setting under Authentication/Authorization in the Azure Portal, along with their own React-ADAL npm package, which was wrapped around their application, causing conflicting issues since those two features were both using the same instance of Azure AD.

    When you mentioned that you have your own authentication, can you share a little bit more detail on that? Are you authenticating users with your own authentication and the App Service Authentication?

    If you have any other questions, please let me know.
    Thank you for your time and patience throughout this issue.


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.