Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix XACML attribute id for system users #1340

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -21,8 +21,8 @@ public static class ClaimsPrincipalExtensions
private const string IdPrefix = "0192";
private const string AltinnClaimPrefix = "urn:altinn:";
private const string IdportenAuthLevelClaim = "acr";
private const string AltinnAutorizationDetailsClaim = "authorization_details";
private const string AttributeIdSystemUser = "urn:altinn:systemuser";
private const string AuthorizationDetailsClaim = "authorization_details";
private const string AuthorizationDetailsType = "urn:altinn:systemuser";
private const string AltinnAuthLevelClaim = "urn:altinn:authlevel";
private const string ScopeClaim = "scope";
private const char ScopeClaimSeparator = ' ';
@@ -85,7 +85,7 @@ private static bool TryGetAuthorizationDetailsClaimValue(this ClaimsPrincipal cl
{
authorizationDetails = null;

if (!claimsPrincipal.TryGetClaimValue(AltinnAutorizationDetailsClaim, out var authDetailsJson))
if (!claimsPrincipal.TryGetClaimValue(AuthorizationDetailsClaim, out var authDetailsJson))
{
return false;
}
@@ -125,7 +125,7 @@ public static bool TryGetSystemUserId(this ClaimsPrincipal claimsPrincipal,
return false;
}

var systemUserDetails = authorizationDetails.FirstOrDefault(x => x.Type == AttributeIdSystemUser);
var systemUserDetails = authorizationDetails.FirstOrDefault(x => x.Type == AuthorizationDetailsType);

if (systemUserDetails?.SystemUserIds is null)
{
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ internal static class DecisionRequestHelper
private const string AltinnAutorizationDetailsClaim = "authorization_details";
private const string AttributeIdOrg = "urn:altinn:org";
private const string AttributeIdApp = "urn:altinn:app";
private const string AttributeIdSystemUser = "urn:altinn:systemuser";
private const string AttributeIdSystemUser = "urn:altinn:systemuser:uuid";
private const string AttributeIdUserId = "urn:altinn:userid";
private const string ReservedResourcePrefixForApps = "app_";
private const string AttributeIdAppInstance = "urn:altinn:instance-id";
Original file line number Diff line number Diff line change
@@ -152,7 +152,7 @@ public void CreateDialogDetailsRequestShouldReturnCorrectRequestForSystemUser()
var accessSubject = result.Request.AccessSubject.First();
Assert.Equal("s1", accessSubject.Id);
Assert.Contains(accessSubject.Attribute, a => a.AttributeId == "urn:altinn:foo" && a.Value == "bar");
Assert.Contains(accessSubject.Attribute, a => a.AttributeId == "urn:altinn:systemuser" && a.Value == "unique_systemuser_id");
Assert.Contains(accessSubject.Attribute, a => a.AttributeId == "urn:altinn:systemuser:uuid" && a.Value == "unique_systemuser_id");
elsand marked this conversation as resolved.
Show resolved Hide resolved
}

[Fact]
Loading