2021-01-15 10:06:18 +00:00
|
|
|
Ext.define('PBS.WebauthnConfigView', {
|
|
|
|
extend: 'Proxmox.grid.ObjectGrid',
|
|
|
|
alias: ['widget.pbsWebauthnConfigView'],
|
|
|
|
|
|
|
|
url: "/api2/json/config/access/tfa/webauthn",
|
|
|
|
cwidth1: 150,
|
|
|
|
interval: 1000,
|
|
|
|
|
|
|
|
rows: {
|
|
|
|
rp: {
|
|
|
|
header: gettext('Relying Party'),
|
|
|
|
required: true,
|
2021-01-15 15:25:47 +00:00
|
|
|
defaultValue: gettext('Not configured'),
|
2021-01-15 10:06:18 +00:00
|
|
|
},
|
|
|
|
origin: {
|
|
|
|
header: gettext('Origin'),
|
|
|
|
required: true,
|
2021-01-15 15:25:47 +00:00
|
|
|
defaultValue: gettext('Not configured'),
|
2021-01-15 10:06:18 +00:00
|
|
|
},
|
|
|
|
id: {
|
2021-01-15 15:25:26 +00:00
|
|
|
header: 'ID',
|
2021-01-15 10:06:18 +00:00
|
|
|
required: true,
|
2021-01-15 15:25:47 +00:00
|
|
|
defaultValue: gettext('Not configured'),
|
2021-01-15 10:06:18 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
tbar: [
|
|
|
|
{
|
|
|
|
text: gettext("Edit"),
|
|
|
|
handler: 'runEditor',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
2021-05-21 16:19:11 +00:00
|
|
|
runEditor: () => Ext.create('PBS.WebauthnConfigEdit', { autoShow: true }),
|
2021-01-15 10:06:18 +00:00
|
|
|
|
|
|
|
startStore: function() { this.getView().getStore().rstore.startUpdate(); },
|
|
|
|
stopStore: function() { this.getView().getStore().rstore.stopUpdate(); },
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
listeners: {
|
|
|
|
itemdblclick: 'runEditor',
|
|
|
|
activate: 'startStore',
|
|
|
|
deactivate: 'stopStore',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
Ext.define('PBS.WebauthnConfigEdit', {
|
|
|
|
extend: 'Proxmox.window.Edit',
|
|
|
|
alias: ['widget.pbsWebauthnConfigEdit'],
|
|
|
|
|
|
|
|
subject: gettext('Webauthn'),
|
|
|
|
url: "/api2/extjs/config/access/tfa/webauthn",
|
|
|
|
autoLoad: true,
|
|
|
|
|
2021-02-01 14:37:43 +00:00
|
|
|
width: 512,
|
|
|
|
|
2021-01-15 10:06:18 +00:00
|
|
|
fieldDefaults: {
|
|
|
|
labelWidth: 120,
|
|
|
|
},
|
|
|
|
|
2021-02-01 14:37:43 +00:00
|
|
|
setValues: function(values) {
|
|
|
|
let me = this;
|
|
|
|
|
|
|
|
me.relayingPartySet = values && typeof values.rp === 'string';
|
|
|
|
|
|
|
|
me.callParent(arguments);
|
|
|
|
},
|
|
|
|
|
2021-01-15 10:06:18 +00:00
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'textfield',
|
|
|
|
fieldLabel: gettext('Relying Party'),
|
|
|
|
name: 'rp',
|
|
|
|
allowBlank: false,
|
2021-02-01 14:37:43 +00:00
|
|
|
listeners: {
|
|
|
|
dirtychange: function(field, isDirty) {
|
|
|
|
let win = field.up('window');
|
|
|
|
let warningBox = win.down('box[id=rpChangeWarning]');
|
|
|
|
warningBox.setHidden(!win.relayingPartySet || !isDirty);
|
|
|
|
},
|
|
|
|
},
|
2021-01-15 10:06:18 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'textfield',
|
|
|
|
fieldLabel: gettext('Origin'),
|
|
|
|
name: 'origin',
|
|
|
|
allowBlank: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'textfield',
|
2021-01-15 15:25:26 +00:00
|
|
|
fieldLabel: 'ID',
|
2021-01-15 10:06:18 +00:00
|
|
|
name: 'id',
|
|
|
|
allowBlank: false,
|
|
|
|
},
|
2021-02-01 13:53:45 +00:00
|
|
|
{
|
|
|
|
xtype: 'container',
|
|
|
|
layout: 'hbox',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'box',
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'button',
|
|
|
|
text: gettext('Auto-fill'),
|
|
|
|
iconCls: 'fa fa-fw fa-pencil-square-o',
|
|
|
|
handler: function(button, ev) {
|
|
|
|
let panel = this.up('panel');
|
|
|
|
panel.down('field[name=rp]').setValue(document.location.hostname);
|
|
|
|
panel.down('field[name=origin]').setValue(document.location.origin);
|
|
|
|
panel.down('field[name=id]').setValue(document.location.hostname);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-02-01 14:37:43 +00:00
|
|
|
{
|
|
|
|
xtype: 'box',
|
|
|
|
html: `<span class='pmx-hint'>${gettext('Note:')}</span> `
|
|
|
|
+ gettext('WebAuthn requires using a trusted certificate.'),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'box',
|
|
|
|
id: 'rpChangeWarning',
|
|
|
|
hidden: true,
|
|
|
|
padding: '5 0 0 0',
|
|
|
|
html: '<i class="fa fa-exclamation-triangle warning"></i> '
|
|
|
|
+ gettext('Changing the Relying Party may break existing webAuthn TFA entries.'),
|
|
|
|
},
|
2021-01-15 10:06:18 +00:00
|
|
|
],
|
|
|
|
});
|