From affolternet-web-api
Configure JWT Bearer authentication with Keycloak for affolterNET.Web.Api. Use when setting up token validation, Keycloak integration, or API authentication.
How this skill is triggered — by the user, by Claude, or both
Slash command
/affolternet-web-api:jwt-authThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Configure JWT Bearer authentication with Keycloak integration.
Configure JWT Bearer authentication with Keycloak integration.
For complete reference, see Library Guide.
{
"affolterNET": {
"Web": {
"Auth": {
"Provider": {
"Authority": "https://keycloak.example.com/realms/myrealm",
"ClientId": "my-api-client",
"ClientSecret": "your-client-secret"
}
}
}
}
}
var options = builder.Services.AddApiServices(isDev, builder.Configuration, opts => {
opts.ConfigureApi = api => {
api.AuthMode = AuthenticationMode.Authenticate;
};
});
| Mode | Description |
|---|---|
None | No authentication required |
Authenticate | Valid JWT required, no permission checks |
Authorize | Valid JWT + Keycloak RPT permissions required |
| Property | Description |
|---|---|
Authority | Keycloak realm URL |
ClientId | OIDC client identifier |
ClientSecret | OIDC client secret |
Audience | Expected JWT audience (optional) |
When using AuthenticationMode.Authorize:
[Authorize(Policy = "admin-resource")]
[HttpGet("admin")]
public IActionResult AdminOnly() { ... }
// Multiple permissions (comma-separated, any match)
[Authorize(Policy = "resource1,resource2")]
[HttpGet("multi")]
public IActionResult MultiPermission() { ... }
The API automatically enriches claims with:
ClaimTypes.Role and "roles" claimsAuthority URL is correct and accessibleClientId matches the Keycloak clientAuthMode is set to Authorizenpx claudepluginhub affolternet/affolternet.web --plugin affolternet-web-apiImplementation guide for Keycloak.AuthServices .NET library covering JWT Bearer and OIDC authentication, RBAC, resource protection, Admin REST API SDK, Protection API SDK, and developer tooling (Aspire, templates, OpenTelemetry).
Implements authentication and authorization in ASP.NET Core: JWT bearer tokens, OpenID Connect, ASP.NET Identity, policy-based authorization, roles, claims, and API key auth.
Configures JWT Bearer authentication for .NET APIs with access tokens, refresh tokens, token rotation, and user context extraction from claims.