* [pve-devel] [PATCH proxmox-widget-toolkit v2 1/3] fix #4546: css: create a new css class for warning texts
2023-10-10 10:40 [pve-devel] [PATCH proxmox-widget-toolkit/manager/access-control v2 0/5] fix #4546: Show warning hint/badge if user account is expiring in next few days Philipp Hufnagl
@ 2023-10-10 10:40 ` Philipp Hufnagl
2023-10-10 10:40 ` [pve-devel] [PATCH proxmox-widget-toolkit v2 2/3] fix #4546: utils: Highlight accounts in user management that exprie soon Philipp Hufnagl
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Philipp Hufnagl @ 2023-10-10 10:40 UTC (permalink / raw)
To: pve-devel
Creates a new css class 'text-color-warning' for the dark theme, which
will be used to propperly show a warning icon later. For this purpose
the 'pwt-gauge-warn' color is extracted in a variable and reused. Also
the variable 'pwd-gauge-crit' has been extracted for consistency.
Signed-off-by: Philipp Hufnagl <p.hufnagl@proxmox.com>
---
.../scss/abstracts/_variables.scss | 20 ++++++++++---------
| 4 ++++
src/proxmox-dark/scss/other/_charts.scss | 4 ++--
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/src/proxmox-dark/scss/abstracts/_variables.scss b/src/proxmox-dark/scss/abstracts/_variables.scss
index cac51eb..cf7cda4 100644
--- a/src/proxmox-dark/scss/abstracts/_variables.scss
+++ b/src/proxmox-dark/scss/abstracts/_variables.scss
@@ -8,9 +8,20 @@ $highlighted-text: hsl(205deg, 100%, 65%);
$highlighted-text-alt: hsl(205deg, 100%, 80%);
$highlighted-text-crit: hsl(360deg, 100%, 65%);
+// Backgrounds
+$content-background-color: hsl(0deg, 0%, 20%);
+$content-background-selected: hsl(0deg, 0%, 30%);
+$background-dark: hsl(0deg, 0%, 20%);
+$background-darker: hsl(0deg, 0%, 15%);
+$background-darkest: hsl(0deg, 0%, 10%);
+$background-invalid: hsl(360deg, 60%, 20%);
+$background-warning: hsl(40deg, 100%, 20%);
+
// Icon and Text colors
$text-color: hsl(0deg, 0%, 95%);
$text-color-inactive: hsl(0deg, 0%, 60%);
+$text-color-warning: adjust-color($background-warning, $lightness: lightness($primary-color));
+$text-color-invalid: adjust-color($background-invalid, $lightness: lightness($primary-color));
$icon-color: hsl(0deg, 0%, 90%);
$icon-color-alt: hsl(0deg, 0%, 55%);
@@ -18,15 +29,6 @@ $icon-color-alt: hsl(0deg, 0%, 55%);
$border-color: hsl(0deg, 0%, 40%);
$border-color-alt: hsl(0deg, 0%, 25%);
-// Backgrounds
-$content-background-color: hsl(0deg, 0%, 20%);
-$content-background-selected: hsl(0deg, 0%, 30%);
-$background-dark: hsl(0deg, 0%, 20%);
-$background-darker: hsl(0deg, 0%, 15%);
-$background-darkest: hsl(0deg, 0%, 10%);
-$background-invalid: hsl(360deg, 60%, 20%);
-$background-warning: hsl(40deg, 100%, 20%);
-
// Buttons
$neutral-button-color: hsl(0deg, 0%, 25%);
$neutral-button-color-alt: hsl(0deg, 0%, 35%);
--git a/src/proxmox-dark/scss/extjs/_menu.scss b/src/proxmox-dark/scss/extjs/_menu.scss
index 2983f60..aa51260 100644
--- a/src/proxmox-dark/scss/extjs/_menu.scss
+++ b/src/proxmox-dark/scss/extjs/_menu.scss
@@ -33,6 +33,10 @@
color: $icon-color;
}
+.x-menu-item-icon-default.warning {
+ color: $text-color-warning;
+}
+
// Vertical divider (e.g. in UserInfo between icons and text)
.x-menu-icon-separator-default {
background-color: $background-dark;
diff --git a/src/proxmox-dark/scss/other/_charts.scss b/src/proxmox-dark/scss/other/_charts.scss
index 26b0104..a3a5b12 100644
--- a/src/proxmox-dark/scss/other/_charts.scss
+++ b/src/proxmox-dark/scss/other/_charts.scss
@@ -7,8 +7,8 @@
--pwt-text-color: #{$text-color};
--pwt-gauge-default: #{$primary-color};
--pwt-gauge-back: #{$background-dark};
- --pwt-gauge-warn: #{adjust-color($background-warning, $lightness: lightness($primary-color))};
- --pwt-gauge-crit: #{adjust-color($background-invalid, $lightness: lightness($primary-color))};
+ --pwt-gauge-warn: #{$text-color-warning};
+ --pwt-gauge-crit: #{$text-color-invalid};
--pwt-chart-primary: #{$primary-color};
--pwt-chart-grid-stroke: #{$content-background-selected};
}
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] [PATCH proxmox-widget-toolkit v2 2/3] fix #4546: utils: Highlight accounts in user management that exprie soon
2023-10-10 10:40 [pve-devel] [PATCH proxmox-widget-toolkit/manager/access-control v2 0/5] fix #4546: Show warning hint/badge if user account is expiring in next few days Philipp Hufnagl
2023-10-10 10:40 ` [pve-devel] [PATCH proxmox-widget-toolkit v2 1/3] fix #4546: css: create a new css class for warning texts Philipp Hufnagl
@ 2023-10-10 10:40 ` Philipp Hufnagl
2023-10-10 10:40 ` [pve-devel] [PATCH proxmox-widget-toolkit v2 3/3] fix #4546: utils: Expand authentication data with account expiry date Philipp Hufnagl
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Philipp Hufnagl @ 2023-10-10 10:40 UTC (permalink / raw)
To: pve-devel
When a user account is about to expire in the next 7 days, the date
column will be highlighted with warning color.
Signed-off-by: Philipp Hufnagl <p.hufnagl@proxmox.com>
---
src/Utils.js | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/Utils.js b/src/Utils.js
index f269607..f5769a0 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -174,10 +174,14 @@ utilities: {
return value ? Proxmox.Utils.enabledText : Proxmox.Utils.disabledText;
},
- format_expire: function(date) {
+ format_expire: function(date, meta) {
if (!date) {
return Proxmox.Utils.neverText;
}
+ let expiryWarningThreshold = Ext.Date.add(new Date(), Ext.Date.DAY, 7);
+ if (expiryWarningThreshold >= date) {
+ meta.tdCls += 'proxmox-warning-row';
+ }
return Ext.Date.format(date, "Y-m-d");
},
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] [PATCH proxmox-widget-toolkit v2 3/3] fix #4546: utils: Expand authentication data with account expiry date
2023-10-10 10:40 [pve-devel] [PATCH proxmox-widget-toolkit/manager/access-control v2 0/5] fix #4546: Show warning hint/badge if user account is expiring in next few days Philipp Hufnagl
2023-10-10 10:40 ` [pve-devel] [PATCH proxmox-widget-toolkit v2 1/3] fix #4546: css: create a new css class for warning texts Philipp Hufnagl
2023-10-10 10:40 ` [pve-devel] [PATCH proxmox-widget-toolkit v2 2/3] fix #4546: utils: Highlight accounts in user management that exprie soon Philipp Hufnagl
@ 2023-10-10 10:40 ` Philipp Hufnagl
2023-10-10 10:40 ` [pve-devel] [PATCH proxmox-widget-toolkit v2 1/1] fix #4546: ui: notify user if there usser account expires soon Philipp Hufnagl
2023-10-10 10:40 ` [pve-devel] [PATCH access-control v2 1/1] fix #4546: api: Return user expiration date on access/ticket API call Philipp Hufnagl
4 siblings, 0 replies; 6+ messages in thread
From: Philipp Hufnagl @ 2023-10-10 10:40 UTC (permalink / raw)
To: pve-devel
When the authentication data of a session are set, the account expiry
date will be set also (provided there is one).
Signed-off-by: Philipp Hufnagl <p.hufnagl@proxmox.com>
---
src/Utils.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/Utils.js b/src/Utils.js
index f5769a0..654c907 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -309,6 +309,9 @@ utilities: {
setAuthData: function(data) {
Proxmox.UserName = data.username;
+ if (data['account-expiry-date']) {
+ Proxmox.AccountExpiryDate = data['account-expiry-date'];
+ }
Proxmox.LoggedOut = data.LoggedOut;
// creates a session cookie (expire = null)
// that way the cookie gets deleted after the browser window is closed
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] [PATCH proxmox-widget-toolkit v2 1/1] fix #4546: ui: notify user if there usser account expires soon
2023-10-10 10:40 [pve-devel] [PATCH proxmox-widget-toolkit/manager/access-control v2 0/5] fix #4546: Show warning hint/badge if user account is expiring in next few days Philipp Hufnagl
` (2 preceding siblings ...)
2023-10-10 10:40 ` [pve-devel] [PATCH proxmox-widget-toolkit v2 3/3] fix #4546: utils: Expand authentication data with account expiry date Philipp Hufnagl
@ 2023-10-10 10:40 ` Philipp Hufnagl
2023-10-10 10:40 ` [pve-devel] [PATCH access-control v2 1/1] fix #4546: api: Return user expiration date on access/ticket API call Philipp Hufnagl
4 siblings, 0 replies; 6+ messages in thread
From: Philipp Hufnagl @ 2023-10-10 10:40 UTC (permalink / raw)
To: pve-devel
When the user account that is currently logged in will expire soon, the
user icon will turn into a yellow exclamation mark. In the user menu
there will be a new element informing the user briefly about it. If the
element is clicked, a popup will appear informing the user in detail
about it
Signed-off-by: Philipp Hufnagl <p.hufnagl@proxmox.com>
---
www/manager6/Workspace.js | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/www/manager6/Workspace.js b/www/manager6/Workspace.js
index 18d574b7..41d44a00 100644
--- a/www/manager6/Workspace.js
+++ b/www/manager6/Workspace.js
@@ -42,6 +42,7 @@ Ext.define('PVE.Workspace', {
Proxmox.Utils.authClear();
Ext.state.Manager.clear('GuiCap');
Proxmox.UserName = null;
+ Proxmox.AccountExpiryDate = null;
me.loginData = null;
if (!me.login) {
@@ -198,6 +199,18 @@ Ext.define('PVE.StdWorkspace', {
let me = this;
let ui = me.query('#userinfo')[0];
ui.setText(Ext.String.htmlEncode(Proxmox.UserName || ''));
+ let label = me.query('#expirewarning')[0];
+ if (Proxmox.AccountExpiryDate !== null) {
+ let expiryWarningThreshold = Ext.Date.add(new Date(), Ext.Date.DAY, 7);
+ let expireDate = new Date(Proxmox.AccountExpiryDate * 1000);
+ if (expiryWarningThreshold >= expireDate) {
+ ui.setIconCls('fa fa-exclamation-triangle warning');
+ label.setHidden(false);
+ }
+ } else {
+ label.setHidden(true);
+ ui.setIconCls('fa fa-user');
+ }
ui.updateLayout();
},
@@ -367,6 +380,21 @@ Ext.define('PVE.StdWorkspace', {
},
iconCls: 'fa fa-user',
menu: [
+ {
+ iconCls: 'fa fa-exclamation-triangle warning',
+ itemId: 'expirewarning',
+ text: gettext('Account expiring soon!'),
+ hidden: true,
+ handler: function() {
+ let expireDate = new Date(Proxmox.AccountExpiryDate * 1000);
+ Ext.Msg.show({
+ title: gettext('Account expiring soon!'),
+ icon: Ext.Msg.WARNING,
+ message: Ext.String.format(gettext("Your account is expiring on {0} . After that you won't be able to log in!"), expireDate),
+ buttons: Ext.Msg.OK,
+ });
+ },
+ },
{
iconCls: 'fa fa-gear',
text: gettext('My Settings'),
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] [PATCH access-control v2 1/1] fix #4546: api: Return user expiration date on access/ticket API call
2023-10-10 10:40 [pve-devel] [PATCH proxmox-widget-toolkit/manager/access-control v2 0/5] fix #4546: Show warning hint/badge if user account is expiring in next few days Philipp Hufnagl
` (3 preceding siblings ...)
2023-10-10 10:40 ` [pve-devel] [PATCH proxmox-widget-toolkit v2 1/1] fix #4546: ui: notify user if there usser account expires soon Philipp Hufnagl
@ 2023-10-10 10:40 ` Philipp Hufnagl
4 siblings, 0 replies; 6+ messages in thread
From: Philipp Hufnagl @ 2023-10-10 10:40 UTC (permalink / raw)
To: pve-devel
Adds an additional, optional parameter to the access/tickets api call
which tells when the currently used user account will expire. If it will
not expire, the parameter will not be added.
Signed-off-by: Philipp Hufnagl <p.hufnagl@proxmox.com>
---
src/PVE/API2/AccessControl.pm | 8 ++++++++
src/PVE/AccessControl.pm | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/src/PVE/API2/AccessControl.pm b/src/PVE/API2/AccessControl.pm
index 74b3910..caba720 100644
--- a/src/PVE/API2/AccessControl.pm
+++ b/src/PVE/API2/AccessControl.pm
@@ -267,6 +267,11 @@ __PACKAGE__->register_method ({
ticket => { type => 'string', optional => 1},
CSRFPreventionToken => { type => 'string', optional => 1 },
clustername => { type => 'string', optional => 1 },
+ 'account-expiry-date' => {
+ type => 'number',
+ description => "Account expiration date as a UNIX timestamp",
+ optional => 1 ,
+ },
# cap => computed api permissions, unless there's a u2f challenge
}
},
@@ -304,6 +309,9 @@ __PACKAGE__->register_method ({
die PVE::Exception->new("authentication failure\n", code => 401);
}
+ my $expires = PVE::AccessControl::lookup_user_expiration($username);
+ $res->{'account-expiry-date'} = $expires if defined($expires);
+
$res->{cap} = $rpcenv->compute_api_permission($username)
if !defined($res->{NeedTFA});
diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm
index cc0f00b..b30570b 100644
--- a/src/PVE/AccessControl.pm
+++ b/src/PVE/AccessControl.pm
@@ -1234,6 +1234,14 @@ sub lookup_username {
return $username;
}
+sub lookup_user_expiration {
+ my ($username) = @_;
+ my $usercfg = cfs_read_file('user.cfg');
+ my $expires = $usercfg->{users}->{$username}->{expire};
+ return undef if $expires == 0;
+ return $expires;
+}
+
sub normalize_path {
my $path = shift;
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread