Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
Merge pull request #17 from CER10TY/develop
Browse files Browse the repository at this point in the history
Move Remember PW into Settings
  • Loading branch information
Sören Johanson authored Jan 18, 2020
2 parents dfe51bb + 779b98e commit 7c73a9d
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lib/chrome-api-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function ChromePromiseApi() {
if (mfest !== undefined)
resolve(mfest)
else
reject("Uknown error while fetching manifest")
reject("Unknown error while fetching manifest")
})
}

Expand Down
24 changes: 11 additions & 13 deletions services/dropboxFileManager.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"use strict";
const Base64 = require('base64-arraybuffer')
const axios = require('axios')
import {
ChromePromiseApi
} from '$lib/chrome-api-promise.js'

import { random } from 'case';
import { ChromePromiseApi } from '$lib/chrome-api-promise';
import {
OauthManager
} from '$services/oauthManager.js'

const chromePromise = ChromePromiseApi()

const Base64 = require('base64-arraybuffer')
const axios = require('axios')

function DropboxFileManager(settings) {
var accessTokenType = 'dropbox';
Expand All @@ -19,8 +19,8 @@ function DropboxFileManager(settings) {

var oauth = {
accessTokenType: accessTokenType,
origins: ['https://*.dropbox.com/'],
authUrl: 'https://www.dropbox.com/oauth2/authorize?response_type=token&force_reapprove=false',
origins: ['https://dropbox.com/oauth2/'],
authUrl: 'https://dropbox.com/oauth2/authorize?response_type=token&reject_cors_preflight=true',
supportedFeatures: ['incognito', 'listDatabases'],
title: 'Dropbox',
icon: 'icon-dropbox',
Expand Down Expand Up @@ -88,8 +88,8 @@ function DropboxFileManager(settings) {
return Promise.resolve()
}

oauth.handleAuthRedirectURI = function (redirect_url, randomState, resolve, reject) {

oauth.handleAuthRedirectURI = function (redirect_url, randomState) {
console.info("OWL INFO - Redirect url:", redirect_url)
var tokenMatches = /access_token=([^&]+)/.exec(redirect_url);
var stateMatches = /state=([^&]+)/.exec(redirect_url);
var uidMatches = /uid=(\d+)/.exec(redirect_url);
Expand All @@ -101,16 +101,14 @@ function DropboxFileManager(settings) {
if (checkState === randomState) {
state.loggedIn = true;
settings.getSetAccessToken(accessTokenType, access_token).then(function () {
resolve(access_token);
return access_token;
});
} else {
//some sort of error or parsing failure
reject();
console.error("OWL ERROR - " + redirect_url, " - state was found invalid");
}
} else {
//some sort of error
reject();
console.error("OWL ERROR - " + redirect_url, " - something was found invalid");
}
}
Expand Down
2 changes: 1 addition & 1 deletion services/keepassService.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function KeepassService(keepassHeader, settings, passwordFileStoreRegistry, keep
return processReferences(entries, majorVersion);
});
} else { // KDB - we don't support this anymore
throw "Unsupported Database Version";
throw "Unsupported Database Version - Owl does not support .kdb formats! Please update to .kdbx instead.";
}
}).then(function (entries) {
return {
Expand Down
5 changes: 0 additions & 5 deletions services/oauthManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,16 @@ function OauthManager(settings, oauth) {

function auth(interactive) {
interactive = !!interactive;
console.info("OWL INFO - Authenticating for:", oauth.accessTokenType, interactive)

let authfunction = interactive => {
return new Promise(function (resolve, reject) {
chromePromise.runtime.getManifest().then(manifest => {
console.info("Owl auth flow is interactive", manifest, true)
console.info("Owl is using redirect url: ", chrome.identity.getRedirectURL(oauth.accessTokenType));
//random state, protects against CSRF
var randomState = Base64.encode(window.crypto.getRandomValues(new Uint8Array(16)));
var authUrl = oauth.authUrl +
'&client_id=' + manifest.static_data[oauth.accessTokenType].client_id +
'&state=' + encodeURIComponent(randomState) +
'&redirect_uri=' + encodeURIComponent(chrome.identity.getRedirectURL(oauth.accessTokenType));
console.info("OWL INFO - Sending request for AUTH to:", authUrl);
chromePromise.identity.launchWebAuthFlow({
'url': authUrl,
'interactive': interactive
Expand All @@ -205,7 +201,6 @@ function OauthManager(settings, oauth) {

// If the oauth provider has chosen to implement its own auth function.
authfunction = oauth.auth !== undefined ? oauth.auth : authfunction;

return ensureOriginPermissions().then(ensured => {
return authfunction(interactive).then(token => {
if (token) {
Expand Down
4 changes: 4 additions & 0 deletions services/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ function Settings(secureCache) {
return keyGetSetter('strictMatchModeEnabled', enabled, false, 'boolean')
}

exports.getSetRememberPasswordEnabled = function (enabled) {
return keyGetSetter('rememberPasswordEnabled', enabled, false, 'boolean')
}

exports.getSetNotificationsEnabled = function (enabledTypes) {
return keyGetSetter('notificationsEnabled', enabledTypes, ['clipboard', 'expiration'], 'object')
}
Expand Down
26 changes: 26 additions & 0 deletions src/components/AdvancedSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default {
]
},
strictMatchEnabled: false,
rememberPasswordEnabled: false,
notificationsEnabled: ['expiration'],
jsonState: [{
k: 'databaseUsages', // key
Expand Down Expand Up @@ -94,6 +95,9 @@ export default {
},
notificationsEnabled(newval) {
this.settings.getSetNotificationsEnabled(newval)
},
rememberPasswordEnabled(newval) {
this.settings.getSetRememberPasswordEnabled(newval)
}
},
methods: {
Expand Down Expand Up @@ -121,6 +125,9 @@ export default {
this.settings.getSetStrictModeEnabled().then(val => {
this.strictMatchEnabled = val;
})
this.settings.getSetRememberPasswordEnabled().then(val => {
this.rememberPasswordEnabled = val;
})
if (!isFirefox()) {
chrome.permissions.contains(this.allOriginPerms, granted => {
this.allOriginPermission = !!granted;
Expand Down Expand Up @@ -233,6 +240,25 @@ export default {
</div>
</div>

<div class="box-bar roomy">
<h4>Enable Remember Password</h4>
<p>Currently, Owl cannot update your database entries when auto-unlocking is enabled.
To enable auto-updating, the Remember Password functionality was hidden. You can re-enable this functionality here, but please keep in mind that you will have to <b>lock and unlock</b>
your database to refresh entries.
</p>
</div>
<div class="box-bar roomy lighter">
<div>
<div class="switch">
<label>
<input type="checkbox" v-model="rememberPasswordEnabled">
<span class="lever"></span>
Remember Password
</label>
</div>
</div>
</div>

<div class="box-bar roomy">
<h4>Stored Data</h4>
<p>The following objects represent the current data cached in local storage. This data is only available to Owl, and is never sent over any network connection.</p>
Expand Down
2 changes: 0 additions & 2 deletions src/components/EntryListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ export default {
},
autofill(e) {
e.stopPropagation()
console.log("autofill")
this.unlockedState.autofill(this.entry);
},
copy(e) {
e.stopPropagation()
console.log("copy")
this.unlockedState.copyPassword(this.entry);
}
}
Expand Down
18 changes: 12 additions & 6 deletions src/components/Unlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default {
rememberPeriodText: "",
databaseFileName: "",
keyFilePicker: false,
rememberPasswordEnabled: false,
appVersion: chrome.runtime.getManifest().version,
slider_options: [{
time: 0,
Expand Down Expand Up @@ -178,14 +179,16 @@ export default {
}
if (priorityEntries.length == 0) {
this.unlockedMessages.warn = "No matches found for this site."
// TODO add maybe show all passwords instead
// Security?
}
// Cache in memory
this.unlockedState.cacheSet('allEntries', allEntries)
this.unlockedState.cacheSet('priorityEntries', priorityEntries)
this.$forceUpdate()
//save longer term (in encrypted storage)
this.secureCache.save('secureCache.entries', entries);
this.secureCache.save('secureCache.entries', entries); // ref https://github.com/CER10TY/Owl/issues/8
this.busy = false
})
},
Expand Down Expand Up @@ -249,6 +252,10 @@ export default {
}
},
async mounted() {
// Add remember password
this.settings.getSetRememberPasswordEnabled().then(enabled => {
this.rememberPasswordEnabled = enabled
})
// modify unlockedState internal state
await this.unlockedState.getTabDetails();
Expand Down Expand Up @@ -295,14 +302,13 @@ export default {
this.busy = true
try {
let entries = await this.secureCache.get('secureCache.entries');
if (entries !== undefined && entries.length > 0) {
if (entries !== undefined && entries.length > 0 && this.rememberPeriod > 0) {
this.showResults(entries)
} else {
try_autounlock()
}
} catch (err) {
console.error("OWL ERROR - " + err);
//this is fine - it just means the cache expired. Clear the cache to be sure.
//this is fine - it just means the cache expired. Clear the cache to be sure.
this.secureCache.clear('secureCache.entries')
try_autounlock()
Expand Down Expand Up @@ -373,8 +379,8 @@ export default {
</div>
</transition>
</div>

<div class="box-bar small plain remember-period-picker">
<!-- @TODO - Re-enable the remember box, eventually -->
<div class="box-bar small plain remember-period-picker" v-if="rememberPasswordEnabled">
<span>
<label for="rememberPeriodLength">
<span>{{rememberPeriodText}} (slide to choose)</span></label>
Expand Down
18 changes: 14 additions & 4 deletions src/components/WebdavProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,29 @@ export default {
}).then(() => {
this.providerManager.addServer(this.webdav.url, this.webdav.username, this.webdav.password).then(serverInfo => {
// do somethings
this.messages.error = ""
return this.updateServerList().then(() => {
this.scan(serverInfo.serverId)
})
}).catch(err => {
console.error(err.toString())
// Very specific error msg, but makes it more human readable later - ref https://github.com/CER10TY/Owl/issues/11
if (err.toString() === "TypeError: serverListItem is undefined") {
this.messages.error = "Error: Server already defined"
} else {
this.messages.error = err.toString()
this.messages.error = "Error: Server already defined!"
}
// Discard other error messages from front end for now - many coming through that don't affect day to day.
else {
console.error("Owl: Error - ", err.toString())
}
})
}).catch(err => {
this.messages.error = err.toString()
if (err.toString() === "TypeError: Cannot set property 'scanBusy' of undefined") {
// Do nothing, cause it's a garbage error
} else if (err.toString() === "Error: Invalid value for origin pattern : Missing scheme separator.") {
this.messages.error = "Error: Server address is undefined!"
} else {
this.messages.error = err.toString()
}
})
},
setBusy(serverId, busy) {
Expand Down

0 comments on commit 7c73a9d

Please sign in to comment.