Back to search
keycloak-authservices
MarketplaceWorks with Claude CodeGitHub
Authentication and Authorization with Keycloak and ASP.NET Core 🔐
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Checked today
Badge for your README
Markdown
[](/listings/nikiforovall--keycloak-authorization-services-dotnet)HTML
<a href="/listings/nikiforovall--keycloak-authorization-services-dotnet"><img src="/api/listings/nikiforovall--keycloak-authorization-services-dotnet/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
Install packages:
dotnet add package Keycloak.AuthServices.Authentication
// 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`.
//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
}
}What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
.claude-plugin/marketplace.json · Manifest · 17 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- {
- "name": "keycloak-authservices",
- "owner": {
- "name": "Oleksii Nikiforov"
- },
- "metadata": {
- "description": "Keycloak administration and Keycloak.AuthServices .NET library development skills"
- },
- "plugins": [
- {
- "name": "keycloak-authservices",
- "source": "./",
- "description": "Keycloak administration and Keycloak.AuthServices .NET library development skills",
- "version": "1.0.0"
- }
- ]
- }
README.md · README · 135 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- # Keycloak.AuthServices
- [](https://discord.gg/S449PhBPRQ)
- [](https://github.com/NikiforovAll/keycloak-authorization-services-dotnet/actions/workflows/build.yml)
- [](https://nuget.org/packages/Keycloak.AuthServices.Authentication)
- [](https://github.com/nikiforovall/keycloak-authorization-services-dotnet)
- [](https://conventionalcommits.org)
- [](https://github.com/nikiforovall/keycloak-authorization-services-dotnet/blob/main/LICENSE.md)
- 🔐 Easy Authentication and Authorization with Keycloak in .NET.
- | Package | Version | Description |
- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
- | `Keycloak.AuthServices.Authentication` | [](https://nuget.org/packages/Keycloak.AuthServices.Authentication) | Keycloak Authentication JWT + OIDC |
- | `Keycloak.AuthServices.Authorization` | [](https://nuget.org/packages/Keycloak.AuthServices.Authorization) | Authorization Services. Use Keycloak as authorization server |
- | `Keycloak.AuthServices.Authorization.TokenIntrospection` | [](https://nuget.org/packages/Keycloak.AuthServices.Authorization.TokenIntrospection) | Token introspection for lightweight access tokens (KC 24+) |
- | `Keycloak.AuthServices.Authorization.Uma` | [](https://nuget.org/packages/Keycloak.AuthServices.Authorization.Uma) | UMA 2.0 support — permission ticket challenges, RPT exchange |
- | `Keycloak.AuthServices.Sdk` | [](https://nuget.org/packages/Keycloak.AuthServices.Sdk) | HTTP API integration with Keycloak |
- | `Keycloak.AuthServices.Sdk.Kiota` | [](https://nuget.org/packages/Keycloak.AuthServices.Sdk.Kiota) | HTTP API integration with Keycloak based on OpenAPI |
- | `Keycloak.AuthServices.OpenTelemetry` | [](https://nuget.org/packages/Keycloak.AuthServices.OpenTelemetry) | OpenTelemetry support |
- | `Keycloak.AuthServices.Templates` | [](https://nuget.org/packages/Keycloak.AuthServices.Templates) | `dotnet new` templates |
- ## Documentation
- For Developer Documentation see: <https://nikiforovall.github.io/keycloak-authorization-services-dotnet>
- ### API Reference
- See: <https://nikiforovall.github.io/keycloak-authorization-services-dotnet-docs>
- ## 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.
- ```csharp
- var builder = WebApplication.CreateBuilder(args);
- var host = builder.Host;
- var configuration = builder.Configuration;
- var services = builder.Services;
- services.AddKeycloakWebApiAuthentication(configuration);
- services.AddAuthorization(options =>
- {
- options.AddPolicy("AdminAndUser", builder =>
- {
- builder
- .RequireRealmRoles("User") // Realm role is fetched from token
- .RequireResourceRoles("Admin"); // Resource/Client role is fetched from token
- });
- })
- .AddKeycloakAuthorization(configuration);
- var app = builder.Build();
- app.UseAuthentication();
- app.UseAuthorization();
- app.MapGet("/hello", () => "[]")
- .RequireAuthorization("AdminAndUser");
- app.Run();
- ```
- ### 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<IKeycloakRealmClient>();
- var realm = await client.GetRealmAsync("Test");
- ```
- ## Build and Development
- `dotnet cake --target build`
- `dotnet cake --target test`
- `dotnet pack -o ./Artefacts`
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.