AArkhipenko.Keycloak 7.0.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package AArkhipenko.Keycloak --version 7.0.0
                    
NuGet\Install-Package AArkhipenko.Keycloak -Version 7.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AArkhipenko.Keycloak" Version="7.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AArkhipenko.Keycloak" Version="7.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AArkhipenko.Keycloak" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AArkhipenko.Keycloak --version 7.0.0
                    
#r "nuget: AArkhipenko.Keycloak, 7.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=AArkhipenko.Keycloak&version=7.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AArkhipenko.Keycloak&version=7.0.0
                    
Install as a Cake Tool

AArkhipenko.Keycloak

Nuget-проект с настройками для работы с keycloak

Методы расширения

Все методы расширения находятся здесь

Настройка для работы с Keycloak

Подключение:

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
// Добавление работы с Keycloak
builder.Services.AddKeycloakAuth(builder.Configuration);
...
var app = builder.Build();
app.UseAuthorization();
...
app.MapControllers();

app.Run();

Раздел с настройками

Для конфигурирования программы для работы с keycloak, провайдер настроек должен иметься раздел с настройками следующего вида:

...
"KeycloakSettings": {
	// сервер авторизации (обязательно)
	"Authority": "http://{keycloak_host}/realms/{realm}",
	// адрес валидации токена (обязательно)
	"MetadataAddress": "http://{keycloak_host}/realms/{realm}/.well-known/openid-configuration",
	// Признак необходимости валидации https запросов (по умолчанию false)
	"IsRequireHttpsMetadata": "false",
	// Признак необходимости проверки издателя токена (по умолчанию false)
	"IsValidateIssuer": "true",
	// Список допустимых издателей токенов
	"ValidIssuers": [
		"http://{keycloak_host}/realms/{realm}"
	],
	// Признак необходимости проверки потребителя токена (по умолчанию false)
	"IsValidateAudience": "true",
	// Перечень допустимых потребителей токена
	"ValidAudiences": [
		"{client_for_service}"
	],
	// Настройки конкретного сервиса
	"ServiceSettings": {
		// ИД клиента для сервиса
		"Service": "{client_for_service}",
		// Перечень ролей, которые могут контроллироваться в программе
		"Roles": [
			{
				// Ключ роли
				"Key": "AdminRole",
				// Значение роли
				"Value": "{admin_role_for_client}"
			},
			...
		]
	}
},
...
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
7.0.2-rc.1 73 5/9/2025
7.0.1-rc.1 83 5/4/2025
7.0.0 136 4/27/2025
0.1.1 130 4/27/2025
0.1.0 93 4/26/2025