Skip to content

Commit

Permalink
[DSC-1963] Fixes potential cache issues with rest exposed props
Browse files Browse the repository at this point in the history
  • Loading branch information
vins01-4science committed Oct 11, 2024
1 parent f21e6f5 commit 2d9b275
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,21 @@ public class ConfigurationRestRepository extends DSpaceRestRepository<PropertyRe
private AuthorizeService authorizeService;

private ConfigurationService configurationService;
private List<String> exposedProperties;
private List<String> adminRestrictedProperties;

@Autowired
public ConfigurationRestRepository(ConfigurationService configurationService) {
this.configurationService = configurationService;
this.exposedProperties = Arrays.asList(configurationService.getArrayProperty("rest.properties.exposed"));
this.adminRestrictedProperties =
Arrays.asList(configurationService.getArrayProperty("admin.rest.properties.exposed"));
}

protected String[] getExposedProperties() {
return configurationService.getArrayProperty("rest.properties.exposed");
}

protected String[] getAdminRestrictedProperties() {
return configurationService.getArrayProperty("admin.rest.properties.exposed");
}


/**
* Gets the value of a configuration property if it is exposed via REST
*
Expand All @@ -62,6 +66,9 @@ public ConfigurationRestRepository(ConfigurationService configurationService) {
@Override
@PreAuthorize("permitAll()")
public PropertyRest findOne(Context context, String property) {
List<String> exposedProperties = Arrays.asList(getExposedProperties());
List<String> adminRestrictedProperties = Arrays.asList(getAdminRestrictedProperties());

if (!configurationService.hasProperty(property) ||
(adminRestrictedProperties.contains(property) && !isCurrentUserAdmin(context)) ||
(!exposedProperties.contains(property) && !isCurrentUserAdmin(context))) {
Expand Down

0 comments on commit 2d9b275

Please sign in to comment.