Skip to content

Commit

Permalink
patch: Update dependencies (#61)
Browse files Browse the repository at this point in the history
* Update dependencies
* Add KeycloakFormatBinder

---------

Co-authored-by: Oleksii Nikiforov <oleksii_nikiforov@epam.com>
  • Loading branch information
NikiforovAll and Oleksii Nikiforov authored Apr 23, 2024
1 parent 02bacd8 commit 7daa7c2
Show file tree
Hide file tree
Showing 40 changed files with 389 additions and 219 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

##########################################
# Common Settings
##########################################
Expand Down Expand Up @@ -75,7 +76,7 @@ dotnet_analyzer_diagnostic.severity = warning
# Motivation https://github.com/dotnet/roslyn/blob/9f87b444da9c48a4d492b19f8337339056bf2b95/src/Analyzers/Core/Analyzers/EnforceOnBuildValues.cs
##########################################
# IDE0055 Fix formatting
dotnet_diagnostic.IDE0055.severity = error
dotnet_diagnostic.IDE0055.severity = suggestion
# IDE005_gen: Remove unnecessary usings in generated code
dotnet_diagnostic.IDE0005.severity = error
# IDE0065: Using directives must be placed outside of a namespace declaration
Expand Down Expand Up @@ -226,7 +227,6 @@ csharp_using_directive_placement = inside_namespace:warning
csharp_prefer_static_local_function = true:warning
csharp_prefer_simple_using_statement = true:suggestion
dotnet_diagnostic.IDE0063.severity = suggestion

##########################################
# .NET Formatting Conventions
# https://docs.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference#formatting-conventions
Expand Down
7 changes: 7 additions & 0 deletions KeycloakAuthorizationServicesDotNet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Keycloak.AuthServices.Sdk.T
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Keycloak.AuthServices.Authentication.Tests", "tests\Keycloak.AuthServices.Authentication.Tests\Keycloak.AuthServices.Authentication.Tests.csproj", "{FE34728A-25AA-44E1-A3A6-AB500307C406}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Keycloak.AuthServices.Common.Tests", "tests\Keycloak.AuthServices.Common.Tests\Keycloak.AuthServices.Common.Tests.csproj", "{8F9E1322-568B-4F02-A1DD-4222C8457A42}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -118,6 +120,10 @@ Global
{FE34728A-25AA-44E1-A3A6-AB500307C406}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FE34728A-25AA-44E1-A3A6-AB500307C406}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FE34728A-25AA-44E1-A3A6-AB500307C406}.Release|Any CPU.Build.0 = Release|Any CPU
{8F9E1322-568B-4F02-A1DD-4222C8457A42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8F9E1322-568B-4F02-A1DD-4222C8457A42}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F9E1322-568B-4F02-A1DD-4222C8457A42}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F9E1322-568B-4F02-A1DD-4222C8457A42}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -137,6 +143,7 @@ Global
{A7C96E1A-8CD6-4BFA-8128-9875B607BEF5} = {AEBE10B1-96B1-4060-B8C1-1F9BFA7A586C}
{A85B6B1E-2030-47BE-9B9F-F645B08E501D} = {96857509-627A-4FD2-AC82-34387619A7B1}
{FE34728A-25AA-44E1-A3A6-AB500307C406} = {96857509-627A-4FD2-AC82-34387619A7B1}
{8F9E1322-568B-4F02-A1DD-4222C8457A42} = {96857509-627A-4FD2-AC82-34387619A7B1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E1907BFD-C144-4B48-AA40-972F499D4E08}
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"version": "6.0.100",
"rollForward": "latestMinor",
"allowPrerelease": true
"rollForward": "latestMajor",
"allowPrerelease": false
}
}
50 changes: 28 additions & 22 deletions samples/AuthGettingStarted/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Api;
using Keycloak.AuthServices.Authentication;
using Keycloak.AuthServices.Authorization;
using Keycloak.AuthServices.Common;
using Keycloak.AuthServices.Sdk.Admin;

var builder = WebApplication.CreateBuilder(args);
Expand All @@ -12,29 +13,32 @@

host.ConfigureLogger();

services
.AddEndpointsApiExplorer()
.AddSwagger();
services.AddEndpointsApiExplorer().AddSwagger();

var authenticationOptions = configuration
.GetSection(KeycloakAuthenticationOptions.Section)
.Get<KeycloakAuthenticationOptions>();
.Get<KeycloakAuthenticationOptions>(KeycloakInstallationOptions.KeycloakFormatBinder);

services.AddKeycloakAuthentication(authenticationOptions);
services.AddKeycloakAuthentication(authenticationOptions!);

var authorizationOptions = configuration
.GetSection(KeycloakProtectionClientOptions.Section)
.Get<KeycloakProtectionClientOptions>();
.Get<KeycloakProtectionClientOptions>(KeycloakInstallationOptions.KeycloakFormatBinder);

