mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-360: Merge support for managing own sessions.
This commit is contained in:
@@ -96,8 +96,8 @@ public class ActiveConnectionPermissionService
|
||||
String identifier = record.getUUID().toString();
|
||||
permissions.add(new ObjectPermission(ObjectPermission.Type.READ, identifier));
|
||||
|
||||
// If we're and admin, then we also have DELETE
|
||||
if (isAdmin)
|
||||
// If we're an admin, or the connection is ours, then we can DELETE
|
||||
if (isAdmin || targetUser.getIdentifier().equals(record.getUsername()))
|
||||
permissions.add(new ObjectPermission(ObjectPermission.Type.DELETE, identifier));
|
||||
|
||||
}
|
||||
|
@@ -34,6 +34,8 @@ import org.apache.guacamole.auth.jdbc.tunnel.ActiveConnectionRecord;
|
||||
import org.apache.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService;
|
||||
import org.apache.guacamole.net.GuacamoleTunnel;
|
||||
import org.apache.guacamole.net.auth.ActiveConnection;
|
||||
import org.apache.guacamole.net.auth.permission.ObjectPermission;
|
||||
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||
|
||||
/**
|
||||
* Service which provides convenience methods for creating, retrieving, and
|
||||
@@ -111,13 +113,12 @@ public class ActiveConnectionService
|
||||
public void deleteObject(ModeledAuthenticatedUser user, String identifier)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Only administrators may delete active connections
|
||||
if (!user.getUser().isAdministrator())
|
||||
throw new GuacamoleSecurityException("Permission denied.");
|
||||
|
||||
// Close connection, if it exists (and we have permission)
|
||||
// Close connection, if it exists and we have permission
|
||||
ActiveConnection activeConnection = retrieveObject(user, identifier);
|
||||
if (activeConnection != null) {
|
||||
if (activeConnection == null)
|
||||
return;
|
||||
|
||||
if (hasObjectPermissions(user, identifier, ObjectPermission.Type.DELETE)) {
|
||||
|
||||
// Close connection if not already closed
|
||||
GuacamoleTunnel tunnel = activeConnection.getTunnel();
|
||||
@@ -125,6 +126,8 @@ public class ActiveConnectionService
|
||||
tunnel.close();
|
||||
|
||||
}
|
||||
else
|
||||
throw new GuacamoleSecurityException("Permission denied.");
|
||||
|
||||
}
|
||||
|
||||
@@ -162,4 +165,54 @@ public class ActiveConnectionService
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the permission set for the specified user that relates
|
||||
* to access to active connections.
|
||||
*
|
||||
* @param user
|
||||
* The user for which to retrieve the permission set.
|
||||
*
|
||||
* @return
|
||||
* A permission set associated with the given user that specifies
|
||||
* the permissions available for active connection objects.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If permission to read permissions for the user is denied.
|
||||
*/
|
||||
private ObjectPermissionSet getPermissionSet(ModeledAuthenticatedUser user)
|
||||
throws GuacamoleException {
|
||||
return user.getUser().getActiveConnectionPermissions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a boolean value representing whether or not a user has the given
|
||||
* permission available to them on the active connection with the given
|
||||
* identifier.
|
||||
*
|
||||
* @param user
|
||||
* The user for which the permissions are being queried.
|
||||
*
|
||||
* @param identifier
|
||||
* The identifier of the active connection we are wondering about.
|
||||
*
|
||||
* @param type
|
||||
* The type of permission being requested.
|
||||
*
|
||||
* @return
|
||||
* True if the user has the necessary permission; otherwise false.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If the user does not have access to read permissions.
|
||||
*/
|
||||
private boolean hasObjectPermissions(ModeledAuthenticatedUser user,
|
||||
String identifier, ObjectPermission.Type type)
|
||||
throws GuacamoleException {
|
||||
|
||||
ObjectPermissionSet permissionSet = getPermissionSet(user);
|
||||
|
||||
return user.getUser().isAdministrator()
|
||||
|| permissionSet.hasPermission(type, identifier);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -72,9 +72,11 @@ angular.module('navigation').factory('userPageService', ['$injector',
|
||||
|
||||
// If user has access to settings pages, return home page and skip
|
||||
// evaluation for automatic connections. The Preferences page is
|
||||
// a Settings page and is always visible, so we look for more than
|
||||
// one to indicate access to administrative pages.
|
||||
if (settingsPages.length > 1)
|
||||
// a Settings page and is always visible, and the Session management
|
||||
// page is also available to all users so that they can kill their
|
||||
// own session. We look for more than those two pages to determine
|
||||
// if we should go to the home page.
|
||||
if (settingsPages.length > 2)
|
||||
return SYSTEM_HOME_PAGE;
|
||||
|
||||
// Determine whether a connection or balancing group should serve as
|
||||
@@ -194,7 +196,6 @@ angular.module('navigation').factory('userPageService', ['$injector',
|
||||
var canManageUsers = [];
|
||||
var canManageConnections = [];
|
||||
var canViewConnectionRecords = [];
|
||||
var canManageSessions = [];
|
||||
|
||||
// Inspect the contents of each provided permission set
|
||||
angular.forEach(authenticationService.getAvailableDataSources(), function inspectPermissions(dataSource) {
|
||||
@@ -257,24 +258,21 @@ angular.module('navigation').factory('userPageService', ['$injector',
|
||||
canManageConnections.push(dataSource);
|
||||
}
|
||||
|
||||
// Determine whether the current user needs access to the session management UI or view connection history
|
||||
// Determine whether the current user needs access to view connection history
|
||||
if (
|
||||
// A user must be a system administrator to manage sessions
|
||||
// A user must be a system administrator to view connection records
|
||||
PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER)
|
||||
) {
|
||||
canManageSessions.push(dataSource);
|
||||
canViewConnectionRecords.push(dataSource);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// If user can manage sessions, add link to sessions management page
|
||||
if (canManageSessions.length) {
|
||||
pages.push(new PageDefinition({
|
||||
name : 'USER_MENU.ACTION_MANAGE_SESSIONS',
|
||||
url : '/settings/sessions'
|
||||
}));
|
||||
}
|
||||
// Add link to Session management (always accessible)
|
||||
pages.push(new PageDefinition({
|
||||
name : 'USER_MENU.ACTION_MANAGE_SESSIONS',
|
||||
url : '/settings/sessions'
|
||||
}));
|
||||
|
||||
// If user can manage connections, add links for connection management pages
|
||||
angular.forEach(canViewConnectionRecords, function addConnectionHistoryLink(dataSource) {
|
||||
|
@@ -189,12 +189,14 @@ angular.module('settings').directive('guacSettingsSessions', [function guacSetti
|
||||
var connection = allConnections[dataSource][activeConnection.connectionIdentifier];
|
||||
|
||||
// Add wrapper
|
||||
$scope.wrappers.push(new ActiveConnectionWrapper({
|
||||
dataSource : dataSource,
|
||||
name : connection.name,
|
||||
startDate : $filter('date')(activeConnection.startDate, sessionDateFormat),
|
||||
activeConnection : activeConnection
|
||||
}));
|
||||
if (activeConnection.username !== null) {
|
||||
$scope.wrappers.push(new ActiveConnectionWrapper({
|
||||
dataSource : dataSource,
|
||||
name : connection.name,
|
||||
startDate : $filter('date')(activeConnection.startDate, sessionDateFormat),
|
||||
activeConnection : activeConnection
|
||||
}));
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
|
||||
"language" : "es_ES",
|
||||
"type" : "qwerty",
|
||||
|
@@ -621,7 +621,7 @@
|
||||
|
||||
"FORMAT_STARTDATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
|
||||
|
||||
"HELP_SESSIONS" : "Alle aktiven Guacamole Sitzungen werden hier aufgelistet. Wenn Sie eine oder mehrere Sitzungen beenden wollen, wählen Sie diese Sitzung durch Aktivierung der nebenstehende Box und klicken auf \"Beende Sitzung\". Beendung einer Sitzung trennt den Benutzer von dessen Verbindung unverzüglich.",
|
||||
"HELP_SESSIONS" : "Diese Seite wird mit derzeit aktiven Verbindungen gefüllt. Die aufgelisteten Verbindungen und die Möglichkeit, diese Verbindungen zu beenden, hängen von Ihrer Zugriffsebene ab. Wenn Sie eine oder mehrere Sitzungen beenden wollen, wählen Sie diese Sitzung durch Aktivierung der nebenstehende Box und klicken auf \"Beende Sitzung\". Beendung einer Sitzung trennt den Benutzer von dessen Verbindung unverzüglich.",
|
||||
|
||||
"INFO_NO_SESSIONS" : "Keine aktiven Sitzungen",
|
||||
|
||||
|
@@ -750,7 +750,7 @@
|
||||
|
||||
"FORMAT_STARTDATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
|
||||
|
||||
"HELP_SESSIONS" : "All currently-active Guacamole sessions are listed here. If you wish to kill one or more sessions, check the box next to those sessions and click \"Kill Sessions\". Killing a session will immediately disconnect the user from the associated connection.",
|
||||
"HELP_SESSIONS" : "This page will be populated with currently-active connections. The connections listed and the ability to kill those connections is dependent upon your access level. If you wish to kill one or more sessions, check the box next to those sessions and click \"Kill Sessions\". Killing a session will immediately disconnect the user from the associated connection.",
|
||||
|
||||
"INFO_NO_SESSIONS" : "No active sessions",
|
||||
|
||||
|
@@ -695,7 +695,7 @@
|
||||
|
||||
"FORMAT_STARTDATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
|
||||
|
||||
"HELP_SESSIONS" : "Aquí se listan todas las sesiones activas que tiene actualmente Guacamole. Si quiere finalizar una o mas sesiones, marque la casilla correspondiente a esa/s sesión/es y haga clic en \"Finalizar Sesiones\". Si finaliza una sesión desconectará inmediatamente al usuario de la conexión asociada.",
|
||||
"HELP_SESSIONS" : "Esta página se completará con las conexiones actualmente activas. Las conexiones enumeradas y la capacidad de eliminar esas conexiones dependen de su nivel de acceso. Si quiere finalizar una o mas sesiones, marque la casilla correspondiente a esa/s sesión/es y haga clic en \"Finalizar Sesiones\". Si finaliza una sesión desconectará inmediatamente al usuario de la conexión asociada.",
|
||||
|
||||
"INFO_NO_SESSIONS" : "No hay sesiones activas",
|
||||
|
||||
|
@@ -624,7 +624,7 @@
|
||||
|
||||
"FORMAT_STARTDATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
|
||||
|
||||
"HELP_SESSIONS" : "Toutes les connexions actives Guacamole sont listées ici. Si vous souhaitez en fermer une ou plusieurs, sélectionner les et cliquer sur \"Fermer Sessions\". La fermeture d'une session déconnectera immédiatement l'utilisateur.",
|
||||
"HELP_SESSIONS" : "Cette page sera remplie avec des connexions actuellement actives. Les connexions répertoriées et la possibilité de supprimer ces connexions dépendent de votre niveau d'accès. Si vous souhaitez en fermer une ou plusieurs, sélectionner les et cliquer sur \"Fermer Sessions\". La fermeture d'une session déconnectera immédiatement l'utilisateur.",
|
||||
|
||||
"INFO_NO_SESSIONS" : "Pas de session ouverte",
|
||||
|
||||
|
@@ -566,7 +566,7 @@
|
||||
|
||||
"FORMAT_STARTDATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
|
||||
|
||||
"HELP_SESSIONS" : "All currently-active Guacamole sessions are listed here. If you wish to kill one or more sessions, check the box next to those sessions and click \"Kill Sessions\". Killing a session will immediately disconnect the user from the associated connection.",
|
||||
"HELP_SESSIONS" : "Questa pagina verrà popolata con connessioni attualmente attive. Le connessioni elencate e la possibilità di uccidere tali connessioni dipende dal tuo livello di accesso. Se desideri uccidere una o più sessioni, seleziona la casella accanto a quelle sessioni e fai clic su \"Uccidi sessioni \". L'uccisione di una sessione interromperà immediatamente l'utente dalla connessione associata.",
|
||||
|
||||
"INFO_NO_SESSIONS" : "Nessuna sessione attiva",
|
||||
|
||||
|
@@ -654,7 +654,7 @@
|
||||
|
||||
"FORMAT_STARTDATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
|
||||
|
||||
"HELP_SESSIONS" : "Alle Guacamole sessies die op dit moment actief zijn worden hier getoond. Als u een of meerdere sessies wilt beeindigen, vink die sessie(s) dan aan en klik op \"Beeindig Sessies\". Door het verbreken van een sessie verliest de gebruiker ogenblikkelijk het contact met die sessie(s).",
|
||||
"HELP_SESSIONS" : "Deze pagina wordt gevuld met momenteel actieve verbindingen. De vermelde verbindingen en de mogelijkheid om die verbindingen te doden, zijn afhankelijk van uw toegangsniveau. Als u een of meerdere sessies wilt beeindigen, vink die sessie(s) dan aan en klik op \"Beeindig Sessies\". Door het verbreken van een sessie verliest de gebruiker ogenblikkelijk het contact met die sessie(s).",
|
||||
|
||||
"INFO_NO_SESSIONS" : "Geen actieve sessies",
|
||||
|
||||
|
@@ -635,7 +635,7 @@
|
||||
|
||||
"FORMAT_STARTDATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
|
||||
|
||||
"HELP_SESSIONS" : "Alle aktive Guacamolesesjoner er listet opp her. Dersom du ønsker å avbryte en eller flere sesjoner haker du av boksen ved siden av sesjonen og klikker \"Avbryt sesjoner\". Avbrytes en sesjon vil brukeren umiddelbart kobles av den aktuelle sesjonen.",
|
||||
"HELP_SESSIONS" : "Denne siden vil bli fylt med nåværende aktive forbindelser. Tilkoblingene oppført og evnen til å drepe disse tilkoblingene er avhengig av tilgangsnivået ditt. Dersom du ønsker å avbryte en eller flere sesjoner haker du av boksen ved siden av sesjonen og klikker \"Avbryt sesjoner\". Avbrytes en sesjon vil brukeren umiddelbart kobles av den aktuelle sesjonen.",
|
||||
|
||||
"INFO_NO_SESSIONS" : "Ingen aktive sesjoner",
|
||||
|
||||
|
@@ -547,7 +547,7 @@
|
||||
|
||||
"FORMAT_STARTDATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
|
||||
|
||||
"HELP_SESSIONS" : "Все активные в настоящий момент сессии Guacamole представлены здесь. Если вы хотите завершить одну или несколько сессий, выберите нужные сессии и нажмите на \"Завершить сессии\". Принудительное завершение сессий приведет к немедленному отключению пользователей, которые ими пользуются.",
|
||||
"HELP_SESSIONS" : "Эта страница будет заполнена активными в настоящее время соединениями. Перечисленные соединения и возможность убивать эти соединения зависят от вашего уровня доступа. Если вы хотите завершить одну или несколько сессий, выберите нужные сессии и нажмите на \"Завершить сессии\". Принудительное завершение сессий приведет к немедленному отключению пользователей, которые ими пользуются.",
|
||||
|
||||
"INFO_NO_SESSIONS" : "Нет активных сессий",
|
||||
|
||||
|
@@ -732,7 +732,7 @@
|
||||
|
||||
"FORMAT_STARTDATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
|
||||
|
||||
"HELP_SESSIONS" : "下表中是所有当前活动的Guacamole会话。如需终止一个或多个会话,勾选目标会话并点击“终止会话”。终止会话会立即断开对应用户的连接。",
|
||||
"HELP_SESSIONS" : "该页面将填充当前活动的连接。 列出的连接和终止连接的能力取决于您的访问级别。如需终止一个或多个会话,勾选目标会话并点击“终止会话”。终止会话会立即断开对应用户的连接。",
|
||||
|
||||
"INFO_NO_SESSIONS" : "无活动会话",
|
||||
|
||||
|
Reference in New Issue
Block a user