Extend accessibility check.
This commit is contained in:
parent
dfe3038463
commit
28b1903acc
4 changed files with 30 additions and 6 deletions
|
|
@ -377,10 +377,34 @@ public class VmDefinition extends K8sDynamicModel {
|
||||||
* @param permissions the permissions
|
* @param permissions the permissions
|
||||||
* @return true, if successful
|
* @return true, if successful
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("PMD.SimplifyBooleanReturns")
|
||||||
public boolean consoleAccessible(String user, Set<Permission> permissions) {
|
public boolean consoleAccessible(String user, Set<Permission> permissions) {
|
||||||
return !conditionStatus("ConsoleConnected").orElse(true)
|
// If user has takeConsole permission, console is always accessible
|
||||||
|| consoleUser().map(cu -> cu.equals(user)).orElse(true)
|
if (permissions.contains(VmDefinition.Permission.TAKE_CONSOLE)) {
|
||||||
|| permissions.contains(VmDefinition.Permission.TAKE_CONSOLE);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if an automatic login is requested. If so, allow access only
|
||||||
|
// if the log in has been established
|
||||||
|
var wantedLogIn = DataPath.<String> get(spec(), "vm", "display",
|
||||||
|
"loggedInUser").orElse(null);
|
||||||
|
if (wantedLogIn != null
|
||||||
|
&& !wantedLogIn.equals(status().get(Status.LOGGED_IN_USER))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the console is not in use, allow access
|
||||||
|
if (!conditionStatus("ConsoleConnected").orElse(true)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the console is in use by the user, allow access
|
||||||
|
if (consoleUser().map(cu -> cu.equals(user)).orElse(true)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Else deny access
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,5 @@ okayLabel = Apply and Close
|
||||||
confirmResetTitle = Confirm reset
|
confirmResetTitle = Confirm reset
|
||||||
confirmResetMsg = Resetting the VM may cause loss of data. \
|
confirmResetMsg = Resetting the VM may cause loss of data. \
|
||||||
Please confirm to continue.
|
Please confirm to continue.
|
||||||
consoleTakenNotification = Console access is locked by another user.
|
consoleInaccessibleNotification = Console is not ready or in use.
|
||||||
poolEmptyNotification = No VM available. Please consult your administrator.
|
poolEmptyNotification = No VM available. Please consult your administrator.
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ Open\ console = Konsole anzeigen
|
||||||
confirmResetTitle = Zurücksetzen bestätigen
|
confirmResetTitle = Zurücksetzen bestätigen
|
||||||
confirmResetMsg = Zurücksetzen der VM kann zu Datenverlust führen. \
|
confirmResetMsg = Zurücksetzen der VM kann zu Datenverlust führen. \
|
||||||
Bitte bestätigen um fortzufahren.
|
Bitte bestätigen um fortzufahren.
|
||||||
consoleTakenNotification = Die Konsole wird von einem anderen Benutzer verwendet.
|
consoleInaccessibleNotification = Die Konsole ist nicht bereit oder belegt.
|
||||||
poolEmptyNotification = Keine VM verfügbar. Wenden Sie sich bitte an den \
|
poolEmptyNotification = Keine VM verfügbar. Wenden Sie sich bitte an den \
|
||||||
Systemadministrator.
|
Systemadministrator.
|
||||||
|
|
||||||
|
|
@ -804,7 +804,7 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
|
||||||
.map(ConsoleUser::getName).orElse("");
|
.map(ConsoleUser::getName).orElse("");
|
||||||
if (!vmDef.consoleAccessible(user, perms)) {
|
if (!vmDef.consoleAccessible(user, perms)) {
|
||||||
channel.respond(new DisplayNotification(
|
channel.respond(new DisplayNotification(
|
||||||
resourceBundle.getString("consoleTakenNotification"),
|
resourceBundle.getString("consoleInaccessibleNotification"),
|
||||||
Map.of("autoClose", 5_000, "type", "Warning")));
|
Map.of("autoClose", 5_000, "type", "Warning")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue