Dr_Cox1911
Dr_Cox1911
CC#
Created by Dr_Cox1911 on 10/24/2023 in #help
✅ Put `[Authorize("myPolicy")]` behind feature flag
Greetings, I'm currently working on authentication and authorization for an API that is already deployed to a couple of customers. The whole auth process sits behind a feature flag using the MS IFeatureManager, so that the API can be deployed completely without auth and once more downtime is possible from customers side auth shall be activated by enabling this feature. I have pretty much all covered by the feature flag, but I don't know how I can conditionally apply the [Authorize("myPolicy")] on my api endpoints. If the feature is disabled I don't even register any auth related services or middlewares.
14 replies
CC#
Created by Dr_Cox1911 on 8/10/2023 in #help
❔ WebApplicationFactory and Minimal-APIs
I've got problems with my integration tests and minimal apis. My app has a worker services that start right up when the actual api is starting. I have a custom WebApplicationFactory that will swap out the Database with one thats started by Testcontainers. My problem though: With the top level statements and the builder that minimal apis use it looks like the app is completely started and in parallel the builder of the WebApplicationFactory runs. My worker service crashes though, as it get's started before my custom WebApplicationFactory finishes with changing out the db. I've never faced these issues in the traditional Startup era, so can I use WebApplicationFactory properly with top level statements?
3 replies