services
.AddAuthorization(o => o.AddPolicy("IsAdmin", b =>
{
b.RequireRealmRoles("admin");
b.RequireResourceRoles("r-admin");
// TokenValidationParameters.RoleClaimType is overriden
// by KeycloakRolesClaimsTransformation
b.RequireRole("r-admin");
}))
.AddAuthorization(o =>
o.AddPolicy(
"IsAdmin",
b =>
{
b.RequireRealmRoles("admin");
b.RequireResourceRoles("r-admin");
// TokenValidationParameters.RoleClaimType is overriden
// by KeycloakRolesClaimsTransformation
b.RequireRole("r-admin");
}
)
)
.AddKeycloakAuthorization(authorizationOptions);

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

Check warning on line 42 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Possible null reference argument for parameter 'keycloakOptions' in 'IServiceCollection ServiceCollectionExtensions.AddKeycloakAuthorization(IServiceCollection services, KeycloakProtectionClientOptions keycloakOptions)'.

var adminClientOptions = configuration
Expand All @@ -45,17 +49,19 @@

var app = builder.Build();

app
.UseSwagger()
.UseSwaggerUI();
app.UseSwagger().UseSwaggerUI();

app.UseAuthentication();
app.UseAuthorization();

app.MapGet("/", (ClaimsPrincipal user) =>
{
// TokenValidationParameters.NameClaimType is overriden based on keycloak specific claim
app.Logger.LogInformation("{@User}", user.Identity.Name);
}).RequireAuthorization("IsAdmin");
app.MapGet(
"/",
(ClaimsPrincipal user) =>
{
// TokenValidationParameters.NameClaimType is overriden based on keycloak specific claim
app.Logger.LogInformation("{@User}", user.Identity.Name);

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

Dereference of a possibly null reference.

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Dereference of a possibly null reference.

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])'

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Dereference of a possibly null reference.

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])'

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Dereference of a possibly null reference.

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])'

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Dereference of a possibly null reference.

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])'

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

Dereference of a possibly null reference.

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

Dereference of a possibly null reference.

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Dereference of a possibly null reference.

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])'

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Dereference of a possibly null reference.

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])'

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Dereference of a possibly null reference.

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])'

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Dereference of a possibly null reference.

Check warning on line 62 in samples/AuthGettingStarted/Program.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])'
}
)
.RequireAuthorization("IsAdmin");

app.Run();
34 changes: 21 additions & 13 deletions samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
namespace Microsoft.Extensions.DependencyInjection;

using Keycloak.AuthServices.Authentication;
using Keycloak.AuthServices.Common;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;

public static partial class ServiceCollectionExtensions
{
public static IServiceCollection AddApplicationSwagger(this IServiceCollection services, IConfiguration configuration)
public static IServiceCollection AddApplicationSwagger(
this IServiceCollection services,
IConfiguration configuration
)
{
KeycloakAuthenticationOptions options = new();

configuration
var options = configuration
.GetSection(KeycloakAuthenticationOptions.Section)
.Bind(options, opt => opt.BindNonPublicProperties = true);
.Get<KeycloakAuthenticationOptions>(KeycloakInstallationOptions.KeycloakFormatBinder);

services.AddEndpointsApiExplorer();
services.AddSwaggerGen(c =>
Expand All @@ -31,28 +33,34 @@ public static IServiceCollection AddApplicationSwagger(this IServiceCollection s
{
Implicit = new OpenApiOAuthFlow
{
AuthorizationUrl = new Uri($"{options.KeycloakUrlRealm}/protocol/openid-connect/auth"),
TokenUrl = new Uri($"{options.KeycloakUrlRealm}/protocol/openid-connect/token"),
AuthorizationUrl = new Uri(
$"{options.KeycloakUrlRealm}/protocol/openid-connect/auth"

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Dereference of a possibly null reference.

Check warning on line 37 in samples/AuthZGettingStarted/ServiceCollectionExtensions.OpenApi.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Dereference of a possibly null reference.
),
TokenUrl = new Uri(
$"{options.KeycloakUrlRealm}/protocol/openid-connect/token"
),
Scopes = new Dictionary<string, string>(),
}
}
};
c.AddSecurityDefinition(securityScheme.Reference.Id, securityScheme);
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{securityScheme, Array.Empty<string>()}
});
c.AddSecurityRequirement(
new OpenApiSecurityRequirement { { securityScheme, Array.Empty<string>() } }
);
});
return services;
}

