]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/dc/AuthEditLDAP.js
ui: realm: clarify that the sync jobs really are for the realm
[pve-manager.git] / www / manager6 / dc / AuthEditLDAP.js
CommitLineData
efff7eab
DC
1Ext.define('PVE.panel.LDAPInputPanel', {
2 extend: 'PVE.panel.AuthBase',
3 xtype: 'pveAuthLDAPPanel',
4
5 initComponent: function() {
6 let me = this;
7
8 if (me.type !== 'ldap') {
9 throw 'invalid type';
10 }
11
12 me.column1 = [
13 {
14 xtype: 'textfield',
15 name: 'base_dn',
16 fieldLabel: gettext('Base Domain Name'),
17 emptyText: 'CN=Users,DC=Company,DC=net',
18 allowBlank: false,
19 },
20 {
21 xtype: 'textfield',
22 name: 'user_attr',
23 emptyText: 'uid / sAMAccountName',
24 fieldLabel: gettext('User Attribute Name'),
25 allowBlank: false,
26 },
27 ];
28
29 me.column2 = [
30 {
31 xtype: 'textfield',
32 fieldLabel: gettext('Server'),
33 name: 'server1',
34 allowBlank: false,
35 },
36 {
37 xtype: 'proxmoxtextfield',
38 fieldLabel: gettext('Fallback Server'),
39 deleteEmpty: !me.isCreate,
40 name: 'server2',
41 },
42 {
43 xtype: 'proxmoxintegerfield',
44 name: 'port',
45 fieldLabel: gettext('Port'),
46 minValue: 1,
47 maxValue: 65535,
48 emptyText: gettext('Default'),
49 submitEmptyText: false,
50 },
51 {
52 xtype: 'proxmoxcheckbox',
53 fieldLabel: 'SSL',
54 name: 'secure',
55 uncheckedValue: 0,
a06e43f0 56 listeners: {
2dddf3ba
TL
57 change: function(field, newValue) {
58 let verifyCheckbox = field.nextSibling('proxmoxcheckbox[name=verify]');
a06e43f0
DJ
59 if (newValue === true) {
60 verifyCheckbox.enable();
61 } else {
62 verifyCheckbox.disable();
63 verifyCheckbox.setValue(0);
64 }
65 },
66 },
67 },
68 {
69 xtype: 'proxmoxcheckbox',
70 fieldLabel: gettext('Verify Certificate'),
71 name: 'verify',
72 unceckedValue: 0,
73 disabled: true,
74 checked: false,
75 autoEl: {
76 tag: 'div',
77 'data-qtip': gettext('Verify SSL certificate of the server'),
78 },
efff7eab
DC
79 },
80 ];
81
82 me.callParent();
83 },
a06e43f0
DJ
84 onGetValues: function(values) {
85 let me = this;
86
87 if (!values.verify) {
88 if (!me.isCreate) {
89 Proxmox.Utils.assemble_field_data(values, { 'delete': 'verify' });
90 }
91 delete values.verify;
92 }
93
94 return me.callParent([values]);
95 },
efff7eab 96});
822fb26d
DC
97
98Ext.define('PVE.panel.LDAPSyncInputPanel', {
99 extend: 'Proxmox.panel.InputPanel',
100 xtype: 'pveAuthLDAPSyncPanel',
101
102 editableAttributes: ['email'],
3e43739f 103 editableDefaults: ['scope', 'enable-new'],
f433ad19
DC
104 default_opts: {},
105 sync_attributes: {},
822fb26d
DC
106
107 // (de)construct the sync-attributes from the list above,
108 // not touching all others
109 onGetValues: function(values) {
110 let me = this;
111 me.editableDefaults.forEach((attr) => {
112 if (values[attr]) {
113 me.default_opts[attr] = values[attr];
114 delete values[attr];
115 } else {
116 delete me.default_opts[attr];
117 }
118 });
3e43739f
DC
119 let vanished_opts = [];
120 ['acl', 'entry', 'properties'].forEach((prop) => {
121 if (values[`remove-vanished-${prop}`]) {
122 vanished_opts.push(prop);
123 }
124 delete values[`remove-vanished-${prop}`];
125 });
126 me.default_opts['remove-vanished'] = vanished_opts.join(';');
127
822fb26d
DC
128 values['sync-defaults-options'] = PVE.Parser.printPropertyString(me.default_opts);
129 me.editableAttributes.forEach((attr) => {
130 if (values[attr]) {
131 me.sync_attributes[attr] = values[attr];
132 delete values[attr];
133 } else {
134 delete me.sync_attributes[attr];
135 }
136 });
137 values.sync_attributes = PVE.Parser.printPropertyString(me.sync_attributes);
138
139 PVE.Utils.delete_if_default(values, 'sync-defaults-options');
140 PVE.Utils.delete_if_default(values, 'sync_attributes');
141
93c425e1
LW
142 // Force values.delete to be an array
143 if (typeof values.delete === 'string') {
144 values.delete = values.delete.split(',');
145 }
146
f433ad19
DC
147 if (me.isCreate) {
148 delete values.delete; // on create we cannot delete values
149 }
150
822fb26d
DC
151 return values;
152 },
153
154 setValues: function(values) {
155 let me = this;
822fb26d
DC
156 if (values.sync_attributes) {
157 me.sync_attributes = PVE.Parser.parsePropertyString(values.sync_attributes);
158 delete values.sync_attributes;
159 me.editableAttributes.forEach((attr) => {
160 if (me.sync_attributes[attr]) {
161 values[attr] = me.sync_attributes[attr];
162 }
163 });
164 }
822fb26d
DC
165 if (values['sync-defaults-options']) {
166 me.default_opts = PVE.Parser.parsePropertyString(values['sync-defaults-options']);
167 delete values.default_opts;
168 me.editableDefaults.forEach((attr) => {
169 if (me.default_opts[attr]) {
170 values[attr] = me.default_opts[attr];
171 }
172 });
3e43739f
DC
173
174 if (me.default_opts['remove-vanished']) {
175 let opts = me.default_opts['remove-vanished'].split(';');
176 for (const opt of opts) {
177 values[`remove-vanished-${opt}`] = 1;
178 }
179 }
822fb26d
DC
180 }
181 return me.callParent([values]);
182 },
183
184 column1: [
185 {
186 xtype: 'proxmoxtextfield',
187 name: 'bind_dn',
188 deleteEmpty: true,
189 emptyText: Proxmox.Utils.noneText,
190 fieldLabel: gettext('Bind User'),
191 },
192 {
193 xtype: 'proxmoxtextfield',
194 inputType: 'password',
195 name: 'password',
196 emptyText: gettext('Unchanged'),
197 fieldLabel: gettext('Bind Password'),
198 },
199 {
200 xtype: 'proxmoxtextfield',
201 name: 'email',
202 fieldLabel: gettext('E-Mail attribute'),
203 },
204 {
205 xtype: 'proxmoxtextfield',
206 name: 'group_name_attr',
207 deleteEmpty: true,
208 fieldLabel: gettext('Groupname attr.'),
209 },
210 {
211 xtype: 'displayfield',
212 value: gettext('Default Sync Options'),
213 },
214 {
215 xtype: 'proxmoxKVComboBox',
216 name: 'scope',
217 emptyText: Proxmox.Utils.NoneText,
218 fieldLabel: gettext('Scope'),
219 value: '__default__',
220 deleteEmpty: false,
221 comboItems: [
222 ['__default__', Proxmox.Utils.NoneText],
223 ['users', gettext('Users')],
224 ['groups', gettext('Groups')],
225 ['both', gettext('Users and Groups')],
226 ],
227 },
822fb26d
DC
228 ],
229
230 column2: [
231 {
232 xtype: 'proxmoxtextfield',
233 name: 'user_classes',
234 fieldLabel: gettext('User classes'),
235 deleteEmpty: true,
236 emptyText: 'inetorgperson, posixaccount, person, user',
237 },
238 {
239 xtype: 'proxmoxtextfield',
240 name: 'group_classes',
241 fieldLabel: gettext('Group classes'),
242 deleteEmpty: true,
243 emptyText: 'groupOfNames, group, univentionGroup, ipausergroup',
244 },
245 {
246 xtype: 'proxmoxtextfield',
247 name: 'filter',
248 fieldLabel: gettext('User Filter'),
249 deleteEmpty: true,
250 },
251 {
252 xtype: 'proxmoxtextfield',
253 name: 'group_filter',
254 fieldLabel: gettext('Group Filter'),
255 deleteEmpty: true,
256 },
257 {
258 // fake for spacing
259 xtype: 'displayfield',
260 value: ' ',
261 },
262 {
263 xtype: 'proxmoxKVComboBox',
264 value: '__default__',
265 deleteEmpty: false,
266 comboItems: [
267 [
268 '__default__',
269 Ext.String.format(
270 gettext("{0} ({1})"),
271 Proxmox.Utils.yesText,
272 Proxmox.Utils.defaultText,
273 ),
274 ],
275 ['1', Proxmox.Utils.yesText],
276 ['0', Proxmox.Utils.noText],
277 ],
278 name: 'enable-new',
279 fieldLabel: gettext('Enable new users'),
280 },
3e43739f
DC
281 ],
282
283 columnB: [
822fb26d 284 {
04f27b64
TL
285 xtype: 'fieldset',
286 title: gettext('Remove Vanished Options'),
287 items: [
288 {
289 xtype: 'proxmoxcheckbox',
290 fieldLabel: gettext('ACL'),
291 name: 'remove-vanished-acl',
292 boxLabel: gettext('Remove ACLs of vanished users and groups.'),
293 },
294 {
295 xtype: 'proxmoxcheckbox',
296 fieldLabel: gettext('Entry'),
297 name: 'remove-vanished-entry',
298 boxLabel: gettext('Remove vanished user and group entries.'),
299 },
300 {
301 xtype: 'proxmoxcheckbox',
302 fieldLabel: gettext('Properties'),
303 name: 'remove-vanished-properties',
2637f372 304 boxLabel: gettext('Remove vanished properties from synced users.'),
04f27b64
TL
305 },
306 ],
822fb26d
DC
307 },
308 ],
309});