1

I have Firebase connected to my web app and users can authenticate using the 'microsoft' provider. The provider only allows authenticating with the active directory tenant that I specified in my firebase project.

I also have a SQL database that I want to let the users connect to after they're logged in on my web app. I DON'T want to use generic authentication credentials (e.g. SQL authentication - username/password) to authenticate to the database because I want to enforce database access permissions at the database level using database roles, users, and permissions rather than enforcing data access permissions through the backend API application level which we would have to custom write.

I figured since firebase is already authenticating users through the Azure AD tenant and you are able to authenticate to SQL Server using Azure AD, there's probably some way to avoid having to separate the authentication process for my web app and the authentication process for my database.

Can they be merged into one authentication process? So the whole idea is when the user authenticates into the web app, they're automatically authenticated to the database (granted they have appropriate database access permissions with their AD account).

I'm looking for general design/architecture advise about if and how this can be done. So far I've been able to authenticate users to my web app using the default scopes, but then I tried to add the "Azure SQL Database" delegated permission to my Azure AD application registration permissions and added the scope on the client side with firebase addScope(...), but when trying to login to my web app I get an invalid audience error.

My question is really two-fold:

  • If my current strategy is correct in using that additional scope, I'd just like to know that it's the correct approach so I can continue with it, and maybe some insight into the invalid audience issue if you have it.

  • Otherwise, if there are better architecture approaches to this, then that's what I'd like to know.

1
  • Paragraphs can help to increase the readabilty of a huge text by an order of magnitude. Next time when asking, be so nice and try to add some by yourself.
    – Doc Brown
    Sep 22, 2023 at 15:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.