public static IApplicationBuilder UseApplicationSwagger(this IApplicationBuilder app, IConfiguration configuration)
public static IApplicationBuilder UseApplicationSwagger(
this IApplicationBuilder app,
IConfiguration configuration
)
{
KeycloakAuthenticationOptions options = new();

configuration
.GetSection(KeycloakAuthenticationOptions.Section)
.Bind(options, opt => opt.BindNonPublicProperties = true);
.Bind(options, KeycloakInstallationOptions.KeycloakFormatBinder);

app.UseSwagger();
app.UseSwaggerUI(s => s.OAuthClientId(options.Resource));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.5" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.5.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion samples/Blazor/Server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Globalization;
using Keycloak.AuthServices.Authentication;
using Microsoft.OpenApi.Models;
using Serilog;
Expand Down Expand Up @@ -40,7 +41,8 @@
.MinimumLevel.Verbose()
.WriteTo.Console(
outputTemplate: "[{Level:u4}] | {Message:lj}{NewLine}{Exception}",
restrictedToMinimumLevel: LogEventLevel.Information)
restrictedToMinimumLevel: LogEventLevel.Information,
formatProvider: CultureInfo.InvariantCulture)
.CreateBootstrapLogger();

builder.Host.UseSerilog();
Expand Down
8 changes: 7 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<Project>

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFrameworks>net6.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
<Authors>Oleksii Nikiforov (@nikiforovall)</Authors>
<PackageProjectUrl>https://github.com/NikiforovAll/keycloak-authorization-services-dotnet</PackageProjectUrl>
Expand All @@ -9,8 +15,8 @@
</PropertyGroup>

<PropertyGroup Label="MinVer">
<MinVerDefaultPreReleasePhase>preview</MinVerDefaultPreReleasePhase>
<MinVerVerbosity>normal</MinVerVerbosity>
<MinVerDefaultPreReleaseIdentifiers>preview.0</MinVerDefaultPreReleaseIdentifiers>
</PropertyGroup>

<ItemGroup>
Expand Down
22 changes: 13 additions & 9 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<Project>
<ItemGroup Label="Core">
<PackageVersion Include="IdentityModel.AspNetCore" Version="4.1.2"/>
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1"/>
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0"/>
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0"/>

<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.29"/>
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1"/>

<PackageVersion Include="IdentityModel.AspNetCore" Version="4.3.0"/>
<PackageVersion Include="Refit.HttpClientFactory" Version="7.0.0"/>
<PackageVersion Include="Refit" Version="7.0.0"/>

<PackageVersion Include="Microsoft.AspNetCore.Authorization" Version="6.0.1"/>
<PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0"/>
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0"/>
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0"/>
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0"/>
<PackageVersion Include="Refit.HttpClientFactory" Version="6.1.15"/>
<PackageVersion Include="Refit" Version="6.1.15"/>
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0"/>
</ItemGroup>

<ItemGroup Label="Release">
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1"/>
<PackageVersion Include="MinVer" Version="2.5.0"/>
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0"/>
<PackageVersion Include="MinVer" Version="5.0.0"/>
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions src/Keycloak.AuthServices.Authentication/Claims/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*.cs]
dotnet_diagnostic.CA1309.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class KeycloakConfigurationProvider : JsonConfigurationProvider
/// Initializes a new instance with the specified source.
/// </summary>
/// <param name="source">The source settings.</param>
public KeycloakConfigurationProvider(KeycloakConfigurationSource source) : base(source) =>
this.stringBuilder = new StringBuilder();
public KeycloakConfigurationProvider(KeycloakConfigurationSource source)
: base(source) => this.stringBuilder = new StringBuilder();

/// <summary>
/// Loads the JSON data from a stream.
Expand All @@ -32,7 +32,8 @@ public override void Load(Stream stream)
this.Data = this.Data.ToDictionary(
x => this.NormalizeKey(x.Key),
x => x.Value,
StringComparer.OrdinalIgnoreCase);
StringComparer.OrdinalIgnoreCase
);
}

/// <summary>
Expand All @@ -42,8 +43,7 @@ public override void Load(Stream stream)
/// <returns></returns>
private string NormalizeKey(string key)
{
var sections = key
.ToUpper(CultureInfo.InvariantCulture)
var sections = key.ToUpper(CultureInfo.InvariantCulture)
.Split(NestedConfigurationDelimiter);

foreach (var section in sections)
Expand All @@ -70,8 +70,10 @@ private string NormalizeKey(string key)
}
}

var result = ConfigurationConstants.ConfigurationPrefix + NestedConfigurationDelimiter +
this.stringBuilder.ToString();
var result =
ConfigurationConstants.ConfigurationPrefix
+ NestedConfigurationDelimiter
+ this.stringBuilder.ToString();
this.stringBuilder.Clear();
return result;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Keycloak.AuthServices.Authentication</RootNamespace>
</PropertyGroup>

Expand Down
Loading

0 comments on commit 7daa7c2

Please sign in to comment.