Skip to content

Commit 0b28f14

Browse files
jonkjetiloyeJon Kjetil Øye
andauthored
bug: fix CalculateRightKeys based on instance delegation policy (#2609)
#2608 Co-authored-by: Jon Kjetil Øye <acn-joye@ai-dev.no>
1 parent 69542ad commit 0b28f14

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/apps/Altinn.AccessManagement/src/Altinn.AccessMgmt.Core/Utils/Helper/DelegationCheckHelper.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ public static IEnumerable<string> CalculateRightKeys(XacmlRule rule, string reso
183183
{
184184
var org = resourceObj.FirstOrDefault(r => r.Id.Equals(AltinnXacmlConstants.MatchAttributeIdentifiers.OrgAttribute));
185185
var app = resourceObj.FirstOrDefault(r => r.Id.Equals(AltinnXacmlConstants.MatchAttributeIdentifiers.AppAttribute));
186+
var instance = resourceObj.FirstOrDefault(r => r.Id.Equals(AltinnXacmlConstants.MatchAttributeIdentifiers.ResourceInstanceAttribute));
186187

187188
if (org != null && app != null)
188189
{
@@ -192,6 +193,11 @@ public static IEnumerable<string> CalculateRightKeys(XacmlRule rule, string reso
192193
resourceObj.Add(new PolicyAttributeMatch { Id = AltinnXacmlConstants.MatchAttributeIdentifiers.ResourceRegistryAttribute, Value = resourceAppId });
193194
}
194195

196+
if (instance != null)
197+
{
198+
resourceObj.Remove(instance);
199+
}
200+
195201
// Just throw away resources not matching the resourceid we are looking for
196202
if (resourceObj.Any(r => r.Id.Equals(AltinnXacmlConstants.MatchAttributeIdentifiers.ResourceRegistryAttribute) && r.Value.Equals(resource, StringComparison.OrdinalIgnoreCase)) == false)
197203
{

0 commit comments

Comments
 (0)