Skip to content

Commit

Permalink
Fix ID-porten acr claim
Browse files Browse the repository at this point in the history
  • Loading branch information
elsand committed Oct 15, 2024
1 parent 378f306 commit 0095dfa
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion TokenGenerator/Services/Token.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public async Task<string> GetPersonalToken(string env, string[] scopes, uint use
{ "pid", pid },
{ "token_type", "Bearer" },
{ "client_id", Guid.NewGuid().ToString() },
{ "acr", "Level" + authLvl },
{ "acr", GetAcrLevel(authLvl) },
{ "scope", string.Join(' ', scopes) },
{ "exp", dateTimeOffset.ToUnixTimeSeconds() + ttl },
{ "iat", dateTimeOffset.ToUnixTimeSeconds() },
Expand Down Expand Up @@ -221,6 +221,18 @@ public async Task<string> GetPersonalToken(string env, string[] scopes, uint use

}

private string GetAcrLevel(string authLvl)
{
return authLvl switch
{
"3" => "idporten-loa-substantial",
"4" => "idporten-loa-high",
// NOTE! This is not currently a value that ID-porten produces
// https://docs.digdir.no/docs/idporten/oidc/oidc_protocol_new_idporten#new-acr-values
_ => "idporten-loa-low"
};
}

public async Task<string> GetConsentToken(string env, string[] serviceCodes, IQueryCollection queryParameters,
Guid authorizationCode, string offeredBy, string coveredBy, string handledBy, uint ttl)
{
Expand Down

0 comments on commit 0095dfa

Please sign in to comment.