Touch ID settings, see #679

This commit is contained in:
antelle 2021-02-01 22:24:53 +01:00
parent acd360efb9
commit 4cdc80e530
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
6 changed files with 82 additions and 9 deletions

View File

@ -43,6 +43,8 @@ const DefaultAppSettings = {
checkPasswordsOnHIBP: false, // check passwords on Have I Been Pwned
auditPasswordAge: 0, // show warnings about old passwords, number of years, 0 = disabled
useLegacyAutoType: false, // use legacy auto-type engine (will be removed in future versions)
deviceOwnerAuth: null, // Touch ID: null / 'unlock' / 'credentials'
deviceOwnerAuthTimeoutMinutes: 0, // how often master password is required with Touch ID
yubiKeyShowIcon: true, // show an icon to open OTP codes from YubiKey
yubiKeyAutoOpen: false, // auto-load one-time codes when there are open files

View File

@ -12,10 +12,14 @@ Handlebars.registerHelper('res', function (key, options) {
return value;
});
Handlebars.registerHelper('Res', (key) => {
Handlebars.registerHelper('Res', (key, options) => {
let value = Locale[key];
if (value) {
value = value[0].toUpperCase() + value.substr(1);
const ix = value.indexOf('{}');
if (ix >= 0) {
value = value.replace('{}', options.fn(this));
}
}
return value;
});

View File

@ -26,6 +26,15 @@
"shiftKey": "shift",
"altKey": "alt",
"error": "error",
"oneMinute": "one minute",
"minutes": "{} minutes",
"oneHour": "one hour",
"hours": "{} hours",
"oneDay": "one day",
"days": "{} days",
"oneWeek": "one week",
"oneMonth": "one month",
"oneYear": "one year",
"cache": "cache",
"file": "file",
@ -449,6 +458,11 @@
"setGenReloadApp": "Reload the app",
"setGenFieldLabelDblClickAutoType": "Auto-type on double-clicking field labels",
"setGenUseLegacyAutoType": "Use legacy auto-type (if you have issues)",
"setGenTouchId": "Touch ID",
"setGenTouchIdDisabled": "Don't use Touch ID",
"setGenTouchIdUnlock": "Unlock with Touch ID only after automatic locking",
"setGenTouchIdCredentials": "Use Touch ID instead of master password",
"setGenTouchIdPass": "Require master password after",
"setGenAudit": "Audit",
"setGenAuditPasswords": "Show warnings about password strength",
"setGenAuditPasswordEntropy": "Check password length and randomness",

View File

@ -75,3 +75,7 @@ export function isEqual(a, b) {
}
return false;
}
export function minmax(val, min, max) {
return Math.min(max, Math.max(min, val));
}

View File

@ -16,7 +16,7 @@ import { DateFormat } from 'comp/i18n/date-format';
import { Locale } from 'util/locale';
import { SettingsLogsView } from 'views/settings/settings-logs-view';
import { SettingsPrvView } from 'views/settings/settings-prv-view';
import { mapObject } from 'util/fn';
import { mapObject, minmax } from 'util/fn';
import { ThemeWatcher } from 'comp/browser/theme-watcher';
import template from 'templates/settings/settings-general.hbs';
@ -53,7 +53,9 @@ class SettingsGeneralView extends View {
'change .settings__general-direct-autotype': 'changeDirectAutotype',
'change .settings__general-field-label-dblclick-autotype':
'changeFieldLabelDblClickAutoType',
'change .settings__general-field-label-legacy-autotype': 'changeUseLegacyAutoType',
'change .settings__general-use-legacy-autotype': 'changeUseLegacyAutoType',
'change .settings__general-device-owner-auth': 'changeDeviceOwnerAuth',
'change .settings__general-device-owner-auth-timeout': 'changeDeviceOwnerAuthTimeout',
'change .settings__general-titlebar-style': 'changeTitlebarStyle',
'click .settings__general-update-btn': 'checkUpdate',
'click .settings__general-restart-btn': 'installUpdateAndRestart',
@ -134,7 +136,10 @@ class SettingsGeneralView extends View {
supportsTitleBarStyles: Launcher && Features.supportsTitleBarStyles(),
titlebarStyle: AppSettingsModel.titlebarStyle,
storageProviders,
showReloadApp: Features.isStandalone
showReloadApp: Features.isStandalone,
hasDeviceOwnerAuth: Launcher && Features.isMac,
deviceOwnerAuth: AppSettingsModel.deviceOwnerAuth,
deviceOwnerAuthTimeout: AppSettingsModel.deviceOwnerAuthTimeoutMinutes
});
this.renderProviderViews(storageProviders);
}
@ -407,13 +412,11 @@ class SettingsGeneralView extends View {
changeUseGroupIconForEntries(e) {
const useGroupIconForEntries = e.target.checked || false;
AppSettingsModel.useGroupIconForEntries = useGroupIconForEntries;
Events.emit('refresh');
}
changeDirectAutotype(e) {
const directAutotype = e.target.checked || false;
AppSettingsModel.directAutotype = directAutotype;
Events.emit('refresh');
}
changeFieldLabelDblClickAutoType(e) {
@ -428,6 +431,25 @@ class SettingsGeneralView extends View {
Events.emit('refresh');
}
changeDeviceOwnerAuth(e) {
const deviceOwnerAuth = e.target.value || null;
let deviceOwnerAuthTimeoutMinutes = AppSettingsModel.deviceOwnerAuthTimeoutMinutes | 0;
if (deviceOwnerAuth) {
const timeouts = { unlock: [30, 10080], credentials: [30, 525600] };
const [tMin, tMax] = timeouts[deviceOwnerAuth] || [0, 0];
deviceOwnerAuthTimeoutMinutes = minmax(deviceOwnerAuthTimeoutMinutes, tMin, tMax);
}
AppSettingsModel.set({ deviceOwnerAuth, deviceOwnerAuthTimeoutMinutes });
this.render();
}
changeDeviceOwnerAuthTimeout(e) {
const deviceOwnerAuthTimeout = e.target.value | 0;
AppSettingsModel.deviceOwnerAuthTimeoutMinutes = deviceOwnerAuthTimeout;
}
installUpdateAndRestart() {
if (Launcher) {
Updater.installAndRestart();

View File

@ -176,6 +176,33 @@
id="settings__general-use-group-icon-for-entries" {{#if useGroupIconForEntries}}checked{{/if}} />
<label for="settings__general-use-group-icon-for-entries">{{res 'setGenUseGroupIconForEntries'}}</label>
</div>
{{#if hasDeviceOwnerAuth}}
<div>
<label for="settings__general-device-owner-auth">{{res 'setGenTouchId'}}:</label>
<select class="settings__general-device-owner-auth settings__select input-base" id="settings__general-device-owner-auth">
<option value="" {{#unless deviceOwnerAuth}}selected{{/unless}}>{{res 'setGenTouchIdDisabled'}}</option>
<option value="unlock" {{#ifeq deviceOwnerAuth 'unlock'}}selected{{/ifeq}}>{{res 'setGenTouchIdUnlock'}}</option>
<option value="credentials" {{#ifeq deviceOwnerAuth 'credentials'}}selected{{/ifeq}}>{{res 'setGenTouchIdCredentials'}}</option>
</select>
</div>
{{#if deviceOwnerAuth}}
<label for="settings__general-device-owner-auth-timeout">{{res 'setGenTouchIdPass'}}:</label>
<select class="settings__general-device-owner-auth-timeout settings__select input-base" id="settings__general-device-owner-auth-timeout">
<option value="1" {{#ifeq deviceOwnerAuthTimeout 1}}selected{{/ifeq}}>{{Res 'oneMinute'}}</option>
<option value="5" {{#ifeq deviceOwnerAuthTimeout 5}}selected{{/ifeq}}>{{#Res 'minutes'}}5{{/Res}}</option>
<option value="30" {{#ifeq deviceOwnerAuthTimeout 30}}selected{{/ifeq}}>{{#Res 'minutes'}}30{{/Res}}</option>
<option value="60" {{#ifeq deviceOwnerAuthTimeout 60}}selected{{/ifeq}}>{{Res 'oneHour'}}</option>
<option value="120" {{#ifeq deviceOwnerAuthTimeout 120}}selected{{/ifeq}}>{{#Res 'hours'}}2{{/Res}}</option>
<option value="480" {{#ifeq deviceOwnerAuthTimeout 480}}selected{{/ifeq}}>{{#Res 'hours'}}8{{/Res}}</option>
<option value="1440" {{#ifeq deviceOwnerAuthTimeout 1440}}selected{{/ifeq}}>{{Res 'oneDay'}}</option>
<option value="10080" {{#ifeq deviceOwnerAuthTimeout 10080}}selected{{/ifeq}}>{{Res 'oneWeek'}}</option>
{{#ifeq deviceOwnerAuth 'credentials'}}
<option value="43200" {{#ifeq deviceOwnerAuthTimeout 43200}}selected{{/ifeq}}>{{Res 'oneMonth'}}</option>
<option value="525600" {{#ifeq deviceOwnerAuthTimeout 525600}}selected{{/ifeq}}>{{Res 'oneYear'}}</option>
{{/ifeq}}
</select>
{{/if}}
{{/if}}
<h2 id="audit">{{res 'setGenAudit'}}</h2>
<div>
@ -288,9 +315,9 @@
<div class="settings__general-advanced hide">
{{#if canAutoType}}
<div>
<input type="checkbox" class="settings__input input-base settings__general-field-label-legacy-autotype"
id="settings__general-field-label-use-legacy-autotype" {{#if useLegacyAutoType}}checked{{/if}} />
<label for="settings__general-field-label-use-legacy-autotype">{{res 'setGenUseLegacyAutoType'}}</label>
<input type="checkbox" class="settings__input input-base settings__general-use-legacy-autotype"
id="settings__general-use-legacy-autotype" {{#if useLegacyAutoType}}checked{{/if}} />
<label for="settings__general-use-legacy-autotype">{{res 'setGenUseLegacyAutoType'}}</label>
</div>
{{/if}}
{{#if devTools}}