]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/AuthEdit.js
980348d7c65ad6a42566c20c3e7d40d15989bf42
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',
28 fieldLabel
: gettext('Realm'),
34 if (me
.authType
=== 'ad') {
36 me
.subject
= gettext('Active Directory Server');
41 fieldLabel
: gettext('Domain'),
42 emptyText
: 'company.net',
46 } else if (me
.authType
=== 'ldap') {
48 me
.subject
= gettext('LDAP Server');
53 fieldLabel
: gettext('Base Domain Name'),
54 emptyText
: 'CN=Users,DC=Company,DC=net',
61 emptyText
: 'uid / sAMAccountName',
62 fieldLabel
: gettext('User Attribute Name'),
65 } else if (me
.authType
=== 'pve') {
68 throw 'unknown auth type';
71 me
.subject
= 'Proxmox VE authentication server';
73 } else if (me
.authType
=== 'pam') {
76 throw 'unknown auth type';
79 me
.subject
= 'linux PAM';
82 throw 'unknown auth type ';
87 fieldLabel
: gettext('Default'),
94 if (me
.authType
=== 'ldap' || me
.authType
=== 'ad') {
98 fieldLabel
: gettext('Server'),
103 xtype
: 'pvetextfield',
104 fieldLabel
: gettext('Fallback Server'),
105 deleteEmpty
: !me
.create
,
109 xtype
: 'pveIntegerField',
111 fieldLabel
: gettext('Port'),
114 emptyText
: gettext('Default'),
115 submitEmptyText
: false
118 xtype
: 'pvecheckbox',
126 // Two Factor Auth settings
129 xtype
: 'pveKVComboBox',
131 deleteEmpty
: !me
.create
,
133 fieldLabel
: gettext('TFA'),
134 comboItems
: [ ['__default__', PVE
.Utils
.noneText
], ['oath', 'OATH'], ['yubico', 'Yubico']],
136 change: function(f
, value
) {
140 me
.down('field[name=oath_step]').setVisible(value
=== 'oath');
141 me
.down('field[name=oath_digits]').setVisible(value
=== 'oath');
142 me
.down('field[name=yubico_api_id]').setVisible(value
=== 'yubico');
143 me
.down('field[name=yubico_api_key]').setVisible(value
=== 'yubico');
144 me
.down('field[name=yubico_url]').setVisible(value
=== 'yubico');
150 xtype
: 'pveIntegerField',
154 emptyText
: PVE
.Utils
.defaultText
+ ' (30)',
155 submitEmptyText
: false,
157 fieldLabel
: 'OATH time step'
161 xtype
: 'pveIntegerField',
166 emptyText
: PVE
.Utils
.defaultText
+ ' (6)',
167 submitEmptyText
: false,
169 fieldLabel
: 'OATH password length'
174 name
: 'yubico_api_id',
176 fieldLabel
: 'Yubico API Id'
181 name
: 'yubico_api_key',
183 fieldLabel
: 'Yubico API Key'
190 fieldLabel
: 'Yubico URL'
193 var ipanel
= Ext
.create('PVE.panel.InputPanel', {
199 fieldLabel
: gettext('Comment')
201 onGetValues: function(values
) {
204 PVE
.Utils
.assemble_field_data(values
, { 'delete': 'port' });
210 values
.type
= me
.authType
;
213 if (values
.tfa
=== 'oath') {
214 values
.tfa
= "type=oath";
215 if (values
.oath_step
) {
216 values
.tfa
+= ",step=" + values
.oath_step
;
218 if (values
.oath_digits
) {
219 values
.tfa
+= ",digits=" + values
.oath_digits
;
221 } else if (values
.tfa
=== 'yubico') {
222 values
.tfa
= "type=yubico";
223 values
.tfa
+= ",id=" + values
.yubico_api_id
;
224 values
.tfa
+= ",key=" + values
.yubico_api_key
;
225 if (values
.yubico_url
) {
226 values
.tfa
+= ",url=" + values
.yubico_url
;
232 delete values
.oath_step
;
233 delete values
.oath_digits
;
234 delete values
.yubico_api_id
;
235 delete values
.yubico_api_key
;
236 delete values
.yubico_url
;
255 success: function(response
, options
) {
256 var data
= response
.result
.data
|| {};
257 // just to be sure (should not happen)
258 if (data
.type
!== me
.authType
) {
260 throw "got wrong auth type";
264 var tfacfg
= PVE
.Parser
.parseTfaConfig(data
.tfa
);
265 data
.tfa
= tfacfg
.type
;
266 if (tfacfg
.type
=== 'yubico') {
267 data
.yubico_api_key
= tfacfg
.key
;
268 data
.yubico_api_id
= tfacfg
.id
;
269 data
.yubico_url
= tfacfg
.url
;
270 } else if (tfacfg
.type
=== 'oath') {
271 // step is a number before
272 /*jslint confusion: true*/
273 data
.oath_step
= tfacfg
.step
;
274 data
.oath_digits
= tfacfg
.digits
;
275 /*jslint confusion: false*/