Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
K

keycloak-authorization-services-dotnet

> 安全
Open source

Authentication and Authorization with Keycloak and ASP.NET Core

673 stars0 likes0 views
WebsiteGitHub

About

Authentication and Authorization with Keycloak and ASP.NET Core

Keycloak.AuthServices

Easy Authentication and Authorization with Keycloak in .NET.

Package Version Description
Keycloak.AuthServices.Authentication Keycloak Authentication JWT + OIDC
Keycloak.AuthServices.Authorization Authorization Services. Use Keycloak as authorization server
Keycloak.AuthServices.Authorization.TokenIntrospection Token introspection for lightweight access tokens (KC 24+)
Keycloak.AuthServices.Authorization.Uma UMA 2.0 support — permission ticket challenges, RPT exchange
Keycloak.AuthServices.Sdk HTTP API integration with Keycloak
Keycloak.AuthServices.Sdk.Kiota HTTP API integration with Keycloak based on OpenAPI
Keycloak.AuthServices.OpenTelemetry OpenTelemetry support
Keycloak.AuthServices.Templates dotnet new templates

Documentation

For Developer Documentation see:

API Reference

See:

Getting Started

Install packages:

bash
dotnet add package Keycloak.AuthServices.Authentication
csharp
// Program.cs
using Keycloak.AuthServices.Authentication;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddKeycloakWebApiAuthentication(builder.Configuration);
builder.Services.AddAuthorization();

var app = builder.Build();

app.UseAuthentication();
app.UseAuthorization();

app.MapGet("/", () => "Hello World!").RequireAuthorization();

app.Run();

In this example, configuration is based on appsettings.json.

jsonc
//appsettings.json
{
    "Keycloak": {
        "realm": "Test",
        "auth-server-url": "http://localhost:8080/",
        "ssl-required": "none",
        "resource": "test-client",
        "verify-token-audience": false,
        "credentials": {
            "secret": ""
        },
        "confidential-port": 0
    }
}

Example - Add Authorization

With Keycloak.AuthServices.Authorization, you can implement role-based authorization in your application. This package allows you to define policies based on roles. Also, you can use Keycloak as Authorization Server. It is a powerful way to organize and apply authorization polices centrally.

…

Example - Invoke Admin API

csharp
var services = new ServiceCollection();
services.AddKeycloakAdminHttpClient(new KeycloakAdminClientOptions
{
    AuthServerUrl = "http://localhost:8080/",
    Realm = "master",
    Resource = "admin-api",
});

var sp = services.BuildServiceProvider();
var client = sp.GetRequiredService();

var realm = await client.GetRealmAsync("Test");

Build and Development

dotnet cake --target build

dotnet cake --target test

dotnet pack -o ./Artefacts

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#authauthenticationauthorizationauthserver

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category安全
PricingOpen source

> Related tools

O
OWASP ZAP
开源 Web 应用安全扫描器
O
owasp-wstg-tracker
Simple web app to track OWASP WSTG security testing progress
H
homebridge-mi-gateway-security
XiaoMi Gateway Security plugin for HomeBridge.