From 03f6f963a317b6b622a15f7a4130cacaa391d994 Mon Sep 17 00:00:00 2001 From: Oleksii Nikiforov Date: Mon, 6 May 2024 11:19:19 +0300 Subject: [PATCH] Update README.md --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 922ed2e2..f40ea7c9 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nikiforovall/keycloak-authorization-services-dotnet/blob/main/LICENSE.md) -Easy Authentication and Authorization with Keycloak in .NET and ASP.NET Core. +Easy Authentication and Authorization with Keycloak in .NET. | Package | Version | Description | | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | @@ -70,7 +70,7 @@ In this example, configuration is based on `appsettings.json`. } ``` -## Example Authorization +## Example - Add Authorization With `Keycloak.AuthServices.Authorization`, you can implement role-based authorization in your application. This package allows you to define policies based on roles. Also, you can use Keycloak as Authorization Server. It is a powerful way to organize and apply authorization polices centrally. @@ -105,6 +105,23 @@ app.MapGet("/hello", () => "[]") app.Run(); ``` +### Example - Invoke Admin API + +```csharp +var services = new ServiceCollection(); +services.AddKeycloakAdminHttpClient(new KeycloakAdminClientOptions +{ + AuthServerUrl = "http://localhost:8080/", + Realm = "master", + Resource = "admin-api", +}); + +var sp = services.BuildServiceProvider(); +var client = sp.GetRequiredService(); + +var realm = await client.GetRealmAsync("Test"); +``` + ## Build and Development `dotnet cake --target build`