Skip to content
Snippets Groups Projects
Commit af764d05 authored by Pavel Břoušek's avatar Pavel Břoušek
Browse files

chore: merge branch 'dBucik/fix_filtering_out_res_caps' into 'main'

fix: :bug: Entitlements sources - do not ignore res. capabilities

See merge request !398
parents 948b33a3 f14c85e9
No related branches found
No related tags found
1 merge request!398fix: 🐛 Entitlements sources - do not ignore res. capabilities
Pipeline #445718 passed
......@@ -47,10 +47,14 @@ public class EntitlementExtendedClaimSource extends EntitlementSource {
private Set<String> produceEntitlementsExtended(Facility facility, Long userId, PerunAdapter perunAdapter) {
Set<Group> userGroups = ClaimUtils.getUserGroupsOnFacility(
facility, userId, perunAdapter, getClaimName(), getGroupEntitlementDisabledAttr());
Map<Long, String> groupIdToNameMap = super.getGroupIdToNameMap(userGroups, false);
Set<String> entitlements = new TreeSet<>();
this.fillUuidEntitlements(userGroups, entitlements);
fillForwardedEntitlements(perunAdapter, userId, entitlements);
userGroups = ClaimUtils.getUserGroupsOnFacility(
facility, userId, perunAdapter, getClaimName(), null);
Map<Long, String> groupIdToNameMap = super.getGroupIdToNameMap(userGroups, false);
fillCapabilities(facility, perunAdapter, groupIdToNameMap,entitlements);
log.trace("{} - UUID entitlements added", getClaimName());
return entitlements;
......
......@@ -97,8 +97,7 @@ public class EntitlementSource extends GroupNamesSource {
PerunAdapter perunAdapter = pctx.getPerunAdapter();
Long userId = pctx.getPerunUserId();
Facility facility = pctx.getFacility();
Set<Group> userGroups = ClaimUtils.getUserGroupsOnFacility(facility, userId, perunAdapter, groupEntitlementDisabledAttr, getClaimName());
Set<String> entitlements = produceEntitlements(facility, userGroups, userId, perunAdapter);
Set<String> entitlements = produceEntitlements(facility, userId, perunAdapter);
JsonNode result = ClaimUtils.convertResultStringsToJsonArray(entitlements);
log.debug("{} - produced value for user({}): '{}'", getClaimName(), userId, result);
......@@ -152,18 +151,20 @@ public class EntitlementSource extends GroupNamesSource {
}
}
protected Set<String> produceEntitlements(Facility facility, Set<Group> userGroups,
Long userId, PerunAdapter perunAdapter)
protected Set<String> produceEntitlements(Facility facility, Long userId, PerunAdapter perunAdapter)
{
Set<String> entitlements = new TreeSet<>();
Map<Long, String> groupIdToNameMap = super.getGroupIdToNameMap(userGroups, false);
Set<Group> userGroups = ClaimUtils.getUserGroupsOnFacility(facility, userId, perunAdapter, groupEntitlementDisabledAttr, getClaimName());
Map<Long, String> groupIdToNameMap = super.getGroupIdToNameMap(userGroups, false);
if (groupIdToNameMap != null && !groupIdToNameMap.values().isEmpty()) {
this.fillEntitlementsFromGroupNames(new HashSet<>(groupIdToNameMap.values()), entitlements);
log.trace("{} - entitlements for group names added", getClaimName());
}
if (facility != null) {
userGroups = ClaimUtils.getUserGroupsOnFacility(facility, userId, perunAdapter, null, getClaimName());
groupIdToNameMap = super.getGroupIdToNameMap(userGroups, false);
this.fillCapabilities(facility, perunAdapter, groupIdToNameMap, entitlements);
log.trace("{} - capabilities added", getClaimName());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment