Skip to content

silentpartnersoftware/Keycloak.Net

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

250 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Icon

Keycloak.Net.Core

license NuGet downloads

A Fork of https://github.com/lvermeulen/Keycloak.Net with some additional patches

  • allow usage of CancellationTokens
  • changed ClientConfig to Dictionary<string, string>
  • removed signing
  • .NET 8 and .NET 10 support only
  • updated for keycloak version 26+
  • added support for changing default AdminClientId which has default admin-cli value
  • added support for System.Text.Json in replacement of NewtonsoftJson.

To use different AdminClientId, use newly introduced KeyCloakOptions:

new KeycloakClient(
  "http://keycloak.url",
  "adminUserName",
  "adminPassword",
  new KeycloakOptions(adminClientId:"admin"
  )
);

Older version support for using /auth path

When creating a new KeycloakClient, use newly introduced KeycloakOptions:

new KeycloakClient(
   "http://keycloak.url",
   "adminUserName",
   "adminPassword",
   new KeycloakOptions(prefix:"auth"
   )
);

C# client for Keycloak 26.x

See documentation at https://www.keycloak.org/docs-api/latest/rest-api/

Features

  • Attack Detection
  • Authentication Management
  • Client Attribute Certificate
  • Client Initial Access
  • Client Registration Policy
  • Client Role Mappings
  • Client Scopes
  • Clients
  • Component
  • Groups
  • Identity Providers
  • Key
  • Protocol Mappers
  • Realms Admin
  • Role Mapper
  • Roles
  • Roles (by ID)
  • Scope Mappings
  • User Storage Provider
  • Users
  • Root

Testing

The easiest way to run the tests is to use the fixture launcher:

./build/start-keycloak.sh --test --auto-cleanup

This starts Keycloak 26.7.0 in Docker, imports /test/keycloak-net-fixture-realm-export.json, runs the tests, and removes the container when the run completes.

To start the fixture server without running tests:

./build/start-keycloak.sh

The fixture realm is keycloak-net-fixture. The tests use the credentials in /test/Keycloak.Net.Core.Tests/appsettings.json; the fixture export includes the matching realm admin user.

If you prefer to run Keycloak manually, import /test/keycloak-net-fixture-realm-export.json into a Keycloak 26.7.0 instance before running the tests. The imported realm must be available at keycloak-net-fixture, and the credentials in /test/Keycloak.Net.Core.Tests/appsettings.json must match the realm admin user included in the export.

About

C# client for Keycloak version 17+

Topics

Resources

License

Stars

67 stars

Watchers

8 watching

Forks

Contributors

Languages

  • C# 98.6%
  • Shell 1.2%
  • PowerShell 0.2%