Keycloak is an open-source identity and access management solution that handles authentication, authorization, and identity brokering. This guide walks through setting up Keycloak as a Docker container, creating a realm with a public OAuth 2.0 client, configuring Swagger UI to authenticate using the Authorization Code flow with PKCE, and implementing JWT validation in ASP.NET Core. The authentication flow involves redirecting users to Keycloak for login, exchanging authorization codes for tokens, and validating JWT signatures locally using cached public keys. The setup includes observing the authentication flow with Aspire Dashboard and covers production considerations like HTTPS configuration, persistent storage with PostgreSQL, and proper security settings.

8m read timeFrom milanjovanovic.tech
Post cover image
Table of contents
Running Keycloak as a ContainerSetting Up a Realm and ClientThe Authorization Code FlowConfiguring Swagger UI with OAuth 2.0Adding JWT ValidationHow JWT Validation WorksObserving the Flow with Aspire DashboardProduction ConsiderationsSummary
1 Comment

Sort: