all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH cluster/docs/manager/widget-toolkit v3 0/4] fix #5463: add optional Consent Banner on login
@ 2024-12-10 16:11 Gabriel Goller
  2024-12-10 16:11 ` [pve-devel] [PATCH manager v3 1/4] show optional consent-banner before login Gabriel Goller
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Gabriel Goller @ 2024-12-10 16:11 UTC (permalink / raw)
  To: pve-devel

The consent text is stored in the datacenter.cfg file and is encoded
using base64. This allows us to support multi-line strings and special
characters. To easily edit the text the existing edit-field
ProxmoxTextAreaField is used. It supports editing and saving
multi-line text and converting it to its base64 representation.

This is the port from the initial PBS implementation and should work
in the same way.

v3:
 - limit max characters in backend as well
   - set a limit of 63*1024 in the frontend (a bit less than max request body size)
   - set a limit of 128kB in the backend

v2, thanks @Thomas:
 - limit max characters for consent-text (24000)
 - wrap datacenter config read in eval
 - fix js indentation
 - remove Ext.htmlEncode (this is done by Markdown.parse)

manager:

Gabriel Goller (1):
  show optional consent-banner before login

 PVE/Service/pveproxy.pm            | 13 ++++++++++---
 www/index.html.tpl                 |  3 ++-
 www/manager6/dc/OptionView.js      |  8 ++++++++
 www/manager6/window/LoginWindow.js | 12 +++++++++++-
 4 files changed, 31 insertions(+), 5 deletions(-)


cluster:

Gabriel Goller (1):
  add consent-text parameter to datacenter config file

 src/PVE/DataCenterConfig.pm | 6 ++++++
 1 file changed, 6 insertions(+)


docs:

Gabriel Goller (1):
  add consent-banner description

 pve-gui.adoc | 9 +++++++++
 1 file changed, 9 insertions(+)


widget-toolkit:

Gabriel Goller (1):
  form: set enforceMaxLength on textareafield

 src/form/TextAreaField.js | 1 +
 1 file changed, 1 insertion(+)


Summary over all repositories:
  7 files changed, 47 insertions(+), 5 deletions(-)

-- 
Generated by git-murpp 0.7.1


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pve-devel] [PATCH manager v3 1/4] show optional consent-banner before login
  2024-12-10 16:11 [pve-devel] [PATCH cluster/docs/manager/widget-toolkit v3 0/4] fix #5463: add optional Consent Banner on login Gabriel Goller
@ 2024-12-10 16:11 ` Gabriel Goller
  2025-04-04 18:16   ` [pve-devel] applied: " Thomas Lamprecht
  2024-12-10 16:11 ` [pve-devel] [PATCH cluster v3 2/4] add consent-text parameter to datacenter config file Gabriel Goller
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Gabriel Goller @ 2024-12-10 16:11 UTC (permalink / raw)
  To: pve-devel

Add ConsentBanner variable to html template and populate it from the
`datacenter.cfg` config file. Add Datacenter option to set the text and
trigger the popup on login. The max length of the input is 63*1024,
which is a bit less than the max body size for a api request (64*1024).

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 PVE/Service/pveproxy.pm            | 13 ++++++++++---
 www/index.html.tpl                 |  3 ++-
 www/manager6/dc/OptionView.js      |  8 ++++++++
 www/manager6/window/LoginWindow.js | 12 +++++++++++-
 4 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/PVE/Service/pveproxy.pm b/PVE/Service/pveproxy.pm
index ac1085457f2e..b5bfd34ca3aa 100755
--- a/PVE/Service/pveproxy.pm
+++ b/PVE/Service/pveproxy.pm
@@ -218,10 +218,16 @@ sub get_index {
 	}
     }
 
-    if (!$lang) {
+    my $consent_text;
+    eval {
 	my $dc_conf = PVE::Cluster::cfs_read_file('datacenter.cfg');
-	$lang = $dc_conf->{language} // 'en';
-    }
+	$consent_text = $dc_conf->{'consent-text'};
+
+	if (!$lang) {
+	    $lang = $dc_conf->{language} // 'en';
+	}
+    };
+    warn "$@\n" if $@;
 
     my $mobile = (is_phone($r->header('User-Agent')) && (!defined($args->{mobile}) || $args->{mobile})) || $args->{mobile};
 
@@ -251,6 +257,7 @@ sub get_index {
 	version => "$version",
 	wtversion => $wtversion,
 	theme => $theme,
+	consenttext => $consent_text
     };
 
     # by default, load the normal index
diff --git a/www/index.html.tpl b/www/index.html.tpl
index 46dc877bcaf2..d53a867522dd 100644
--- a/www/index.html.tpl
+++ b/www/index.html.tpl
@@ -41,7 +41,8 @@
 	defaultLang: '[% lang %]',
 	NodeName: '[% nodename %]',
 	UserName: '[% username %]',
-	CSRFPreventionToken: '[% token %]'
+	CSRFPreventionToken: '[% token %]',
+	ConsentText: '[% consenttext %]'
     };
     </script>
     <script type="text/javascript" src="/proxmoxlib.js?ver=[% wtversion %]"></script>
diff --git a/www/manager6/dc/OptionView.js b/www/manager6/dc/OptionView.js
index b200fd12dcc9..02e640d88f60 100644
--- a/www/manager6/dc/OptionView.js
+++ b/www/manager6/dc/OptionView.js
@@ -516,6 +516,14 @@ Ext.define('PVE.dc.OptionView', {
 	    },
 	};
 
+	me.add_textareafield_row('consent-text', gettext('Consent Text'), {
+	    deleteEmpty: true,
+	    fieldOpts: {
+		maxLength: 63 * 1024,
+	    },
+	    onlineHelp: 'consent_banner',
+	});
+
 	me.selModel = Ext.create('Ext.selection.RowModel', {});
 
 	Ext.apply(me, {
diff --git a/www/manager6/window/LoginWindow.js b/www/manager6/window/LoginWindow.js
index aaeca3550289..b4dff0c19ac1 100644
--- a/www/manager6/window/LoginWindow.js
+++ b/www/manager6/window/LoginWindow.js
@@ -18,9 +18,19 @@ Ext.define('PVE.window.LoginWindow', {
     },
 
     controller: {
-
 	xclass: 'Ext.app.ViewController',
 
+	init: async function() {
+	    if (Proxmox.ConsentText) {
+		Ext.create("Proxmox.window.ConsentModal", {
+		    autoShow: true,
+		    consent: Proxmox.Markdown.parse(
+			Proxmox.Utils.base64ToUtf8(Proxmox.ConsentText),
+		    ),
+		});
+	    }
+	},
+
 	onLogon: async function() {
 	    var me = this;
 
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pve-devel] [PATCH cluster v3 2/4] add consent-text parameter to datacenter config file
  2024-12-10 16:11 [pve-devel] [PATCH cluster/docs/manager/widget-toolkit v3 0/4] fix #5463: add optional Consent Banner on login Gabriel Goller
  2024-12-10 16:11 ` [pve-devel] [PATCH manager v3 1/4] show optional consent-banner before login Gabriel Goller
@ 2024-12-10 16:11 ` Gabriel Goller
  2025-04-04 17:09   ` [pve-devel] applied: " Thomas Lamprecht
  2024-12-10 16:11 ` [pve-devel] [PATCH docs v3 3/4] add consent-banner description Gabriel Goller
  2024-12-10 16:11 ` [pve-devel] [PATCH widget-toolkit v3 4/4] form: set enforceMaxLength on textareafield Gabriel Goller
  3 siblings, 1 reply; 10+ messages in thread
From: Gabriel Goller @ 2024-12-10 16:11 UTC (permalink / raw)
  To: pve-devel

The consent-text parameter is the base64-encoded content of the optional
consent-banner which can be displayed before login. The limit is 128kB,
which is less than the pmxcfs file limit, but still enough to also
encode images.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/DataCenterConfig.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/PVE/DataCenterConfig.pm b/src/PVE/DataCenterConfig.pm
index abd0bbfd4532..9d1c02726637 100644
--- a/src/PVE/DataCenterConfig.pm
+++ b/src/PVE/DataCenterConfig.pm
@@ -449,6 +449,12 @@ my $datacenter_schema = {
 	    pattern => "(?:${PVE::JSONSchema::PVE_TAG_RE};)*${PVE::JSONSchema::PVE_TAG_RE}",
 	    typetext => "<tag>[;<tag>...]",
 	},
+	'consent-text' => {
+	    optional => 1,
+	    type => 'string',
+	    maxLength => 128000,
+	    description => "Consent text that is displayed before logging in."
+	},
     },
 };
 
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pve-devel] [PATCH docs v3 3/4] add consent-banner description
  2024-12-10 16:11 [pve-devel] [PATCH cluster/docs/manager/widget-toolkit v3 0/4] fix #5463: add optional Consent Banner on login Gabriel Goller
  2024-12-10 16:11 ` [pve-devel] [PATCH manager v3 1/4] show optional consent-banner before login Gabriel Goller
  2024-12-10 16:11 ` [pve-devel] [PATCH cluster v3 2/4] add consent-text parameter to datacenter config file Gabriel Goller
@ 2024-12-10 16:11 ` Gabriel Goller
  2025-04-04 18:06   ` [pve-devel] applied: " Thomas Lamprecht
  2024-12-10 16:11 ` [pve-devel] [PATCH widget-toolkit v3 4/4] form: set enforceMaxLength on textareafield Gabriel Goller
  3 siblings, 1 reply; 10+ messages in thread
From: Gabriel Goller @ 2024-12-10 16:11 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 pve-gui.adoc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/pve-gui.adoc b/pve-gui.adoc
index 8a04bd977796..4eef5cc1b56d 100644
--- a/pve-gui.adoc
+++ b/pve-gui.adoc
@@ -453,6 +453,15 @@ edited under __Datacenter -> Options -> Registered Tags__ or via the CLI.
 For more details on the exact options and how to invoke them in the CLI, see
 xref:datacenter_configuration_file[Datacenter Configuration].
 
+[[consent_banner]]
+Consent Banner
+------------
+
+A custom consent banner that has to be accepted before login can be configured
+in __Datacenter -> Options -> Consent Text__. If there is no
+content, the consent banner will not be displayed. The text will be stored as a
+base64 string in the `/etc/pve/datacenter.cfg` config file.
+
 ifdef::wiki[]
 
 See Also
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pve-devel] [PATCH widget-toolkit v3 4/4] form: set enforceMaxLength on textareafield
  2024-12-10 16:11 [pve-devel] [PATCH cluster/docs/manager/widget-toolkit v3 0/4] fix #5463: add optional Consent Banner on login Gabriel Goller
                   ` (2 preceding siblings ...)
  2024-12-10 16:11 ` [pve-devel] [PATCH docs v3 3/4] add consent-banner description Gabriel Goller
@ 2024-12-10 16:11 ` Gabriel Goller
  2025-02-26 17:59   ` Thomas Lamprecht
  3 siblings, 1 reply; 10+ messages in thread
From: Gabriel Goller @ 2024-12-10 16:11 UTC (permalink / raw)
  To: pve-devel

This allows us to set `maxLength` on it. `enforceMaxLength` will force
extjs to set the `maxLength` property on the underlying inputfield.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/form/TextAreaField.js | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/form/TextAreaField.js b/src/form/TextAreaField.js
index 267b40c87d74..b0092510c019 100644
--- a/src/form/TextAreaField.js
+++ b/src/form/TextAreaField.js
@@ -10,6 +10,7 @@ Ext.define('Proxmox.form.field.Base64TextArea', {
         width: 600,
         height: 400,
         scrollable: 'y',
+        enforceMaxLength: true,
     },
 
     setValue: function(value) {
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [pve-devel] [PATCH widget-toolkit v3 4/4] form: set enforceMaxLength on textareafield
  2024-12-10 16:11 ` [pve-devel] [PATCH widget-toolkit v3 4/4] form: set enforceMaxLength on textareafield Gabriel Goller
@ 2025-02-26 17:59   ` Thomas Lamprecht
  2025-02-27 12:37     ` Gabriel Goller
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Lamprecht @ 2025-02-26 17:59 UTC (permalink / raw)
  To: Proxmox VE development discussion, Gabriel Goller

Am 10.12.24 um 17:11 schrieb Gabriel Goller:
> This allows us to set `maxLength` on it. `enforceMaxLength` will force
> extjs to set the `maxLength` property on the underlying inputfield.
> 

isn't it enough to make the field invalid?

It might not be a big problem in practice here, but personally I find
it slightly infuriating if there is a hard blocker for going over a text
length limit, as that makes restructuring the text to a shorter variant
harder to do, as there it's often useful to be able to (temporarily) write
a longer text as what it's allowed to submit.


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [pve-devel] [PATCH widget-toolkit v3 4/4] form: set enforceMaxLength on textareafield
  2025-02-26 17:59   ` Thomas Lamprecht
@ 2025-02-27 12:37     ` Gabriel Goller
  0 siblings, 0 replies; 10+ messages in thread
From: Gabriel Goller @ 2025-02-27 12:37 UTC (permalink / raw)
  To: Thomas Lamprecht; +Cc: Proxmox VE development discussion

On 26.02.2025 18:59, Thomas Lamprecht wrote:
>Am 10.12.24 um 17:11 schrieb Gabriel Goller:
>> This allows us to set `maxLength` on it. `enforceMaxLength` will force
>> extjs to set the `maxLength` property on the underlying inputfield.
>>
>
>isn't it enough to make the field invalid?
>
>It might not be a big problem in practice here, but personally I find
>it slightly infuriating if there is a hard blocker for going over a text
>length limit, as that makes restructuring the text to a shorter variant
>harder to do, as there it's often useful to be able to (temporarily) write
>a longer text as what it's allowed to submit.

Agreed. We can drop the last patch.



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pve-devel] applied: [PATCH cluster v3 2/4] add consent-text parameter to datacenter config file
  2024-12-10 16:11 ` [pve-devel] [PATCH cluster v3 2/4] add consent-text parameter to datacenter config file Gabriel Goller
@ 2025-04-04 17:09   ` Thomas Lamprecht
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Lamprecht @ 2025-04-04 17:09 UTC (permalink / raw)
  To: Proxmox VE development discussion, Gabriel Goller

Am 10.12.24 um 17:11 schrieb Gabriel Goller:
> The consent-text parameter is the base64-encoded content of the optional
> consent-banner which can be displayed before login. The limit is 128kB,
> which is less than the pmxcfs file limit, but still enough to also
> encode images.
> 
> Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
> ---
>  src/PVE/DataCenterConfig.pm | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
>

applied, lowered limit to 64 kiB though, no big reason besides
gut-feeling on final apply, we can always increase this if someone
provides a valid usecase, thanks!


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pve-devel] applied: [PATCH docs v3 3/4] add consent-banner description
  2024-12-10 16:11 ` [pve-devel] [PATCH docs v3 3/4] add consent-banner description Gabriel Goller
@ 2025-04-04 18:06   ` Thomas Lamprecht
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Lamprecht @ 2025-04-04 18:06 UTC (permalink / raw)
  To: Proxmox VE development discussion, Gabriel Goller

Am 10.12.24 um 17:11 schrieb Gabriel Goller:
> Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
> ---
>  pve-gui.adoc | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
>

applied, thanks!

prefixed the anchor-link with the per-chapter gui_ string, i.e. like
all others are in this chapter ;-)


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pve-devel] applied: [PATCH manager v3 1/4] show optional consent-banner before login
  2024-12-10 16:11 ` [pve-devel] [PATCH manager v3 1/4] show optional consent-banner before login Gabriel Goller
@ 2025-04-04 18:16   ` Thomas Lamprecht
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Lamprecht @ 2025-04-04 18:16 UTC (permalink / raw)
  To: Proxmox VE development discussion, Gabriel Goller

Am 10.12.24 um 17:11 schrieb Gabriel Goller:
> Add ConsentBanner variable to html template and populate it from the
> `datacenter.cfg` config file. Add Datacenter option to set the text and
> trigger the popup on login. The max length of the input is 63*1024,
> which is a bit less than the max body size for a api request (64*1024).
> 
> Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
> ---
>  PVE/Service/pveproxy.pm            | 13 ++++++++++---
>  www/index.html.tpl                 |  3 ++-
>  www/manager6/dc/OptionView.js      |  8 ++++++++
>  www/manager6/window/LoginWindow.js | 12 +++++++++++-
>  4 files changed, 31 insertions(+), 5 deletions(-)
> 
>

applied, thanks!

commented out the onlineHelp for now to avoid build errors while pve-docs is
not yet bumped and increase the maxLength to 64 kiB to match the updated
(reduced) limit in the backend and as the http-server's limit was increased
to 512 kiB recently [0] (not yet bumped though).

[0]: https://git.proxmox.com/?p=pve-http-server.git;a=commitdiff;h=2650923a42c9ea357dc0e663a69294410190cc7c


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-04-04 18:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-10 16:11 [pve-devel] [PATCH cluster/docs/manager/widget-toolkit v3 0/4] fix #5463: add optional Consent Banner on login Gabriel Goller
2024-12-10 16:11 ` [pve-devel] [PATCH manager v3 1/4] show optional consent-banner before login Gabriel Goller
2025-04-04 18:16   ` [pve-devel] applied: " Thomas Lamprecht
2024-12-10 16:11 ` [pve-devel] [PATCH cluster v3 2/4] add consent-text parameter to datacenter config file Gabriel Goller
2025-04-04 17:09   ` [pve-devel] applied: " Thomas Lamprecht
2024-12-10 16:11 ` [pve-devel] [PATCH docs v3 3/4] add consent-banner description Gabriel Goller
2025-04-04 18:06   ` [pve-devel] applied: " Thomas Lamprecht
2024-12-10 16:11 ` [pve-devel] [PATCH widget-toolkit v3 4/4] form: set enforceMaxLength on textareafield Gabriel Goller
2025-02-26 17:59   ` Thomas Lamprecht
2025-02-27 12:37     ` Gabriel Goller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal