mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-5: Merge sharing profile fixes for non-admins.
This commit is contained in:
@@ -80,6 +80,7 @@ public class ActiveConnectionService
|
|||||||
public Collection<TrackedActiveConnection> retrieveObjects(AuthenticatedUser user,
|
public Collection<TrackedActiveConnection> retrieveObjects(AuthenticatedUser user,
|
||||||
Collection<String> identifiers) throws GuacamoleException {
|
Collection<String> identifiers) throws GuacamoleException {
|
||||||
|
|
||||||
|
String username = user.getIdentifier();
|
||||||
boolean isAdmin = user.getUser().isAdministrator();
|
boolean isAdmin = user.getUser().isAdministrator();
|
||||||
Set<String> identifierSet = new HashSet<String>(identifiers);
|
Set<String> identifierSet = new HashSet<String>(identifiers);
|
||||||
|
|
||||||
@@ -90,10 +91,15 @@ public class ActiveConnectionService
|
|||||||
Collection<TrackedActiveConnection> activeConnections = new ArrayList<TrackedActiveConnection>(identifiers.size());
|
Collection<TrackedActiveConnection> activeConnections = new ArrayList<TrackedActiveConnection>(identifiers.size());
|
||||||
for (ActiveConnectionRecord record : records) {
|
for (ActiveConnectionRecord record : records) {
|
||||||
|
|
||||||
|
// Sensitive information should be included if the connection was
|
||||||
|
// started by the current user OR the user is an admin
|
||||||
|
boolean includeSensitiveInformation =
|
||||||
|
isAdmin || username.equals(record.getUsername());
|
||||||
|
|
||||||
// Add connection if within requested identifiers
|
// Add connection if within requested identifiers
|
||||||
if (identifierSet.contains(record.getUUID().toString())) {
|
if (identifierSet.contains(record.getUUID().toString())) {
|
||||||
TrackedActiveConnection activeConnection = trackedActiveConnectionProvider.get();
|
TrackedActiveConnection activeConnection = trackedActiveConnectionProvider.get();
|
||||||
activeConnection.init(user, record, isAdmin);
|
activeConnection.init(user, record, includeSensitiveInformation);
|
||||||
activeConnections.add(activeConnection);
|
activeConnections.add(activeConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
<!-- Select identifiers of all readable sharing profiles associated with a particular connection -->
|
<!-- Select identifiers of all readable sharing profiles associated with a particular connection -->
|
||||||
<select id="selectReadableIdentifiersWithin" resultType="string">
|
<select id="selectReadableIdentifiersWithin" resultType="string">
|
||||||
SELECT sharing_profile_id
|
SELECT guacamole_sharing_profile.sharing_profile_id
|
||||||
FROM guacamole_sharing_profile
|
FROM guacamole_sharing_profile
|
||||||
JOIN guacamole_sharing_profile_permission ON guacamole_sharing_profile_permission.sharing_profile_id = guacamole_sharing_profile.sharing_profile_id
|
JOIN guacamole_sharing_profile_permission ON guacamole_sharing_profile_permission.sharing_profile_id = guacamole_sharing_profile.sharing_profile_id
|
||||||
WHERE
|
WHERE
|
||||||
|
@@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
<!-- Select identifiers of all readable sharing profiles associated with a particular connection -->
|
<!-- Select identifiers of all readable sharing profiles associated with a particular connection -->
|
||||||
<select id="selectReadableIdentifiersWithin" resultType="string">
|
<select id="selectReadableIdentifiersWithin" resultType="string">
|
||||||
SELECT sharing_profile_id
|
SELECT guacamole_sharing_profile.sharing_profile_id
|
||||||
FROM guacamole_sharing_profile
|
FROM guacamole_sharing_profile
|
||||||
JOIN guacamole_sharing_profile_permission ON guacamole_sharing_profile_permission.sharing_profile_id = guacamole_sharing_profile.sharing_profile_id
|
JOIN guacamole_sharing_profile_permission ON guacamole_sharing_profile_permission.sharing_profile_id = guacamole_sharing_profile.sharing_profile_id
|
||||||
WHERE
|
WHERE
|
||||||
|
@@ -30,6 +30,7 @@ import javax.ws.rs.Produces;
|
|||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
import org.apache.guacamole.GuacamoleResourceNotFoundException;
|
||||||
import org.apache.guacamole.net.auth.ActiveConnection;
|
import org.apache.guacamole.net.auth.ActiveConnection;
|
||||||
import org.apache.guacamole.net.auth.UserContext;
|
import org.apache.guacamole.net.auth.UserContext;
|
||||||
import org.apache.guacamole.rest.activeconnection.APIActiveConnection;
|
import org.apache.guacamole.rest.activeconnection.APIActiveConnection;
|
||||||
@@ -96,10 +97,14 @@ public class TunnelResource {
|
|||||||
// Pull the UserContext from the tunnel
|
// Pull the UserContext from the tunnel
|
||||||
UserContext userContext = tunnel.getUserContext();
|
UserContext userContext = tunnel.getUserContext();
|
||||||
|
|
||||||
|
// Fail if the active connection cannot be found
|
||||||
|
ActiveConnection activeConnection = tunnel.getActiveConnection();
|
||||||
|
if (activeConnection == null)
|
||||||
|
throw new GuacamoleResourceNotFoundException("No readable active connection for tunnel.");
|
||||||
|
|
||||||
// Return the associated ActiveConnection as a resource
|
// Return the associated ActiveConnection as a resource
|
||||||
return activeConnectionResourceFactory.create(userContext,
|
return activeConnectionResourceFactory.create(userContext,
|
||||||
userContext.getActiveConnectionDirectory(),
|
userContext.getActiveConnectionDirectory(), activeConnection);
|
||||||
tunnel.getActiveConnection());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user