Req: Example code for VS2022 Razor app using environment variables

Having scraped just about the entire web and found countless non-working examples I could really use an example of using Keycloak to authenticate and authorize a user in a Razor app.

It would be a plus if the Keycloak arguments (ProviderURL, Client, Secrret) is provided using environment variables as I do most code in containers.

Anyone have such a thing then it would just make my day.

Cheers, Karsten

I don’t usually use Razor but I believe you can use the ASP.NET Core library that supports OIDC, such as Microsoft.AspNetCore.Authentication.OpenIdConnect. Here’s you have an example:

Alternatively, if the OIDC library presents challenges, you can delegate authentication to a proxy like NGINX with lua-resty-openidc.