Skip to content

Commit

Permalink
Merge pull request #1 from eerhardt/UpdateKeycloak
Browse files Browse the repository at this point in the history
Feedback for Keycloak PR
  • Loading branch information
julioct committed Jul 17, 2024
2 parents 4dd1056 + a6e8ba5 commit e192bf5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/Aspire.Hosting.Keycloak/Aspire.Hosting.Keycloak.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
<IsPackable>true</IsPackable>
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
<PackageTags>aspire hosting keycloak</PackageTags>
<Description>Keycloak support for .NET Aspire.</Description>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
<IsPackable>true</IsPackable>
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
<PackageTags>$(ComponentCommonPackageTags) Keycloak</PackageTags>
<Description>Configures Keycloak as the authentication provider for ASP.NET Core applications.</Description>
<!-- Disable package validation as this package hasn't shipped yet. -->
Expand All @@ -13,10 +14,6 @@
<MinCodeCoverage>80</MinCodeCoverage>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Common\ConfigurationSchemaAttributes.cs" Link="ConfigurationSchemaAttributes.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static class AspireKeycloakExtensions
/// For example, if <paramref name="serviceName"/> is "keycloak" and <paramref name="realm"/> is "myrealm", the authority URL will be "https+http://keycloak/realms/myrealm".
/// </remarks>
public static AuthenticationBuilder AddKeycloakJwtBearer(this AuthenticationBuilder builder, string serviceName, string realm)
=> builder.AddKeycloakJwtBearer(serviceName, realm, JwtBearerDefaults.AuthenticationScheme, _ => { });
=> builder.AddKeycloakJwtBearer(serviceName, realm, JwtBearerDefaults.AuthenticationScheme, null);

