Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Nils Bandener <[email protected]>
  • Loading branch information
nibix committed Jun 20, 2024
1 parent dbf7cd6 commit 1714bd7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,15 @@ public PrivilegesEvaluator(
SecurityDynamicConfiguration<?> rolesConfiguration = configurationRepository.getConfiguration(CType.ROLES);

if (rolesConfiguration != null) {
FlattenedActionGroups flattenedActionGroups = actionGroupsConfiguration != null
? new FlattenedActionGroups(
(SecurityDynamicConfiguration<ActionGroupsV7>) DynamicConfigFactory.addStatics(
actionGroupsConfiguration.deepClone()
)
@SuppressWarnings("unchecked")
SecurityDynamicConfiguration<ActionGroupsV7> actionGroupsWithStatics = actionGroupsConfiguration != null
? (SecurityDynamicConfiguration<ActionGroupsV7>) DynamicConfigFactory.addStatics(
actionGroupsConfiguration.deepClone()
)
: FlattenedActionGroups.EMPTY;
: (SecurityDynamicConfiguration<ActionGroupsV7>) DynamicConfigFactory.addStatics(
SecurityDynamicConfiguration.empty()
);
FlattenedActionGroups flattenedActionGroups = new FlattenedActionGroups(actionGroupsWithStatics);
ActionPrivileges actionPrivileges = new ActionPrivileges(
DynamicConfigFactory.addStatics(rolesConfiguration.deepClone()),
flattenedActionGroups,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,6 @@ public static <T> SecurityDynamicConfiguration<T> fromYaml(String yaml, CType ct
return result;
}

/**
* For testing only
*/
public static <T> SecurityDynamicConfiguration<T> fromMap(Map<String, Object> map, CType ctype) throws JsonProcessingException {
Class<?> implementationClass = ctype.getImplementationClass().get(2);
SecurityDynamicConfiguration<T> result = DefaultObjectMapper.objectMapper.convertValue(
map,
DefaultObjectMapper.getTypeFactory().constructParametricType(SecurityDynamicConfiguration.class, implementationClass)
);
result.ctype = ctype;
return result;
}

// for Jackson
private SecurityDynamicConfiguration() {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,17 +515,16 @@ SecurityDynamicConfiguration<RoleV7> toRolesConfig(ActionSpec actionSpec) {
try {
return SecurityDynamicConfiguration.fromMap(
ImmutableMap.of(
"test_role", //
"test_role",
ImmutableMap.of(
//
"index_permissions",
Arrays.asList(
//
ImmutableMap.of("index_patterns", this.givenIndexPrivs, "allowed_actions", actionSpec.givenPrivs)
)//
)
)
),
CType.ROLES
CType.ROLES,
2
);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public void setup(
Arrays.asList("*")
)
),
CType.ROLES
CType.ROLES,
2
);

this.actionPrivileges = new ActionPrivileges(rolesConfig, FlattenedActionGroups.EMPTY, () -> indexMetadata);
Expand Down

0 comments on commit 1714bd7

Please sign in to comment.