403 Forbidden when using client managed authentication on Azure App Service
Asked Answered
K

0

0

I've been working on a multi-app project for a few months now using Azure App Service for my database and ADD B2C for authentication. There are three applications in this project: an admin WPF app, a client web app, and an employee WPF app. All three applications use client managed authentication with my B2C tenant by getting a token from B2C and using that token to login to the App Service database. Everything has been working fine until seemingly overnight I am no longer able to authenticate with the app service. I have no problem displaying the B2C login screen and getting an access token as a result of the authentication, but when I package the token in a JObject and call the 'mobileServiceClient.LoginAsync()' function, all I get back is a 403 "forbidden" error.

First I tried seeing if all three projects were affected, which they are. I then tried rolling back to my last commit. Still the same thing. I then tried re-cloning to see if there was any little quirk with still the same results. Because I know my Azure resources have not hit their limits, I then tried making a completely separate WPF project and I made a table on the app service that allows anonymous access. After setting "Action to take when request is not authenticated" to "Allow anonymous access" on the app service, I was able to read and write to the anonymous table without issue. I then tried to have this new project authenticate the same way the others have been only to get the same 403 error. After checking all of this I can say I'm almost completely sure that there is no issue with the client applications and the issue has to be on the server side.

The most confusing part for me is that aside from adding a new table to the database, I haven't changed a single thing server side. I've checked out both the B2C tenant and the authentication settings on the app service but nothing seems to be different than before I was experiencing this problem. Investigating a little bit more in the app service, I tried to find some JS code that handles authentication to see if I could find any useful information using the console output. I did not find any code, but I did find out the console outputs PID[31680] Information Sending response: 403.76 Forbidden whenever a client tries to authenticate.

Additional information that might help is that my request header timestamp is correct. I know from research that Azure only allows a 15 minute variance for incoming requests from its time.

Any help or suggestions for solving this issue would be greatly appreciated! Thanks!

Kumar answered 24/6, 2019 at 20:18 Comment(7)
Is your client_id + client_secret still valid ? I mean did it expired ?Amalgamate
I believe so? It's still the same client_id on B2C and for the WPF applications I don't even use the client_secret.Kumar
@Joshua see this thread: #56743996Foam
Thanks for linking that. I'm going to try it now. Looks like there are many others with the problem tooKumar
@Zachafer You are my hero. That seems to be the fix! If you will turn your comment into a answer I will gladly accept it.Kumar
Possible duplicate of Receiving 403 error when accessing Azure function app locked down by Azure AD B2CFoam
@Zachafer You can add the comment to the answer.Tolle

© 2022 - 2024 — McMap. All rights reserved.