tbouron commented on a change in pull request #1061: Granularity entitlement
control
URL: https://github.com/apache/brooklyn-server/pull/1061#discussion_r274307524
##########
File path:
rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ServerResource.java
##########
@@ -421,16 +425,27 @@ public ManagementNodeState
setHighAvailabilityNodeState(HighAvailabilityMode mod
@Override
public Map<String, Object> getHighAvailabilityMetrics() {
- return mgmt().getHighAvailabilityManager().getMetrics();
+ if (Entitlements.isEntitled(mgmt().getEntitlementManager(),
Entitlements.HA_STATS, null))
+ return mgmt().getHighAvailabilityManager().getMetrics();
+ else
+ throw WebResourceUtils.forbidden("User '%s' is not authorized for
this operation", Entitlements.getEntitlementContext().user());
}
@Override
public long getHighAvailabitlityPriority() {
- return mgmt().getHighAvailabilityManager().getPriority();
+ if (Entitlements.isEntitled(mgmt().getEntitlementManager(),
Entitlements.HA_STATS, null)) {
+ return mgmt().getHighAvailabilityManager().getPriority();
+ } else {
+ throw WebResourceUtils.forbidden("User '%s' is not authorized for
this operation", Entitlements.getEntitlementContext().user());
+ }
}
@Override
public long setHighAvailabilityPriority(long priority) {
+ if (!Entitlements.isEntitled(mgmt().getEntitlementManager(),
Entitlements.HA_ADMIN, null)) {
+ throw WebResourceUtils.forbidden("User '%s' is not authorized for
this operation", Entitlements.getEntitlementContext().user());
Review comment:
Message should say: `User '%s' is not authorized to perform this operation`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services