Skip to content

Commit

Permalink
Sr at21 integration test config5 (#235)
Browse files Browse the repository at this point in the history
* unauth systemregister

* reauth systemregister

* add profileclient and it's dependencies

* access token etc towards profile api

* fix comment

* init

* forgot to switch to the real client from the mock

* userprofile and partyclient fixes

* removed unused method

* fix

* quickfix

* nudge

* fixed missing services in DI

* fix authorize
  • Loading branch information
simen-rekkedal authored Apr 24, 2024
1 parent 3e38190 commit 1eada96
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

public class ClientSettings
{
public ClientSettings() { }

public ClientSettings(string issuer, string app, string certificateName)
{
Issuer = issuer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

public class KeyVaultSettings
{
public KeyVaultSettings() { }

public KeyVaultSettings(string secretUri)
{
SecretUri = secretUri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -34,13 +35,13 @@ public UserProfileClient(
ILogger<UserProfileClient> logger,
HttpClient httpClient,
IHttpContextAccessor httpContextAccessor,
PlatformSettings platformSettings,
IOptions<PlatformSettings> platformSettings,
IAccessTokenProvider accessTokenProvider)
{
_logger = logger;
_httpClient = httpClient;
_httpContextAccessor = httpContextAccessor;
_platformSettings = platformSettings;
_platformSettings = platformSettings.Value;
_accessTokenProvider = accessTokenProvider;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
/// </summary>
/// <param name="services"></param>
/// <param name="configuration"></param>
/// <param name="isDevelopment"></param>
/// <returns></returns>
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<IAuthenticationClient, AuthenticationClientMock>();
services.AddHttpClient<IAuthenticationClient, AuthenticationClient>();
services.AddHttpClient<IUserProfileClient, UserProfileClient>();
services.AddHttpClient<IUserProfileClient, UserProfileClient>();

//Providers and supporting services
if (isDevelopment)
{
services.AddSingleton<IKeyVaultService, LocalKeyVaultService>();
}
else
{
services.AddSingleton<IKeyVaultService, KeyVaultService>();
}

services.AddSingleton<IAccessTokenGenerator, AccessTokenGenerator>();
services.AddSingleton<IAccessTokenProvider, AccessTokenProvider>();


//Clients for the actual Features' Services
services.AddHttpClient<ISystemUserClient, SystemUserClient>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
builder.Services.ConfigureAuthenticationAndSecurity(builder);

//Adds the layers
builder.Services.AddIntegrationLayer();
builder.Services.AddIntegrationLayer(builder.Environment.IsDevelopment());
builder.Services.AddCoreServices();

//Swagger
Expand Down

0 comments on commit 1eada96

Please sign in to comment.