From: Markus Frank <m.frank@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-gui v4 3/3] add OIDC configuration panel for PMG
Date: Wed, 19 Mar 2025 14:29:59 +0100 [thread overview]
Message-ID: <20250319132959.5149-4-m.frank@proxmox.com> (raw)
In-Reply-To: <20250319132959.5149-1-m.frank@proxmox.com>
AuthEditOIDC.js is based on AuthEditOpenId from widget-toolkit and
adds additional configuration options for autocreate-role-assignment.
Use sub/preferred_username for username-claim instead of the old names
(subject/username/email) because subject and username do not exist in
the current OpenID Connect specifications and the email option is
incompatible with the username scheme.
Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
no changes in v4
js/AuthEditOIDC.js | 244 +++++++++++++++++++++++++++++++++++++++++++++
js/Makefile | 1 +
js/Utils.js | 1 +
3 files changed, 246 insertions(+)
create mode 100644 js/AuthEditOIDC.js
diff --git a/js/AuthEditOIDC.js b/js/AuthEditOIDC.js
new file mode 100644
index 0000000..ad6683f
--- /dev/null
+++ b/js/AuthEditOIDC.js
@@ -0,0 +1,244 @@
+Ext.define('PMG.OIDCInputPanel', {
+ extend: 'Proxmox.panel.InputPanel',
+ xtype: 'pmgAuthOIDCPanel',
+ mixins: ['Proxmox.Mixin.CBind'],
+
+ type: 'oidc',
+
+ viewModel: {
+ data: {
+ roleSource: '__default__',
+ autocreate: 0,
+ },
+ formulas: {
+ hideFixedRoleAssignment: function(get) {
+ return get('roleSource') !== 'fixed' || !get('autocreate');
+ },
+ hideClaimRoleAssignment: function(get) {
+ return get('roleSource') !== 'from-claim' || !get('autocreate');
+ },
+ },
+ },
+
+ onGetValues: function(values) {
+ let me = this;
+
+ if (me.isCreate && !me.useTypeInUrl) {
+ values.type = me.type;
+ }
+
+ let autocreateRoleAssignment = {};
+ if (values.source) {
+ autocreateRoleAssignment.source = values.source;
+ }
+ if (values.source === 'fixed') {
+ autocreateRoleAssignment['fixed-role'] = values['fixed-role'];
+ } else if (values.source === 'from-claim') {
+ autocreateRoleAssignment['role-claim'] = values['role-claim'];
+ }
+ values['autocreate-role-assignment'] = Proxmox.Utils.printPropertyString(autocreateRoleAssignment);
+ Proxmox.Utils.delete_if_default(values, 'autocreate-role-assignment', '', me.isCreate);
+
+ delete values.source;
+ delete values['fixed-role'];
+ delete values['role-claim'];
+
+ return values;
+ },
+
+ setValues: function(values) {
+ let autocreateRoleAssignment =
+ Proxmox.Utils.parsePropertyString(values['autocreate-role-assignment']);
+
+ values.source = autocreateRoleAssignment.source ?? '__default__';
+
+ if (autocreateRoleAssignment.source === 'fixed') {
+ values['fixed-role'] = autocreateRoleAssignment['fixed-role'];
+ }
+ if (autocreateRoleAssignment.source === 'from-claim') {
+ values['role-claim'] = autocreateRoleAssignment['role-claim'];
+ }
+
+ this.callParent(arguments);
+ },
+
+
+ columnT: [
+ {
+ xtype: 'textfield',
+ name: 'issuer-url',
+ fieldLabel: gettext('Issuer URL'),
+ allowBlank: false,
+ },
+ ],
+
+ column1: [
+ {
+ xtype: 'pmxDisplayEditField',
+ name: 'realm',
+ cbind: {
+ value: '{realm}',
+ editable: '{isCreate}',
+ },
+ fieldLabel: gettext('Realm'),
+ allowBlank: false,
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ fieldLabel: gettext('Default realm'),
+ name: 'default',
+ value: 0,
+ cbind: {
+ deleteEmpty: '{!isCreate}',
+ },
+ autoEl: {
+ tag: 'div',
+ 'data-qtip': gettext('Set realm as default for login'),
+ },
+ },
+ {
+ xtype: 'proxmoxtextfield',
+ fieldLabel: gettext('Client ID'),
+ name: 'client-id',
+ allowBlank: false,
+ },
+ {
+ xtype: 'proxmoxtextfield',
+ fieldLabel: gettext('Client Key'),
+ cbind: {
+ deleteEmpty: '{!isCreate}',
+ },
+ name: 'client-key',
+ },
+ ],
+
+ column2: [
+ {
+ xtype: 'pmxDisplayEditField',
+ name: 'username-claim',
+ fieldLabel: gettext('Username Claim'),
+ editConfig: {
+ xtype: 'proxmoxKVComboBox',
+ editable: true,
+ comboItems: [
+ ['__default__', Proxmox.Utils.defaultText],
+ ['sub', gettext('sub (subject)')],
+ ['preferred_username', gettext('preferred_username')],
+ ],
+ },
+ cbind: {
+ value: get => get('isCreate') ? '__default__' : Proxmox.Utils.defaultText,
+ deleteEmpty: '{!isCreate}',
+ editable: '{isCreate}',
+ },
+ },
+ {
+ xtype: 'proxmoxtextfield',
+ name: 'scopes',
+ fieldLabel: gettext('Scopes'),
+ emptyText: `${Proxmox.Utils.defaultText} (email profile)`,
+ submitEmpty: false,
+ cbind: {
+ deleteEmpty: '{!isCreate}',
+ },
+ },
+ {
+ xtype: 'proxmoxKVComboBox',
+ name: 'prompt',
+ fieldLabel: gettext('Prompt'),
+ editable: true,
+ emptyText: gettext('Auth-Provider Default'),
+ comboItems: [
+ ['__default__', gettext('Auth-Provider Default')],
+ ['none', 'none'],
+ ['login', 'login'],
+ ['consent', 'consent'],
+ ['select_account', 'select_account'],
+ ],
+ cbind: {
+ deleteEmpty: '{!isCreate}',
+ },
+ },
+ ],
+
+ columnB: [
+ {
+ xtype: 'proxmoxtextfield',
+ name: 'comment',
+ fieldLabel: gettext('Comment'),
+ cbind: {
+ deleteEmpty: '{!isCreate}',
+ },
+ },
+ {
+ xtype: 'displayfield',
+ value: gettext('Autocreate Options'),
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ fieldLabel: gettext('Autocreate Users'),
+ name: 'autocreate',
+ bind: {
+ value: '{autocreate}',
+ },
+ cbind: {
+ deleteEmpty: '{!isCreate}',
+ },
+ },
+ {
+ xtype: 'proxmoxKVComboBox',
+ name: 'source',
+ fieldLabel: gettext('Source for Role Assignment'),
+ allowBlank: false,
+ deleteEmpty: false,
+ comboItems: [
+ [
+ '__default__',
+ Proxmox.Utils.defaultText
+ + ' (' + gettext('All auto-created users get audit role') + ')',
+ ],
+ ['fixed', gettext('Fixed role for all auto-created users')],
+ ['from-claim', gettext('Get role from OIDC claim')],
+ ],
+ bind: {
+ value: '{roleSource}',
+ disabled: '{!autocreate}',
+ hidden: '{!autocreate}',
+ },
+ },
+ {
+ xtype: 'pmgRoleSelector',
+ name: 'fixed-role',
+ allowBlank: false,
+ deleteEmpty: false,
+ fieldLabel: gettext('Fixed Role'),
+ bind: {
+ disabled: '{hideFixedRoleAssignment}',
+ hidden: '{hideFixedRoleAssignment}',
+ },
+ },
+ {
+ xtype: 'proxmoxtextfield',
+ name: 'role-claim',
+ allowBlank: false,
+ deleteEmpty: false,
+ fieldLabel: gettext('Role Claim'),
+ bind: {
+ disabled: '{hideClaimRoleAssignment}',
+ hidden: '{hideClaimRoleAssignment}',
+ },
+ },
+ ],
+
+ advancedColumnB: [
+ {
+ xtype: 'proxmoxtextfield',
+ name: 'acr-values',
+ fieldLabel: gettext('ACR Values'),
+ submitEmpty: false,
+ cbind: {
+ deleteEmpty: '{!isCreate}',
+ },
+ },
+ ],
+});
diff --git a/js/Makefile b/js/Makefile
index d1fab9b..c984bf3 100644
--- a/js/Makefile
+++ b/js/Makefile
@@ -78,6 +78,7 @@ JSSRC= \
LDAPConfig.js \
UserEdit.js \
UserView.js \
+ AuthEditOIDC.js \
TFAView.js \
FetchmailEdit.js \
FetchmailView.js \
diff --git a/js/Utils.js b/js/Utils.js
index aa17d83..d563483 100644
--- a/js/Utils.js
+++ b/js/Utils.js
@@ -871,6 +871,7 @@ Ext.define('PMG.Utils', {
// use oidc instead of openid
Proxmox.Schema.authDomains.oidc = Proxmox.Schema.authDomains.openid;
Proxmox.Schema.authDomains.oidc.useTypeInUrl = false;
+ Proxmox.Schema.authDomains.oidc.ipanel = 'pmgAuthOIDCPanel';
delete Proxmox.Schema.authDomains.openid;
// Disable LDAP/AD as a realm until LDAP/AD login is implemented
--
2.39.5
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
next prev parent reply other threads:[~2025-03-19 13:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-19 13:29 [pmg-devel] [PATCH pmg-api/pmg-gui v4 0/3] add default realm option and OIDC configuration panel Markus Frank
2025-03-19 13:29 ` [pmg-devel] [PATCH pmg-api v4 1/3] Auth Plugin: stop forcing the default realm to be the pmg realm Markus Frank
2025-03-19 13:29 ` [pmg-devel] [PATCH pmg-gui v4 2/3] realms: enable default realm support Markus Frank
2025-03-19 13:29 ` Markus Frank [this message]
2025-03-20 9:36 ` [pmg-devel] [PATCH pmg-api/pmg-gui v4 0/3] add default realm option and OIDC configuration panel Christoph Heiss
2025-03-26 7:41 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250319132959.5149-4-m.frank@proxmox.com \
--to=m.frank@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.