keycloak-authorization-services-dotnet
AGENTS.md673 starsChanged 7 months agoMITView on GitHub
.NET library for Keycloak integration — authentication (JWT Bearer, OIDC), authorization (RBAC, resource protection, Authorization Server/RPT), Admin REST API SDK, and Protection API SDK. Published as NuGet packages under Keycloak.AuthServices.*.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,843 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository4 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- aspireSkill
- keycloak-administrationSkill
- keycloak-auth-servicesSkill
The file
We split this AGENTS.md into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 57
Configuration section: All projects bind to a "Keycloak" config section by default.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file provides guidance to AI coding agents when working with code in this repository.
Project Overview
.NET library for Keycloak integration — authentication (JWT Bearer, OIDC), authorization (RBAC, resource protection, Authorization Server/RPT), Admin REST API SDK, and Protection API SDK. Published as NuGet packages under Keycloak.AuthServices.*.
Build & Test Commands
# Build the solution
dotnet build -p:WarningLevel=0 /clp:ErrorsOnly
# Run unit tests (excludes integration tests)
dotnet cake --target=Test
# Run a single test project
dotnet test tests/Keycloak.AuthServices.Authorization.Tests
# Run a single test by name
dotnet test tests/Keycloak.AuthServices.Authorization.Tests --filter "FullyQualifiedName~TestMethodName"
# Run integration tests (requires Docker for Testcontainers)
dotnet cake --target=IntegrationTest
# Create NuGet packages
dotnet cake --target=Pack
# Full CI pipeline (clean, build, test)
dotnet cakeArchitecture
Source Projects (src/)
| Project | Purpose |
| Common | Shared config (KeycloakInstallationOptions), constants, claims utilities |
| Authentication | AddKeycloakWebApiAuthentication() (JWT Bearer) and AddKeycloakWebAppAuthentication() (OIDC+Cookies) |
| Authorization | Authorization handlers, policy providers, [ProtectedResource] attribute, Authorization Server (RPT) client |
| Sdk | Hand-written HTTP clients for Admin API (IKeycloakRealmClient, IKeycloakUserClient, etc.) and Protection API (IKeycloakProtectionClient) |
| Sdk.Kiota | Auto-generated (Kiota) typed client for Keycloak Admin REST API |
| OpenTelemetry | Metrics and tracing extensions |
| Aspire.Hosting | .NET Aspire KeycloakResource integration |
| Templates | dotnet new project templates |
Test Projects (tests/)
*.Tests— Unit tests (xUnit, FluentAssertions, MockHttp)IntegrationTests— Full Keycloak integration via Testcontainers (requires Docker)TestWebApi,TestWebApiWithControllers— Test host apps used by integration tests
Key Patterns
- Configuration section: All projects bind to a
"Keycloak"config section by default. Key properties:AuthServerUrl,Realm,Resource(client ID),Credentials:Secret. - Central package management: Versions in
src/Directory.Packages.propsandtests/Directory.Packages.props. - MinVer versioning: Version derived from git tags.
- Target framework: net10.0
- File-scoped namespaces preferred (
.editorconfig). - Nullable reference types enabled globally.
Code Style
- 4 spaces indentation, file-scoped namespaces
- Expression-bodied members preferred
- XML documentation on public APIs
KeyBot (Agentic Workflow)
- KeyBot is an automated repository assistant running as a GitHub Agentic Workflow
- PRs from KeyBot have
[KeyBot]title prefix andautomation/keybotlabels - KeyBot uses persistent repo memory on
memory/keybotbranch - To trigger on-demand: comment
/keybot <instructions>on any issue or PR - Workflow spec:
.github/workflows/keybot.md - Domain knowledge:
.github/agents/keycloak-expert.agent.md+skills/directory
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

