|
| 1 | +# 🔐 Keycloak Client for .NET Core |
| 2 | + |
| 3 | +🚀 A powerful and feature-rich .NET Core client library for Keycloak that simplifies integration with Keycloak's authentication and authorization services. This enterprise-ready library provides a comprehensive implementation of Keycloak's REST API, with full support for OpenID Connect, OAuth 2.0, and User-Managed Access (UMA 2.0) protocols. |
| 4 | + |
| 5 | +*** |
| 6 | + |
| 7 | +## ⚙️ Requirements |
| 8 | + |
| 9 | +| Category | Supported Versions | |
| 10 | +| ------------ | ----------------------------------------------------------------------- | |
| 11 | +| .NET | 6.0, 7.0, 8.0 | |
| 12 | +| Dependencies | ASP.NET Core, Microsoft.Extensions.DependencyInjection, Newtonsoft.Json | |
| 13 | + |
| 14 | +## ✅ Version Compatibility |
| 15 | + |
| 16 | +| Keycloak Version | Support | |
| 17 | +| ---------------- | ------- | |
| 18 | +| 26.x | ✅ | |
| 19 | +| 25.x | ✅ | |
| 20 | +| 24.x | ✅ | |
| 21 | +| 23.x | ✅ | |
| 22 | +| 22.x | ✅ | |
| 23 | +| 21.x | ✅ | |
| 24 | +| 20.x | ✅ | |
| 25 | + |
| 26 | +## 🌟 Key Features |
| 27 | + |
| 28 | +- 🔄 Complete Keycloak REST API integration |
| 29 | +- 🛡️ Robust security with OpenID Connect and OAuth 2.0 |
| 30 | +- 📊 Built-in monitoring and performance metrics |
| 31 | +- 🔍 Comprehensive error handling and debugging |
| 32 | +- 🚦 Automated token management and renewal |
| 33 | +- 👥 Advanced user and group management |
| 34 | +- 🔑 Multiple authentication flows support |
| 35 | +- 📈 Enterprise-grade scalability |
| 36 | + |
| 37 | +## 💻 Installation |
| 38 | + |
| 39 | +To integrate the Keycloak client library into your .NET Core application, simply add the NuGet package: |
| 40 | + |
| 41 | +```bash |
| 42 | +Install-Package Keycloak.NETCore.Client |
| 43 | +``` |
| 44 | + |
| 45 | +## 🚀 Getting Started |
| 46 | + |
| 47 | +### 📋 Prerequisites |
| 48 | + |
| 49 | +- ✳️ .NET Core SDK (version 6.0 or later) |
| 50 | +- 🖥️ A running Keycloak instance |
| 51 | +- 🔑 Client credentials and realm configuration |
| 52 | + |
| 53 | +### 🔧 Basic Setup |
| 54 | + |
| 55 | +1. Add the Keycloak client to your services in `Program.cs` or `Startup.cs`: |
| 56 | + |
| 57 | +```csharp |
| 58 | +services.AddKeycloakAuthentication(options => |
| 59 | +{ |
| 60 | + options.KeycloakBaseUrl = "http://localhost:8080"; |
| 61 | + options.RealmAdminCredentials = new KcClientCredentials |
| 62 | + { |
| 63 | + ClientId = "your-client-id", |
| 64 | + ClientSecret = "your-client-secret" |
| 65 | + }; |
| 66 | +}); |
| 67 | +``` |
| 68 | + |
| 69 | +## 📖 Basic Usage |
| 70 | + |
| 71 | +Here's a quick example of how to use the library: |
| 72 | + |
| 73 | +```csharp |
| 74 | +// Create Keycloak client |
| 75 | +var keycloakClient = new KeycloakClient("http://localhost:8080"); |
| 76 | + |
| 77 | +// Authenticate |
| 78 | +var token = await keycloakClient.Auth.GetClientCredentialsTokenAsync( |
| 79 | + "your-realm", |
| 80 | + new KcClientCredentials |
| 81 | + { |
| 82 | + ClientId = "your-client-id", |
| 83 | + ClientSecret = "your-client-secret" |
| 84 | + }); |
| 85 | + |
| 86 | +// Use the token for other operations |
| 87 | +var users = await keycloakClient.Users.GetAsync( |
| 88 | + "your-realm", |
| 89 | + token.AccessToken, |
| 90 | + new KcUserFilter { MaxResults = 10 }); |
| 91 | +``` |
| 92 | +## 📄 License |
| 93 | + |
| 94 | +This project is licensed under the MIT License. |
0 commit comments