From 441d5293730dd2ac5e549ef7b60908245103abc6 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Mon, 16 Dec 2024 17:58:35 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D1=81?= =?UTF-8?q?=D0=B5=D0=BA=D1=86=D0=B8=D0=B8=20Authentication=20=D0=B2=D0=BD?= =?UTF-8?q?=D1=83=D1=82=D1=80=D0=B8=20appsettings.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DD.Persistence.API/DependencyInjection.cs | 5 +++-- DD.Persistence.App/appsettings.json | 1 - DD.Persistence.App/defaultsettings.json | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/DD.Persistence.API/DependencyInjection.cs b/DD.Persistence.API/DependencyInjection.cs index d009aae..0b0ee72 100644 --- a/DD.Persistence.API/DependencyInjection.cs +++ b/DD.Persistence.API/DependencyInjection.cs @@ -74,15 +74,16 @@ public static class DependencyInjection private static void AddKeyCloakAuthentication(this IServiceCollection services, IConfiguration configuration) { + var keyCloakHost = configuration["Authentication:Audience"]; services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.Audience = configuration["Authentication:Audience"]; - options.MetadataAddress = configuration["Authentication:MetadataAddress"]!; + options.MetadataAddress = $"{keyCloakHost}/.well-known/openid-configuration"; options.TokenValidationParameters = new TokenValidationParameters { - ValidIssuer = configuration["Authentication:ValidIssuer"], + ValidIssuer = keyCloakHost, }; }); } diff --git a/DD.Persistence.App/appsettings.json b/DD.Persistence.App/appsettings.json index d4248fb..bec1541 100644 --- a/DD.Persistence.App/appsettings.json +++ b/DD.Persistence.App/appsettings.json @@ -10,7 +10,6 @@ }, "AllowedHosts": "*", "Authentication": { - "MetadataAddress": "http://192.168.0.10:8321/realms/Persistence/.well-known/openid-configuration", "Audience": "account", "ValidIssuer": "http://192.168.0.10:8321/realms/Persistence", "AuthorizationUrl": "http://192.168.0.10:8321/realms/Persistence/protocol/openid-connect/auth" diff --git a/DD.Persistence.App/defaultsettings.json b/DD.Persistence.App/defaultsettings.json index d4248fb..bec1541 100644 --- a/DD.Persistence.App/defaultsettings.json +++ b/DD.Persistence.App/defaultsettings.json @@ -10,7 +10,6 @@ }, "AllowedHosts": "*", "Authentication": { - "MetadataAddress": "http://192.168.0.10:8321/realms/Persistence/.well-known/openid-configuration", "Audience": "account", "ValidIssuer": "http://192.168.0.10:8321/realms/Persistence", "AuthorizationUrl": "http://192.168.0.10:8321/realms/Persistence/protocol/openid-connect/auth"