Skip to content

Commit

Permalink
Sr at21 integration test config2 (#228)
Browse files Browse the repository at this point in the history
* changed some configs

* minor cosmetic fixes

* small fixes

* added packages for application insight

* refactor program cs for readability and extensibility

* removed code that was moved to extension file from program cs

* bedre mock data

* bedre mockdata

* puttet defaultrights inni dto

* AT21 appsettings

* comments

* init

* platformsettings
  • Loading branch information
simen-rekkedal authored Apr 23, 2024
1 parent e213d8d commit 0e85a8a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
/// </summary>
public class PlatformSettings
{
/// <summary>
/// Gets or sets the access management api endpoint
/// </summary>
public string? ApiAccessManagementEndpoint { get; set; }

/// <summary>
/// Gets or sets the authentication api endpoint
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,62 @@ private static async Task<List<RegisteredSystemDTO>> MockTestHelper()
{
SystemTypeId = "4human_hr_system_2024_2",
SystemVendor = "4Human",
Description = "4Humans HR system 2024 versjon."
Description = "4Humans HR system 2024 versjon.",
DefaultRights =
[
new DefaultRightsDTO { Right = "Sykemelding - Oppgi leder", ServiceProvider = "Arbeids- og velferdsetaten (NAV)" },
new DefaultRightsDTO { Right = "Søknad om sykepenger", ServiceProvider = "Arbeids- og velferdsetaten (NAV)" }
]
};

RegisteredSystemDTO regsys2 = new()
{
SystemTypeId = "din_lokale_regnskapspartner",
SystemVendor = "Din Lokale Regnskapspartner AS",
Description = "Regnskap og Revisor tjenester"
Description = "Regnskap og Revisor tjenester",
DefaultRights =
[
new DefaultRightsDTO { Right = "MVA rapportering", ServiceProvider = "Skatteetaten" },
new DefaultRightsDTO { Right = "Årsregnskap", ServiceProvider = "Skatteetaten" }
]
};

RegisteredSystemDTO regsys3 = new()
{
SystemTypeId = "fiken_smabedrift",
SystemVendor = "Fiken",
Description = "Fiken Småbedrift pakken"
Description = "Fiken Småbedrift pakken",
DefaultRights =
[
new DefaultRightsDTO { Right = "MVA rapportering", ServiceProvider = "Skatteetaten" },
new DefaultRightsDTO { Right = "Årsregnskap", ServiceProvider = "Skatteetaten" }
]
};

RegisteredSystemDTO regsys4 = new()
{
SystemTypeId = "visma_mva_pakke",
SystemVendor = "Visma",
Description = "Visma MVA rapportering"
Description = "Visma MVA rapportering",
DefaultRights =
[
new DefaultRightsDTO { Right = "MVA rapportering", ServiceProvider = "Skatteetaten" }
]

};

RegisteredSystemDTO regsys5 = new()
{
SystemTypeId = "visma_skatt_totalpakke",
SystemVendor = "Visma",
Description = "Visma Totalpakke for alle skatterapporterings behov"
Description = "Visma Totalpakke for alle skatterapporterings behov",
DefaultRights =
[
new DefaultRightsDTO { Right = "MVA rapportering", ServiceProvider = "Skatteetaten" },
new DefaultRightsDTO { Right = "Årsregnskap", ServiceProvider = "Skatteetaten" },
new DefaultRightsDTO { Right = "Bytte av Revisor", ServiceProvider = "Skatteetaten" },
new DefaultRightsDTO { Right = "Levere Lakselus", ServiceProvider = "Mattilsynet" },
]
};

List<RegisteredSystemDTO> theList = new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
using Altinn.Authentication.UI.Mocks.SystemUsers;
using Altinn.Authentication.UI.Mocks.UserProfiles;
using Altinn.Common.AccessTokenClient.Services;
using Altinn.Common.PEP.Configuration;
using AltinnCore.Authentication.JwtCookie;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.IdentityModel.Tokens;
using System.Configuration;
using System.Reflection;

namespace Altinn.Authentication.UI.Extensions
Expand Down Expand Up @@ -47,8 +49,8 @@ public static IServiceCollection ConfigureServiceDefaults(this IServiceCollectio
public static IServiceCollection ConfigureAppSettings(this IServiceCollection services, IConfiguration configuration)
{
//App Configuration
services.Configure<PlatformSettings>(configuration.GetSection("PlatformSettings"));
PlatformSettings? platformSettings = configuration.GetSection("PlatformSettings").Get<PlatformSettings>();
services.Configure<Integration.Configuration.PlatformSettings>(configuration.GetSection("PlatformSettings"));
Integration.Configuration.PlatformSettings? platformSettings = configuration.GetSection("PlatformSettings").Get<Integration.Configuration.PlatformSettings>();

services.Configure<GeneralSettings>(configuration.GetSection("GeneralSettings"));

Expand All @@ -61,7 +63,6 @@ public static IServiceCollection ConfigureAppSettings(this IServiceCollection se
/// Extension method for Program
/// </summary>
/// <param name="services"></param>
/// <param name="configuration"></param>
/// <param name="builder"></param>
/// <returns></returns>
public static IServiceCollection ConfigureAuthenticationAndSecurity(this IServiceCollection services, WebApplicationBuilder builder)
Expand All @@ -71,11 +72,16 @@ public static IServiceCollection ConfigureAuthenticationAndSecurity(this IServic
services.AddTransient<ISigningCredentialsResolver, SigningCredentialsResolver>();
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.TryAddSingleton<ValidateAntiforgeryTokenIfAuthCookieAuthorizationFilter>();

//App Configuration
services.Configure<Integration.Configuration.PlatformSettings>(builder.Configuration.GetSection("PlatformSettings"));
Integration.Configuration.PlatformSettings? platformSettings = builder.Configuration.GetSection("PlatformSettings").Get<Integration.Configuration.PlatformSettings>();

services.AddAuthentication(JwtCookieDefaults.AuthenticationScheme)
.AddJwtCookie(JwtCookieDefaults.AuthenticationScheme, configureOptions: options =>
{
options.JwtCookieName = "AltinnStudioRuntime";
options.MetadataAddress = "http://localhost:5101/authentication/api/v1/openid/";
options.MetadataAddress = platformSettings?.OpenIdWellKnownEndpoint;

options.TokenValidationParameters = new TokenValidationParameters
{
Expand Down

0 comments on commit 0e85a8a

Please sign in to comment.