mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUACAMOLE-360: Merge update active connection permission check to support user groups.
This commit is contained in:
@@ -97,7 +97,7 @@ public class ActiveConnectionPermissionService
|
||||
permissions.add(new ObjectPermission(ObjectPermission.Type.READ, identifier));
|
||||
|
||||
// If we're an admin, or the connection is ours, then we can DELETE
|
||||
if (isAdmin || targetUser.getIdentifier().equals(record.getUsername()))
|
||||
if (isAdmin || targetEntity.isUser(record.getUsername()))
|
||||
permissions.add(new ObjectPermission(ObjectPermission.Type.DELETE, identifier));
|
||||
|
||||
}
|
||||
|
@@ -105,6 +105,21 @@ public abstract class ModeledPermissions<ModelType extends EntityModel>
|
||||
return getModel().getEntityType() == EntityType.USER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the underlying entity represents a specific user having
|
||||
* the given username.
|
||||
*
|
||||
* @param username
|
||||
* The username of a user.
|
||||
*
|
||||
* @return
|
||||
* true if the underlying entity is a user that has the given username,
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean isUser(String username) {
|
||||
return isUser() && getIdentifier().equals(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the underlying entity is a user group. Entities may be
|
||||
* either users or user groups.
|
||||
|
@@ -101,7 +101,7 @@ public abstract class AbstractPermissionService<PermissionSetType extends Permis
|
||||
throws GuacamoleException {
|
||||
|
||||
// A user can always read their own permissions
|
||||
if (targetEntity.isUser() && user.getUser().getIdentifier().equals(targetEntity.getIdentifier()))
|
||||
if (targetEntity.isUser(user.getUser().getIdentifier()))
|
||||
return true;
|
||||
|
||||
// A system adminstrator can do anything
|
||||
|
Reference in New Issue
Block a user