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"