This commit is contained in:
antelle 2020-04-19 18:52:21 +02:00
parent 7e849934ff
commit 4591268063
No known key found for this signature in database
GPG Key ID: 094A2F2D6136A4EE
7 changed files with 88 additions and 11 deletions

View File

@ -36,6 +36,11 @@ const DefaultAppSettings = {
useGroupIconForEntries: false, // automatically use group icon when creating new entries
enableUsb: true, // enable interaction with USB devices
yubiKeyShowIcon: true, // show an icon to open OTP codes from YubiKey
yubiKeyAutoOpen: true, // auto-load one-time codes when there are open files
yubiKeyMatchEntries: true, // show matching one-time codes in entries
yubiKeyShowChalResp: true, // show YubiKey challenge-response option
canOpen: true, // can select and open new files
canOpenDemo: true, // can open a demo file
canOpenSettings: true, // can go to settings

View File

@ -14,7 +14,8 @@ const Links = {
Translation: 'https://keeweb.oneskyapp.com/',
Donation: 'https://opencollective.com/keeweb#support',
Plugins: 'https://plugins.keeweb.info',
PluginDevelopStart: 'https://github.com/keeweb/keeweb/wiki/Plugins'
PluginDevelopStart: 'https://github.com/keeweb/keeweb/wiki/Plugins',
YubiKeyManual: 'https://github.com/keeweb/keeweb/wiki/YubiKey'
};
export { Links };

View File

@ -582,6 +582,16 @@
"setDevicesTitle": "Devices",
"setDevicesEnableUsb": "Enable interaction with USB devices",
"setDevicesYubiKeyIntro": "It's recommended to read {} before using YubiKey.",
"setDevicesYubiKeyIntroLink": "this document",
"setDevicesYubiKeyOtpTitle": "One-time codes",
"setDevicesYubiKeyOtpDesc": "YubiKey can be used to generate one-time codes for different services.",
"setDevicesYubiKeyOtpShowIcon": "Show the icon on the start screen",
"setDevicesYubiKeyOtpAutoOpen": "Automatically load one-time codes when there are open files",
"setDevicesYubiKeyOtpMatchEntries": "Show matching one-time codes in entries",
"setDevicesYubiKeyChalRespTitle": "Challenge-Response",
"setDevicesYubiKeyChalRespDesc": "It's also possible to use YubiKey in challenge-response mode, so that a piece of private key used to encrypt files resides on a YubiKey.",
"setDevicesYubiKeyChalRespShow": "Show an option to use YubiKey when opening files",
"setAboutTitle": "About",
"setAboutBuilt": "This app is built with these awesome tools",

View File

@ -35,7 +35,7 @@ class OpenView extends View {
'click .open__icon-open': 'openFile',
'click .open__icon-new': 'createNew',
'click .open__icon-demo': 'createDemo',
'click .open__icon-otp-device': 'openOtpDevice',
'click .open__icon-yubikey': 'openYubiKey',
'click .open__icon-more': 'toggleMore',
'click .open__icon-storage': 'openStorage',
'click .open__icon-settings': 'openSettings',
@ -101,6 +101,11 @@ class OpenView extends View {
!this.model.settings.canOpen &&
!this.model.settings.canCreate &&
!(this.model.settings.canOpenDemo && !this.model.settings.demoOpened);
const canOpenYubiKey =
this.model.settings.canOpenOtpDevice &&
this.model.settings.yubiKeyShowIcon &&
!!UsbListener.attachedYubiKeys.length;
super.render({
lastOpenFiles: this.getLastOpenFiles(),
canOpenKeyFromDropbox: !Launcher && Storage.dropbox.enabled,
@ -112,8 +117,7 @@ class OpenView extends View {
canOpenGenerator: this.model.settings.canOpenGenerator,
canCreate: this.model.settings.canCreate,
canRemoveLatest: this.model.settings.canRemoveLatest,
canOpenOtpDevice:
this.model.settings.canOpenOtpDevice && !!UsbListener.attachedYubiKeys.length,
canOpenYubiKey,
showMore,
showLogo
});
@ -975,11 +979,13 @@ class OpenView extends View {
}
usbDevicesChanged() {
const hasYubiKeys = !!UsbListener.attachedYubiKeys.length;
this.$el.find('.open__icon-otp-device').toggleClass('hide', !hasYubiKeys);
if (this.model.settings.canOpenOtpDevice && this.model.settings.yubiKeyShowIcon) {
const hasYubiKeys = !!UsbListener.attachedYubiKeys.length;
this.$el.find('.open__icon-yubikey').toggleClass('hide', !hasYubiKeys);
}
}
openOtpDevice() {
openYubiKey() {
return Events.emit('toggle-settings', 'devices');
if (this.busy && this.otpDevice) {
this.otpDevice.cancelOpen();

View File

@ -1,17 +1,27 @@
import { View } from 'framework/views/view';
import { AppSettingsModel } from 'models/app-settings-model';
import template from 'templates/settings/settings-devices.hbs';
import { Links } from 'const/links';
class SettingsDevicesView extends View {
template = template;
events = {
'change .settings__devices-enable-usb': 'changeEnableUsb'
'change .settings__devices-enable-usb': 'changeEnableUsb',
'change .settings__yubikey-show-icon': 'changeYubiKeyShowIcon',
'change .settings__yubikey-auto-open': 'changeYubiKeyAutoOpen',
'change .settings__yubikey-match-entries': 'changeYubiKeyMatchEntries',
'change .settings__yubikey-chalresp-show': 'changeYubiKeyShowChalResp'
};
render() {
super.render({
enableUsb: AppSettingsModel.enableUsb
enableUsb: AppSettingsModel.enableUsb,
yubiKeyShowIcon: AppSettingsModel.yubiKeyShowIcon,
yubiKeyAutoOpen: AppSettingsModel.yubiKeyAutoOpen,
yubiKeyMatchEntries: AppSettingsModel.yubiKeyMatchEntries,
yubiKeyShowChalResp: AppSettingsModel.yubiKeyShowChalResp,
yubiKeyManualLink: Links.YubiKeyManual
});
}
@ -19,6 +29,26 @@ class SettingsDevicesView extends View {
AppSettingsModel.enableUsb = e.target.checked;
this.render();
}
changeYubiKeyShowIcon(e) {
AppSettingsModel.yubiKeyShowIcon = e.target.checked;
this.render();
}
changeYubiKeyAutoOpen(e) {
AppSettingsModel.yubiKeyAutoOpen = e.target.checked;
this.render();
}
changeYubiKeyMatchEntries(e) {
AppSettingsModel.yubiKeyMatchEntries = e.target.checked;
this.render();
}
changeYubiKeyShowChalResp(e) {
AppSettingsModel.yubiKeyShowChalResp = e.target.checked;
this.render();
}
}
export { SettingsDevicesView };

View File

@ -13,8 +13,8 @@
<div class="open__icon-text">{{res 'openNew'}}</div>
</div>
{{/if}}
<div class="open__icon open__icon-otp-device svg-btn {{#unless canOpenOtpDevice}}hide{{/unless}}"
tabindex="3" id="open__icon-otp-device">
<div class="open__icon open__icon-yubikey svg-btn {{#unless canOpenYubiKey}}hide{{/unless}}"
tabindex="3" id="open__icon-yubikey">
<div class="open__icon-svg">{{{svg 'usb-token'}}}</div>
<div class="open__icon-text">YubiKey</div>
</div>

View File

@ -8,5 +8,30 @@
{{#if enableUsb}}
<h2>YubiKey</h2>
<p>{{#res 'setDevicesYubiKeyIntro'}}<a href="{{yubiKeyManualLink}}" target="_blank">{{res 'setDevicesYubiKeyIntroLink'}}</a>{{/res}}</p>
<h3>{{res 'setDevicesYubiKeyOtpTitle'}}</h3>
<p>{{res 'setDevicesYubiKeyOtpDesc'}}</p>
<div>
<input type="checkbox" class="settings__input input-base settings__yubikey-show-icon" id="settings__yubikey-show-icon"
{{#if yubiKeyShowIcon}}checked{{/if}} />
<label for="settings__yubikey-show-icon">{{res 'setDevicesYubiKeyOtpShowIcon'}}</label>
</div>
<div>
<input type="checkbox" class="settings__input input-base settings__yubikey-auto-open" id="settings__yubikey-auto-open"
{{#if yubiKeyAutoOpen}}checked{{/if}} />
<label for="settings__yubikey-auto-open">{{res 'setDevicesYubiKeyOtpAutoOpen'}}</label>
</div>
<div>
<input type="checkbox" class="settings__input input-base settings__yubikey-match-entries" id="settings__yubikey-match-entries"
{{#if yubiKeyMatchEntries}}checked{{/if}} />
<label for="settings__yubikey-match-entries">{{res 'setDevicesYubiKeyOtpMatchEntries'}}</label>
</div>
<h3>{{res 'setDevicesYubiKeyChalRespTitle'}}</h3>
<p>{{res 'setDevicesYubiKeyChalRespDesc'}}</p>
<div>
<input type="checkbox" class="settings__input input-base settings__yubikey-chalresp-show" id="settings__yubikey-chalresp-show"
{{#if yubiKeyShowChalResp}}checked{{/if}} />
<label for="settings__yubikey-chalresp-show">{{res 'setDevicesYubiKeyChalRespShow'}}</label>
</div>
{{/if}}
</div>