/// <summary>
/// Adds Keycloak JWT Bearer authentication to the application.
Expand All @@ -41,7 +41,7 @@ public static AuthenticationBuilder AddKeycloakJwtBearer(this AuthenticationBuil
/// For example, if <paramref name="serviceName"/> is "keycloak" and <paramref name="realm"/> is "myrealm", the authority URL will be "https+http://keycloak/realms/myrealm".
/// </remarks>
public static AuthenticationBuilder AddKeycloakJwtBearer(this AuthenticationBuilder builder, string serviceName, string realm, string authenticationScheme)
=> builder.AddKeycloakJwtBearer(serviceName, realm, authenticationScheme, _ => { });
=> builder.AddKeycloakJwtBearer(serviceName, realm, authenticationScheme, null);

/// <summary>
/// Adds Keycloak JWT Bearer authentication to the application.
Expand All @@ -54,7 +54,7 @@ public static AuthenticationBuilder AddKeycloakJwtBearer(this AuthenticationBuil
/// The <paramref name="serviceName"/> is used to resolve the Keycloak server URL and is combined with the realm to form the authority URL.
/// For example, if <paramref name="serviceName"/> is "keycloak" and <paramref name="realm"/> is "myrealm", the authority URL will be "https+http://keycloak/realms/myrealm".
/// </remarks>
public static AuthenticationBuilder AddKeycloakJwtBearer(this AuthenticationBuilder builder, string serviceName, string realm, Action<JwtBearerOptions> configureOptions)
public static AuthenticationBuilder AddKeycloakJwtBearer(this AuthenticationBuilder builder, string serviceName, string realm, Action<JwtBearerOptions>? configureOptions)
=> builder.AddKeycloakJwtBearer(serviceName, realm, JwtBearerDefaults.AuthenticationScheme, configureOptions);

/// <summary>
Expand All @@ -74,7 +74,7 @@ public static AuthenticationBuilder AddKeycloakJwtBearer(
string serviceName,
string realm,
string authenticationScheme,
Action<JwtBearerOptions> configureOptions)
Action<JwtBearerOptions>? configureOptions)
{
ArgumentNullException.ThrowIfNull(builder);

Expand Down Expand Up @@ -106,7 +106,7 @@ public static AuthenticationBuilder AddKeycloakJwtBearer(
/// For example, if <paramref name="serviceName"/> is "keycloak" and <paramref name="realm"/> is "myrealm", the authority URL will be "https+http://keycloak/realms/myrealm".
/// </remarks>
public static AuthenticationBuilder AddKeycloakOpenIdConnect(this AuthenticationBuilder builder, string serviceName, string realm)
=> builder.AddKeycloakOpenIdConnect(serviceName, realm, OpenIdConnectDefaults.AuthenticationScheme, _ => { });
=> builder.AddKeycloakOpenIdConnect(serviceName, realm, OpenIdConnectDefaults.AuthenticationScheme, null);

/// <summary>
/// Adds Keycloak OpenID Connect authentication to the application.
Expand All @@ -120,7 +120,7 @@ public static AuthenticationBuilder AddKeycloakOpenIdConnect(this Authentication
/// For example, if <paramref name="serviceName"/> is "keycloak" and <paramref name="realm"/> is "myrealm", the authority URL will be "https+http://keycloak/realms/myrealm".
/// </remarks>
public static AuthenticationBuilder AddKeycloakOpenIdConnect(this AuthenticationBuilder builder, string serviceName, string realm, string authenticationScheme)
=> builder.AddKeycloakOpenIdConnect(serviceName, realm, authenticationScheme, _ => { });
=> builder.AddKeycloakOpenIdConnect(serviceName, realm, authenticationScheme, null);

/// <summary>
/// Adds Keycloak OpenID Connect authentication to the application.
Expand All @@ -133,7 +133,7 @@ public static AuthenticationBuilder AddKeycloakOpenIdConnect(this Authentication
/// The <paramref name="serviceName"/> is used to resolve the Keycloak server URL and is combined with the realm to form the authority URL.
/// For example, if <paramref name="serviceName"/> is "keycloak" and <paramref name="realm"/> is "myrealm", the authority URL will be "https+http://keycloak/realms/myrealm".
/// </remarks>
public static AuthenticationBuilder AddKeycloakOpenIdConnect(this AuthenticationBuilder builder, string serviceName, string realm, Action<OpenIdConnectOptions> configureOptions)
public static AuthenticationBuilder AddKeycloakOpenIdConnect(this AuthenticationBuilder builder, string serviceName, string realm, Action<OpenIdConnectOptions>? configureOptions)
=> builder.AddKeycloakOpenIdConnect(serviceName, realm, OpenIdConnectDefaults.AuthenticationScheme, configureOptions);

/// <summary>
Expand All @@ -153,7 +153,7 @@ public static AuthenticationBuilder AddKeycloakOpenIdConnect(
string serviceName,
string realm,
string authenticationScheme,
Action<OpenIdConnectOptions> configureOptions)
Action<OpenIdConnectOptions>? configureOptions)
{
ArgumentNullException.ThrowIfNull(builder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Microsoft.Extensions.DependencyInjection.AspireKeycloakExtensions
static Microsoft.Extensions.DependencyInjection.AspireKeycloakExtensions.AddKeycloakJwtBearer(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! serviceName, string! realm) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
static Microsoft.Extensions.DependencyInjection.AspireKeycloakExtensions.AddKeycloakJwtBearer(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! serviceName, string! realm, string! authenticationScheme) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
static Microsoft.Extensions.DependencyInjection.AspireKeycloakExtensions.AddKeycloakJwtBearer(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! serviceName, string! realm, string! authenticationScheme, System.Action<Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions!>! configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
static Microsoft.Extensions.DependencyInjection.AspireKeycloakExtensions.AddKeycloakJwtBearer(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! serviceName, string! realm, System.Action<Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions!>! configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
static Microsoft.Extensions.DependencyInjection.AspireKeycloakExtensions.AddKeycloakJwtBearer(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! serviceName, string! realm, string! authenticationScheme, System.Action<Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions!>? configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
static Microsoft.Extensions.DependencyInjection.AspireKeycloakExtensions.AddKeycloakJwtBearer(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! serviceName, string! realm, System.Action<Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions!>? configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
static Microsoft.Extensions.DependencyInjection.AspireKeycloakExtensions.AddKeycloakOpenIdConnect(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! serviceName, string! realm) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
static Microsoft.Extensions.DependencyInjection.AspireKeycloakExtensions.AddKeycloakOpenIdConnect(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! serviceName, string! realm, string! authenticationScheme) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
static Microsoft.Extensions.DependencyInjection.AspireKeycloakExtensions.AddKeycloakOpenIdConnect(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! serviceName, string! realm, string! authenticationScheme, System.Action<Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions!>! configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
static Microsoft.Extensions.DependencyInjection.AspireKeycloakExtensions.AddKeycloakOpenIdConnect(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! serviceName, string! realm, System.Action<Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions!>! configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
static Microsoft.Extensions.DependencyInjection.AspireKeycloakExtensions.AddKeycloakOpenIdConnect(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! serviceName, string! realm, string! authenticationScheme, System.Action<Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions!>? configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
static Microsoft.Extensions.DependencyInjection.AspireKeycloakExtensions.AddKeycloakOpenIdConnect(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! serviceName, string! realm, System.Action<Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions!>? configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
6 changes: 3 additions & 3 deletions src/Components/Aspire.Keycloak.Authentication/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Aspire.Keycloak library
# Aspire.Keycloak.Authentication library

Adds JwtBearer and OpenId Connect authentication to the project via a [Keycloak](https://www.keycloak.org).

Expand All @@ -16,7 +16,7 @@ Adds JwtBearer and OpenId Connect authentication to the project via a [Keycloak]
Install the .NET Aspire Keycloak library with [NuGet](https://www.nuget.org):

```dotnetcli
dotnet add package Aspire.Keycloak
dotnet add package Aspire.Keycloak.Authentication
```

## Jwt bearer authentication usage example
Expand Down Expand Up @@ -104,4 +104,4 @@ builder.Services.AddAuthentication(oidcScheme)

## Feedback & contributing

https://github.com/dotnet/aspire
https://github.com/dotnet/aspire

0 comments on commit e192bf5

Please sign in to comment.