Lewee.Infrastructure.Keycloak 0.40.3

dotnet add package Lewee.Infrastructure.Keycloak --version 0.40.3
                    
NuGet\Install-Package Lewee.Infrastructure.Keycloak -Version 0.40.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lewee.Infrastructure.Keycloak" Version="0.40.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lewee.Infrastructure.Keycloak" Version="0.40.3" />
                    
Directory.Packages.props
<PackageReference Include="Lewee.Infrastructure.Keycloak" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Lewee.Infrastructure.Keycloak --version 0.40.3
                    
#r "nuget: Lewee.Infrastructure.Keycloak, 0.40.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Lewee.Infrastructure.Keycloak@0.40.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Lewee.Infrastructure.Keycloak&version=0.40.3
                    
Install as a Cake Addin
#tool nuget:?package=Lewee.Infrastructure.Keycloak&version=0.40.3
                    
Install as a Cake Tool

Lewee.Infrastructure.Keycloak

This package provides authentication infrastructure for integrating Keycloak with ASP.NET Core Blazor applications.

Features

  • Simplified Keycloak OpenID Connect authentication setup
  • Cookie-based authentication scheme
  • Customizable authentication events
  • Sign-out endpoint mapping

Usage

Adding Authentication Services

services.AddKeycloakAuthenticationForWebApp(
    keycloakServiceName: "auth-server",
    keycloakRealmName: "my-realm",
    keycloakClientId: "my-client-id",
    events: new OpenIdConnectEvents
    {
        OnTokenValidated = async context =>
        {
            // Custom logic when token is validated
        }
    },
    requireHttpsMetadata: false); // Set to true in production

Mapping Sign-Out Endpoint

app.MapKeycloakSignOut("/signout");

Configuration

The package automatically configures:

  • Cookie authentication as the default scheme
  • OpenID Connect as the challenge scheme
  • Authorization code flow with PKCE
  • Token saving
  • Claims mapping (username and roles)
  • Required scopes (openid, profile, email)

Dependencies

  • Aspire.Keycloak.Authentication: Keycloak integration for .NET Aspire
  • Microsoft.AspNetCore.Authentication.OpenIdConnect: OpenID Connect authentication
Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.40.3 49 11/22/2026