Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
324 stars 56 forks source link

Azure Functions authentication doesn't work in pre-production environment #581

Open itpropro opened 3 years ago

itpropro commented 3 years ago

Describe the bug

We heavily rely on the auth endpoint in form of the .auth/me endpoint as well as the injected headers in the backend. If a PR is created and a pre-production environment deployed, the .auth/me endpoint sometimes returns a 404, and the bring-your-own-function backend always returns a 405. This renders our application technically unusable, what can we do to have the auth endpoint available in pre-production environments and to have the auth information handed over to the backend?

Additional context Backend

Frontend

The whole development process heavily relies on PRs and the ability to preview the application in a live environment before merging with GitHub checks that implement E2E tests based on the pre-production environment (that all fail currently).

EDIT: I just found the chapter in the docs, where is says that bring your own function apps are "Only supported in the Static Web Apps production environment.". Are there any plans to fix that, as pre-production environments are somewhat useless currently with bring your own functions?

mkarmark commented 2 years ago

Hi, by pre-production environments, do you mean local development or staging sites?

itpropro commented 2 years ago

Hey, I mean the staging sites, they are called pre-production in the docs that is why I used that phrase :) I think these staging sites are one of the great features that help integrating a SWA into a professional CI/CD process. Unfortunately, as many larger SWA based projects that I assisted customers with were using their own functions runtime, they couldn't benefit from the staging environments. This and the lack of full swaconfig support in staging environments (auth) are currently blocking two projects and I wanted to know if there is an indication when these limitations may be fixed.

itpropro commented 2 years ago

Hey, @mkarmark, @anthonychu, any updates on support for authentication/authorization and bring your own functions on pre-production enviroments?

PunditSharp commented 2 years ago

+1 on this. I had to switch to BYO function because I needed to generate a client-side auth token using a managed identity. But doing so means my app collaborators can't use the staging environment feature to fully test out their changes. Big Sad!

itpropro commented 2 years ago

Any updates or plans on this @mkarmark and @anthonychu?

anthonychu commented 2 years ago

We're working on this. Hope to have an update in a month.

derkoe commented 1 year ago

@anthonychu any updates on this?

As I understand it - authentication does not work with preview environments at all.

itpropro commented 1 year ago

Any updates @annikel ? Most projects I work with use the authentication layer, so preview and PR environments are basically not usable...

itpropro commented 1 year ago

@anthonychu was the functionality to use the full authentication/authorization features in every environment type released in the meantime? I could close the issue then.

hgbao commented 2 months ago

I'm facing the same issue here. Technically, if we need AAD for both StaticWebApp and Azure Functions (with Azure Functions is the backend API of StaticWebApp), there is no way we could authorize the requests (in pre-production environments)

@anthonychu do we have any update or workaround for this issue?