]>
git.proxmox.com Git - pve-manager.git/blob - www/manager/dc/AuthEdit.js
1 Ext
.define('PVE.dc.AuthEdit', {
2 extend
: 'PVE.window.Edit',
3 alias
: ['widget.pveDcAuthEdit'],
7 initComponent : function() {
10 me
.create
= !me
.realm
;
17 url
= '/api2/extjs/access/domains';
20 url
= '/api2/extjs/access/domains/' + me
.realm
;
26 xtype
: me
.create
? 'textfield' : 'displayfield',
27 height
: 22, // hack: set same height as text fields
29 fieldLabel
: gettext('Realm'),
35 if (me
.authType
=== 'ad') {
37 me
.subject
= gettext('Active Directory Server');
42 fieldLabel
: gettext('Domain'),
43 emptyText
: 'company.net',
47 } else if (me
.authType
=== 'ldap') {
49 me
.subject
= gettext('LDAP Server');
54 fieldLabel
: gettext('Base Domain Name'),
55 emptyText
: 'CN=Users,DC=Company,DC=net',
62 emptyText
: 'uid / sAMAccountName',
63 fieldLabel
: gettext('User Attribute Name'),
66 } else if (me
.authType
=== 'pve') {
68 if (me
.create
) throw 'unknown auth type';
70 me
.subject
= 'Proxmox VE authentication server';
72 } else if (me
.authType
=== 'pam') {
74 if (me
.create
) throw 'unknown auth type';
76 me
.subject
= 'linux PAM';
79 throw 'unknown auth type ';
84 fieldLabel
: gettext('Default'),
91 if (me
.authType
=== 'ldap' || me
.authType
=== 'ad') {
95 fieldLabel
: gettext('Server'),
100 xtype
: 'pvetextfield',
101 fieldLabel
: gettext('Fallback Server'),
102 deleteEmpty
: !me
.create
,
106 xtype
: 'numberfield',
108 fieldLabel
: gettext('Port'),
111 emptyText
: gettext('Default'),
112 submitEmptyText
: false
115 xtype
: 'pvecheckbox',
123 // Two Factor Auth settings
126 xtype
: 'pveKVComboBox',
128 deleteEmpty
: !me
.create
,
130 fieldLabel
: gettext('TFA'),
131 data
: [ ['', PVE
.Utils
.noneText
], ['oath', 'OATH'], ['yubico', 'Yubico']],
133 change: function(f
, value
) {
137 me
.down('field[name=oath_step]').setVisible(value
=== 'oath');
138 me
.down('field[name=oath_digits]').setVisible(value
=== 'oath');
139 me
.down('field[name=yubico_api_id]').setVisible(value
=== 'yubico');
140 me
.down('field[name=yubico_api_key]').setVisible(value
=== 'yubico');
141 me
.down('field[name=yubico_url]').setVisible(value
=== 'yubico');
147 xtype
: 'numberfield',
152 allowDecimals
: false,
154 emptyText
: PVE
.Utils
.defaultText
+ ' (30)',
155 submitEmptyText
: false,
157 fieldLabel
: 'OATH time step'
161 xtype
: 'numberfield',
167 allowDecimals
: false,
169 emptyText
: PVE
.Utils
.defaultText
+ ' (6)',
170 submitEmptyText
: false,
172 fieldLabel
: 'OATH password length'
177 name
: 'yubico_api_id',
179 fieldLabel
: 'Yubico API Id'
184 name
: 'yubico_api_key',
186 fieldLabel
: 'Yubico API Key'
193 fieldLabel
: 'Yubico URL'
196 var ipanel
= Ext
.create('PVE.panel.InputPanel', {
202 fieldLabel
: gettext('Comment')
204 onGetValues: function(values
) {
207 PVE
.Utils
.assemble_field_data(values
, { 'delete': 'port' });
213 values
.type
= me
.authType
;
216 if (values
.tfa
=== 'oath') {
217 values
.tfa
= "type=oath";
218 if (values
.oath_step
) {
219 values
.tfa
+= ",step=" + values
.oath_step
;
221 if (values
.oath_digits
) {
222 values
.tfa
+= ",digits=" + values
.oath_digits
;
224 } else if (values
.tfa
=== 'yubico') {
225 values
.tfa
= "type=yubico";
226 values
.tfa
+= ",id=" + values
.yubico_api_id
;
227 values
.tfa
+= ",key=" + values
.yubico_api_key
;
228 if (values
.yubico_url
) {
229 values
.tfa
+= ",url=" + values
.yubico_url
;
235 delete values
.oath_step
;
236 delete values
.oath_digits
;
237 delete values
.yubico_api_id
;
238 delete values
.yubico_api_key
;
239 delete values
.yubico_url
;
258 success: function(response
, options
) {
259 var data
= response
.result
.data
|| {};
260 // just to be sure (should not happen)
261 if (data
.type
!== me
.authType
) {
263 throw "got wrong auth type";
267 var tfacfg
= PVE
.Parser
.parseTfaConfig(data
.tfa
);
268 data
.tfa
= tfacfg
.type
;
269 if (tfacfg
.type
=== 'yubico') {
270 data
.yubico_api_key
= tfacfg
.key
;
271 data
.yubico_api_id
= tfacfg
.id
;
272 data
.yubico_url
= tfacfg
.url
;
273 } else if (tfacfg
.type
=== 'oath') {
274 data
.oath_step
= tfacfg
.step
;
275 data
.oath_digits
= tfacfg
.digits
;