Skip to content

Commit

Permalink
Merged in task/dspace-cris-2023_02_x/DSC-1963 (pull request DSpace#2868)
Browse files Browse the repository at this point in the history
DSC-1963

Approved-by: Andrea Bollini
  • Loading branch information
vins01-4science authored and abollini committed Oct 16, 2024
2 parents ca92e14 + 2d9b275 commit 5780e79
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 5780e79

Please sign in to comment.