Skip to content

Commit

Permalink
fix: Authentication level claim is 0 in dialog token (#1654)
Browse files Browse the repository at this point in the history
## Description

Changed IdportenAuthLevelClaim constant to fix parsing of Acr field in
dialog token

## Related Issue(s)

- #1458 

## Verification

- [x] **Your** code builds clean without any errors or warnings
- [x] Manual testing done (required)
- [ ] Relevant automated test added (if you find this hard, leave it and
we'll help out)

## Documentation

- [ ] Documentation is updated (either in `docs`-directory, Altinnpedia
or a separate linked PR in
[altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if
applicable)
  • Loading branch information
Fargekritt authored Jan 9, 2025
1 parent a4a1a62 commit 37e545a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.IdentityModel.Tokens;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using System.Diagnostics;
using System.IdentityModel.Tokens.Jwt;

namespace Digdir.Domain.Dialogporten.GraphQL.Common.Authentication;

Expand All @@ -22,6 +23,10 @@ public static IServiceCollection AddDialogportenAuthentication(

services.AddSingleton<ITokenIssuerCache, TokenIssuerCache>();

// Turn off mapping InboundClaims names to its longer version
// "acr" => "http://schemas.microsoft.com/claims/authnclassreference"
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;

var authenticationBuilder = services.AddAuthentication();

foreach (var schema in jwtTokenSchemas)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.IdentityModel.Tokens;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using System.Diagnostics;
using System.IdentityModel.Tokens.Jwt;

namespace Digdir.Domain.Dialogporten.WebApi.Common.Authentication;

Expand All @@ -24,6 +25,10 @@ public static IServiceCollection AddDialogportenAuthentication(

services.AddSingleton<ITokenIssuerCache, TokenIssuerCache>();

// Turn off mapping InboundClaims names to its longer version
// "acr" => "http://schemas.microsoft.com/claims/authnclassreference"
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;

var authenticationBuilder = services.AddAuthentication();

foreach (var schema in jwtTokenSchemas)
Expand Down

0 comments on commit 37e545a

Please sign in to comment.