Short story : I'm thinking of granting this Action to all Consumers. Security-wise, how stupid would that be ?
Long story :
I'd like to use the OpenCmis API to get a User's allowed actions, on a given Alfresco Resource.
This way, I will decide which UI-controls I should Enable or Render. I have created a function that scans the user's allowed actions on that resource and Checks if a given one is among them, e.g CAN_CHECK_OUT, or CAN_GET_CONTENT_STREAM.
My function works like that:
private static Boolean canUserPerformAction_(Session cmisSession, String cmisObjId, String actionKey){
try{
OperationContext operationContext = new OperationContextImpl();
operationContext.setIncludeAcls(true);
CmisObject obj = getResourceById(cmisSession, cmisObjId);
obj = (CmisObject)cmisSession.getObject(obj, operationContext);
Acl acl = obj.getAcl();
AllowableActions actions = obj.getAllowableActions();
Set<Action> allowedActions = actions.getAllowableActions();
for(Action act :allowedActions){
if(actionKey.equals( act.name() ) ){
return true;
}
}
}catch (Exception e){
log.debug("Error accessing Object allowed actions | "+e.toString());
}
return false;
}
But this method returns false Negatives for Users with Consumer/Read Role. It took me some time to realize that the Action CAN_GET_ACL
was binded for role cmis:all
and base.ReadPermissions
, so a Consumer couldn't fetch the ACLs at all, so my method will create an empty 'allowedActions' Array. Looking at the cmis:mapping I can see that:
<cmis:mapping>
<cmis:key>canGetACL.Object</cmis:key>
<cmis:permission>cmis:all</cmis:permission>
<cmis:permission>{http://www.alfresco.org/model/system/1.0}base.ReadPermissions</cmis:permission>
</cmis:mapping>
An obvious solution would be to enable base.ReadPermissions
to all users on the Company Home. But I'm not sure if this is the best way to deal with that, maybe I'm opening some security holes. Would that be a good solution ?
Or maybe I should find another way to check permissions? Any suggestions?
Thank you for your time !