Commit 10f7ed8d authored by Dietmar Maurer's avatar Dietmar Maurer

add support for two factor auth

parent 16bef583
...@@ -32,7 +32,7 @@ Ext.define('PVE.RestProxy', { ...@@ -32,7 +32,7 @@ Ext.define('PVE.RestProxy', {
Ext.define('pve-domains', { Ext.define('pve-domains', {
extend: "Ext.data.Model", extend: "Ext.data.Model",
fields: [ 'realm', 'type', 'comment', 'default', fields: [ 'realm', 'type', 'comment', 'default', 'tfa',
{ {
name: 'descr', name: 'descr',
// Note: We use this in the RealmComboBox.js // Note: We use this in the RealmComboBox.js
...@@ -45,7 +45,13 @@ Ext.define('PVE.RestProxy', { ...@@ -45,7 +45,13 @@ Ext.define('PVE.RestProxy', {
return value; return value;
} }
// return realm if there is no comment // return realm if there is no comment
return info.comment || info.realm; text = info.comment || info.realm;
if (info.tfa) {
text += " (+ " + info.tfa + ")";
}
return text;
} }
} }
], ],
......
...@@ -118,11 +118,19 @@ Ext.define('PVE.dc.UserEdit', { ...@@ -118,11 +118,19 @@ Ext.define('PVE.dc.UserEdit', {
name: 'email', name: 'email',
fieldLabel: gettext('E-Mail'), fieldLabel: gettext('E-Mail'),
vtype: 'email' vtype: 'email'
}, }
];
var columnB = [
{ {
xtype: 'textfield', xtype: 'textfield',
name: 'comment', name: 'comment',
fieldLabel: gettext('Comment') fieldLabel: gettext('Comment')
},
{
xtype: 'textfield',
name: 'keys',
fieldLabel: gettext('Key IDs')
} }
]; ];
...@@ -147,6 +155,7 @@ Ext.define('PVE.dc.UserEdit', { ...@@ -147,6 +155,7 @@ Ext.define('PVE.dc.UserEdit', {
var ipanel = Ext.create('PVE.panel.InputPanel', { var ipanel = Ext.create('PVE.panel.InputPanel', {
column1: column1, column1: column1,
column2: column2, column2: column2,
columnB: columnB,
onGetValues: function(values) { onGetValues: function(values) {
// hack: ExtJS datefield does not submit 0, so we need to set that // hack: ExtJS datefield does not submit 0, so we need to set that
if (!values.expire) { if (!values.expire) {
......
...@@ -2,6 +2,14 @@ Ext.define('PVE.form.RealmComboBox', { ...@@ -2,6 +2,14 @@ Ext.define('PVE.form.RealmComboBox', {
extend: 'Ext.form.field.ComboBox', extend: 'Ext.form.field.ComboBox',
alias: ['widget.pveRealmComboBox'], alias: ['widget.pveRealmComboBox'],
needOTP: function(realm) {
var me = this;
var rec = me.store.findRecord('realm', realm);
return rec && rec.data && rec.data.tfa ? rec.data.tfa : undefined;
},
initComponent: function() { initComponent: function() {
var me = this; var me = this;
......
...@@ -34,6 +34,13 @@ Ext.define('PVE.window.LoginWindow', { ...@@ -34,6 +34,13 @@ Ext.define('PVE.window.LoginWindow', {
initComponent: function() { initComponent: function() {
var me = this; var me = this;
var otp_field = Ext.createWidget('textfield', {
fieldLabel: gettext('OTP'),
name: 'otp',
allowBlank: false,
hidden: true
});
Ext.apply(me, { Ext.apply(me, {
width: 400, width: 400,
modal: true, modal: true,
...@@ -95,9 +102,21 @@ Ext.define('PVE.window.LoginWindow', { ...@@ -95,9 +102,21 @@ Ext.define('PVE.window.LoginWindow', {
} }
} }
}, },
otp_field,
{ {
xtype: 'pveRealmComboBox', xtype: 'pveRealmComboBox',
name: 'realm' name: 'realm',
listeners: {
change: function(f, value) {
if (f.needOTP(value)) {
otp_field.setVisible(true);
otp_field.setDisabled(false);
} else {
otp_field.setVisible(false);
otp_field.setDisabled(true);
}
}
}
}, },
{ {
xtype: 'pveLanguageSelector', xtype: 'pveLanguageSelector',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment