Skip to content

MiladRv/Keycloak.Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keycloak.Net.Sdk

🧰 A powerful and modular .NET SDK for integrating with Keycloak

This SDK is designed to provide a clean, extensible, and testable interface to interact with Keycloak in .NET applications using HttpClientFactory, typed services, and native DTOs.

📦 NuGet: Keycloak.Net.Sdk


✨ Features

  • Sign up / Sign in users
  • Manage users (set password, enable/disable, delete)
  • Manage roles (realm & client)
  • Assign / remove roles to users
  • Manage realms and clients
  • Token-based authentication
  • Built-in retry policy & auth handler
  • Supports HttpClientFactory and dependency injection

Prerequisites

Before using the Keycloak.Net SDK, ensure you have the following:

  • A Keycloak server running and accessible.
  • .NET 8+ project setup.

⚙️ Installation

dotnet add package Keycloak.Net.Sdk

🔧 Configuration

1- Add this config to your appsettings.json

  "keycloak": {
    "ServerUrl": "keycloak service address",
    "RealmName": "your realm name",
    "ClientId": "your clientId",
    "ClientSecret":"your clientSecret",
    "AdminUsername": "master realm username",
    "AdminPassword": "master realm password",
    "NumberOfRetries": 3,
    "DelayBetweenRetryRequestsInSeconds": 1
  }

2- Register to DI

builder.Services.AddKeycloak(builder.Configuration);

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For more information, questions, or feedback, you can reach out to me at [email protected] or open an issue in this repository.

About

A powerful and modular .NET SDK for integrating with Keycloak

Resources

License

Stars

Watchers

Forks

Languages