data-api-builder icon indicating copy to clipboard operation
data-api-builder copied to clipboard

[Documentation] I need some detail description on how to configure OAuth2/JWT in SWA Database connections

Open lgc019 opened this issue 1 year ago • 4 comments

What happened?

I configure AzureAD as authentication provider, and also have audience and issuer for the jwt section, but I didn't manage to make it work. does anyone could help or provide a detail document on how to set it up by using AzureAD to authenticate the data-api. thanks a lot.

Version

1.1.7

What database are you using?

Azure SQL

What hosting model are you using?

Static Web Apps (SWA)

Which API approach are you accessing DAB through?

REST

Relevant log output

{
    "error": {
        "code": "AuthorizationCheckFailed",
        "message": "Authorization Failure: Access Not Allowed.",
        "status": 403
    }
}

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

lgc019 avatar Aug 07 '24 06:08 lgc019

Hi @lgc019, When using SWA Database Connections, you must use "StaticWebApps" as the authentication provider. You can configuration Azure AD / EntraID auth by following this Static Web Apps doc: https://learn.microsoft.com/azure/static-web-apps/authentication-custom?tabs=aad%2Cinvitations

seantleonard avatar Aug 07 '24 15:08 seantleonard

@seantleonard thanks a lot for your comment. I managed to configure AzureAD with jwt on Azure Container App, it is working fine. But the same configuration is not working on SWA.

lgc019 avatar Aug 08 '24 02:08 lgc019

That is by design that when using SWA Database Connections, the only provider that is supported is StaticWebApps. That's because Static Web Apps handles authentication upstream of DAB.

seantleonard avatar Aug 08 '24 04:08 seantleonard

I've updated the title and will add an action to our backlog to improve the DAB documentation to make it clearer which providers are supported in which hosting model.

seantleonard avatar Aug 08 '24 04:08 seantleonard

@seantleonard thanks a lot for your comment. I managed to configure AzureAD with jwt on Azure Container App, it is working fine. But the same configuration is not working on SWA.

If you are interested in writing a blog article on configuring AzureAD wit JWT on Azure Container Apps, let me know, I would love to help you with it and get it promoted.

JerryNixon avatar Aug 30 '24 22:08 JerryNixon

Closing. If you are using Static Web Apps, your Auth provider must be StaticWebApps.

JerryNixon avatar Sep 06 '24 16:09 JerryNixon