Dosaic.Plugins.Authorization.Keycloak
1.0.18
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Dosaic.Plugins.Authorization.Keycloak --version 1.0.18
NuGet\Install-Package Dosaic.Plugins.Authorization.Keycloak -Version 1.0.18
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="Dosaic.Plugins.Authorization.Keycloak" Version="1.0.18" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dosaic.Plugins.Authorization.Keycloak --version 1.0.18
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Dosaic.Plugins.Authorization.Keycloak, 1.0.18"
#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.
// Install Dosaic.Plugins.Authorization.Keycloak as a Cake Addin #addin nuget:?package=Dosaic.Plugins.Authorization.Keycloak&version=1.0.18 // Install Dosaic.Plugins.Authorization.Keycloak as a Cake Tool #tool nuget:?package=Dosaic.Plugins.Authorization.Keycloak&version=1.0.18
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Dosaic.Plugins.Authorization.Keycloak
Dosaic.Plugins.Authorization.Keycloak is a plugin
that allows to use authentication polices with an keycloak server instance for authentication & authorization
.
Installation
To install the nuget package follow these steps:
dotnet add package Dosaic.Plugins.Authorization.Keycloak
or add as package reference to your .csproj
<PackageReference Include="Dosaic.Plugins.Authorization.Keycloak" Version="" />
Appsettings.yml
Configure your appsettings.yml with these properties
keycloak:
enabled: true #whenever the whole plugin should be active or not
host: host.example #keycloak host url
insecure: false i used protocol https vs http
realms:
prefix: '/realms/' # url prefix which should be used before the realm
policies: # policies which should be available within the service/application
- name: READ
roles:
- API_PERMISSIONS_READ
- name: WRITE
roles:
- API_PERMISSIONS_WRITE
PluginReadmeTemplateConfig.cs
[Configuration("keycloak")]
public class KeycloakPluginConfiguration
{
public bool Enabled { get; set; }
public string? Host { get; set; }
public bool Insecure { get; set; }
public RealmsConfig Realms { get; set; } = new RealmsConfig();
public IList<AuthPolicy> Policies { get; set; } = new List<AuthPolicy>();
}
public class RealmsConfig
{
public string Prefix { get; set; } = "/auth/realms/";
}
Usage
public class PluginReadme : IPluginEndpointsConfiguration
{
public void ConfigureEndpoints(IEndpointRouteBuilder endpointRouteBuilder, IServiceProvider serviceProvider)
{
endpointRouteBuilder
.AddSimpleRestResource<MyResourceClass>(serviceProvider, "my-resource")
.ForGet(configuration => configuration.WithPolicies("READ")) // assign individual policies for each http verb
.ForGetList(configuration => configuration.WithPolicies("READ"))
.ForDelete(configuration => configuration.WithPolicies("WRITE"))
.ForPost(configuration => configuration.WithPolicies("WRITE"))
.ForPut(configuration => configuration.WithPolicies("WRITE"))
.ForAll(configuration => configuration.WithPolicies("WRITE", "READ")); // or for all at once
endpointRouteBuilder.MapGet("/hello", async () => "Hello World!").RequireAuthorization("READ");
}
}
public class ExampleController : ControllerBase
{
[HttpGet]
[Authorize("READ")]
public IActionResult Hello() => Ok();
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- AspNetCore.HealthChecks.Uris (>= 9.0.0)
- BouncyCastle.NetCore (>= 2.2.1)
- Dosaic.Hosting.Abstractions (>= 1.0.18)
- Dosaic.Plugins.Authorization.Abstractions (>= 1.0.18)
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 9.0.1)
- Microsoft.IdentityModel.Tokens (>= 8.3.1)
- Newtonsoft.Json (>= 13.0.3)
- System.IdentityModel.Tokens.Jwt (>= 8.3.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.