]> git.proxmox.com Git - proxmox-widget-toolkit.git/blame - src/window/AuthEditLDAP.js
auth ui: add LDAP realm edit panel
[proxmox-widget-toolkit.git] / src / window / AuthEditLDAP.js
CommitLineData
aa5cbdbb
LW
1
2Ext.define('Proxmox.panel.LDAPInputPanelViewModel', {
3 extend: 'Ext.app.ViewModel',
4
5 alias: 'viewmodel.pmxAuthLDAPPanel',
6
7 data: {
8 mode: 'ldap',
9 anonymous_search: 1,
10 },
11
12 formulas: {
13 tls_enabled: function(get) {
14 return get('mode') !== 'ldap';
15 },
16 },
17
18});
19
20
21Ext.define('Proxmox.panel.LDAPInputPanel', {
22 extend: 'Proxmox.panel.InputPanel',
23 xtype: 'pmxAuthLDAPPanel',
24 mixins: ['Proxmox.Mixin.CBind'],
25
26 viewModel: {
27 type: 'pmxAuthLDAPPanel',
28 },
29
30 type: 'ldap',
31
32 onGetValues: function(values) {
33 if (this.isCreate) {
34 values.type = this.type;
35 }
36
37 if (values.anonymous_search) {
38 if (!values.delete) {
39 values.delete = [];
40 }
41
42 if (!Array.isArray(values.delete)) {
43 let tmp = values.delete;
44 values.delete = [];
45 values.delete.push(tmp);
46 }
47
48 values.delete.push("bind-dn");
49 values.delete.push("password");
50 }
51
52 delete values.anonymous_search;
53
54 return values;
55 },
56
57 onSetValues: function(values) {
58 values.anonymous_search = values["bind-dn"] ? 0 : 1;
59
60 return values;
61 },
62
63
64 column1: [
65 {
66 xtype: 'pmxDisplayEditField',
67 name: 'realm',
68 cbind: {
69 value: '{realm}',
70 editable: '{isCreate}',
71 },
72 fieldLabel: gettext('Realm'),
73 allowBlank: false,
74 },
75 {
76 xtype: 'proxmoxtextfield',
77 fieldLabel: gettext('Base Domain Name'),
78 name: 'base-dn',
79 allowBlank: false,
80 emptyText: 'cn=Users,dc=company,dc=net',
81 },
82 {
83 xtype: 'proxmoxtextfield',
84 fieldLabel: gettext('User Attribute Name'),
85 name: 'user-attr',
86 allowBlank: false,
87 emptyText: 'uid / sAMAccountName',
88 },
89 {
90 xtype: 'proxmoxcheckbox',
91 fieldLabel: gettext('Anonymous Search'),
92 name: 'anonymous_search',
93 bind: '{anonymous_search}',
94 },
95 {
96 xtype: 'proxmoxtextfield',
97 fieldLabel: gettext('Bind Domain Name'),
98 name: 'bind-dn',
99 allowBlank: false,
100 emptyText: 'cn=user,dc=company,dc=net',
101 bind: {
102 disabled: "{anonymous_search}",
103 },
104 },
105 {
106 xtype: 'proxmoxtextfield',
107 inputType: 'password',
108 fieldLabel: gettext('Bind Password'),
109 name: 'password',
110 allowBlank: true,
111 cbind: {
112 emptyText: get => !get('isCreate') ? gettext('Unchanged') : '',
113 },
114 bind: {
115 disabled: "{anonymous_search}",
116 },
117 },
118 ],
119
120 column2: [
121 {
122 xtype: 'proxmoxtextfield',
123 name: 'server1',
124 fieldLabel: gettext('Server'),
125 allowBlank: false,
126 },
127 {
128 xtype: 'proxmoxtextfield',
129 name: 'server2',
130 fieldLabel: gettext('Fallback Server'),
131 submitEmpty: false,
132 cbind: {
133 deleteEmpty: '{!isCreate}',
134 },
135 },
136 {
137 xtype: 'proxmoxintegerfield',
138 name: 'port',
139 fieldLabel: gettext('Port'),
140 minValue: 1,
141 maxValue: 65535,
142 emptyText: gettext('Default'),
143 submitEmptyText: false,
144 deleteEmpty: true,
145 },
146 {
147 xtype: 'proxmoxKVComboBox',
148 name: 'mode',
149 fieldLabel: gettext('Mode'),
150 editable: false,
151 comboItems: [
152 ['ldap', 'LDAP'],
153 ['ldap+starttls', 'STARTTLS'],
154 ['ldaps', 'LDAPS'],
155 ],
156 bind: "{mode}",
157 cbind: {
158 deleteEmpty: '{!isCreate}',
159 value: get => get('isCreate') ? 'ldap' : 'LDAP',
160 },
161 },
162 {
163 xtype: 'proxmoxcheckbox',
164 fieldLabel: gettext('Verify Certificate'),
165 name: 'verify',
166 value: 0,
167 cbind: {
168 deleteEmpty: '{!isCreate}',
169 },
170
171 bind: {
172 disabled: '{!tls_enabled}',
173 },
174 autoEl: {
175 tag: 'div',
176 'data-qtip': gettext('Verify TLS certificate of the server'),
177 },
178
179 },
180 ],
181
182 columnB: [
183 {
184 xtype: 'textfield',
185 name: 'comment',
186 fieldLabel: gettext('Comment'),
187 cbind: {
188 deleteEmpty: '{!isCreate}',
189 },
190 },
191 ],
192
193});
194