diff --git a/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI.Core/AppConfiguration/ClientSettings.cs b/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI.Core/AppConfiguration/ClientSettings.cs index 80a95315..8d064cad 100644 --- a/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI.Core/AppConfiguration/ClientSettings.cs +++ b/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI.Core/AppConfiguration/ClientSettings.cs @@ -2,6 +2,8 @@ public class ClientSettings { + public ClientSettings() { } + public ClientSettings(string issuer, string app, string certificateName) { Issuer = issuer; diff --git a/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI.Core/AppConfiguration/KeyVaultSettings.cs b/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI.Core/AppConfiguration/KeyVaultSettings.cs index 5bf18002..6579c706 100644 --- a/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI.Core/AppConfiguration/KeyVaultSettings.cs +++ b/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI.Core/AppConfiguration/KeyVaultSettings.cs @@ -2,6 +2,8 @@ public class KeyVaultSettings { + public KeyVaultSettings() { } + public KeyVaultSettings(string secretUri) { SecretUri = secretUri; diff --git a/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI.Integration/UserProfiles/UserProfileClient.cs b/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI.Integration/UserProfiles/UserProfileClient.cs index 91f2f836..3fdfd04f 100644 --- a/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI.Integration/UserProfiles/UserProfileClient.cs +++ b/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI.Integration/UserProfiles/UserProfileClient.cs @@ -8,6 +8,7 @@ using System.Text.Json.Serialization; using Altinn.Authentication.UI.Core.Extensions; using Altinn.Authentication.UI.Integration.AccessToken; +using Microsoft.Extensions.Options; namespace Altinn.Authentication.UI.Integration.UserProfiles; @@ -34,13 +35,13 @@ public UserProfileClient( ILogger logger, HttpClient httpClient, IHttpContextAccessor httpContextAccessor, - PlatformSettings platformSettings, + IOptions platformSettings, IAccessTokenProvider accessTokenProvider) { _logger = logger; _httpClient = httpClient; _httpContextAccessor = httpContextAccessor; - _platformSettings = platformSettings; + _platformSettings = platformSettings.Value; _accessTokenProvider = accessTokenProvider; } diff --git a/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI/Extensions/ProgramConfigurationAndDependencyInjection.cs b/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI/Extensions/ProgramConfigurationAndDependencyInjection.cs index d537002f..7516b916 100644 --- a/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI/Extensions/ProgramConfigurationAndDependencyInjection.cs +++ b/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI/Extensions/ProgramConfigurationAndDependencyInjection.cs @@ -5,8 +5,10 @@ using Altinn.Authentication.UI.Core.SystemUsers; using Altinn.Authentication.UI.Core.UserProfiles; using Altinn.Authentication.UI.Filters; +using Altinn.Authentication.UI.Integration.AccessToken; using Altinn.Authentication.UI.Integration.Authentication; using Altinn.Authentication.UI.Integration.Configuration; +using Altinn.Authentication.UI.Integration.KeyVault; using Altinn.Authentication.UI.Integration.SystemRegister; using Altinn.Authentication.UI.Integration.SystemUsers; using Altinn.Authentication.UI.Integration.UserProfiles; @@ -122,14 +124,28 @@ public static IServiceCollection ConfigureAuthenticationAndSecurity(this IServic /// Adds Clients for Integration to the Authentication Component for AuthenticationClient, UserProfileClient, PartyClient, SystemUserClient and SystemRegisterClient /// /// - /// + /// /// - public static IServiceCollection AddIntegrationLayer(this IServiceCollection services) + public static IServiceCollection AddIntegrationLayer(this IServiceCollection services, bool isDevelopment) { //Clients in the Integration layer for the login user and auth logic //services.AddHttpClient(); services.AddHttpClient(); - services.AddHttpClient(); + services.AddHttpClient(); + + //Providers and supporting services + if (isDevelopment) + { + services.AddSingleton(); + } + else + { + services.AddSingleton(); + } + + services.AddSingleton(); + services.AddSingleton(); + //Clients for the actual Features' Services services.AddHttpClient(); diff --git a/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI/Program.cs b/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI/Program.cs index 98b855ba..7b751226 100644 --- a/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI/Program.cs +++ b/bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI/Program.cs @@ -26,7 +26,7 @@ builder.Services.ConfigureAuthenticationAndSecurity(builder); //Adds the layers -builder.Services.AddIntegrationLayer(); +builder.Services.AddIntegrationLayer(builder.Environment.IsDevelopment()); builder.Services.AddCoreServices(); //Swagger