🔒 Enables sensetive data to be passed by env var

This commit is contained in:
Alicia Sykes 2024-04-14 20:50:03 +01:00
parent 75f65de8f6
commit 25e774ca79
26 changed files with 54 additions and 51 deletions

View File

@ -26,7 +26,7 @@ export default {
/* URL/ IP or hostname to the AdGuardHome instance, without trailing slash */ /* URL/ IP or hostname to the AdGuardHome instance, without trailing slash */
hostname() { hostname() {
if (!this.options.hostname) this.error('You must specify the path to your AdGuard server'); if (!this.options.hostname) this.error('You must specify the path to your AdGuard server');
return this.options.hostname; return this.parseAsEnvVar(this.options.hostname);
}, },
showFullInfo() { showFullInfo() {
return this.options.showFullInfo; return this.options.showFullInfo;
@ -39,7 +39,9 @@ export default {
}, },
authHeaders() { authHeaders() {
if (this.options.username && this.options.password) { if (this.options.username && this.options.password) {
const encoded = window.btoa(`${this.options.username}:${this.options.password}`); const password = this.parseAsEnvVar(this.options.password);
const username = this.parseAsEnvVar(this.options.username);
const encoded = window.btoa(`${username}:${password}`);
return { Authorization: `Basic ${encoded}` }; return { Authorization: `Basic ${encoded}` };
} }
return {}; return {};

View File

@ -38,7 +38,7 @@ export default {
/* URL/ IP or hostname to the AdGuardHome instance, without trailing slash */ /* URL/ IP or hostname to the AdGuardHome instance, without trailing slash */
hostname() { hostname() {
if (!this.options.hostname) this.error('You must specify the path to your AdGuard server'); if (!this.options.hostname) this.error('You must specify the path to your AdGuard server');
return this.options.hostname; return this.parseAsEnvVar(this.options.hostname);
}, },
showOnOffStatusOnly() { showOnOffStatusOnly() {
return this.options.showOnOffStatusOnly; return this.options.showOnOffStatusOnly;
@ -48,7 +48,9 @@ export default {
}, },
authHeaders() { authHeaders() {
if (this.options.username && this.options.password) { if (this.options.username && this.options.password) {
const encoded = window.btoa(`${this.options.username}:${this.options.password}`); const username = this.parseAsEnvVar(this.options.username);
const password = this.parseAsEnvVar(this.options.password);
const encoded = window.btoa(`${username}:${password}`);
return { Authorization: `Basic ${encoded}` }; return { Authorization: `Basic ${encoded}` };
} }
return {}; return {};

View File

@ -20,14 +20,16 @@ export default {
/* URL/ IP or hostname to the AdGuardHome instance, without trailing slash */ /* URL/ IP or hostname to the AdGuardHome instance, without trailing slash */
hostname() { hostname() {
if (!this.options.hostname) this.error('You must specify the path to your AdGuard server'); if (!this.options.hostname) this.error('You must specify the path to your AdGuard server');
return this.options.hostname; return this.parseAsEnvVar(this.options.hostname);
}, },
endpoint() { endpoint() {
return `${this.hostname}/control/stats`; return `${this.hostname}/control/stats`;
}, },
authHeaders() { authHeaders() {
if (this.options.username && this.options.password) { if (this.options.username && this.options.password) {
const encoded = window.btoa(`${this.options.username}:${this.options.password}`); const username = this.parseAsEnvVar(this.options.username);
const password = this.parseAsEnvVar(this.options.password);
const encoded = window.btoa(`${username}:${password}`);
return { Authorization: `Basic ${encoded}` }; return { Authorization: `Basic ${encoded}` };
} }
return {}; return {};

View File

@ -36,11 +36,13 @@ export default {
/* URL/ IP or hostname to the AdGuardHome instance, without trailing slash */ /* URL/ IP or hostname to the AdGuardHome instance, without trailing slash */
hostname() { hostname() {
if (!this.options.hostname) this.error('You must specify the path to your AdGuard server'); if (!this.options.hostname) this.error('You must specify the path to your AdGuard server');
return this.options.hostname; return this.parseAsEnvVar(this.options.hostname);
}, },
authHeaders() { authHeaders() {
if (this.options.username && this.options.password) { if (this.options.username && this.options.password) {
const encoded = window.btoa(`${this.options.username}:${this.options.password}`); const username = this.parseAsEnvVar(this.options.username);
const password = this.parseAsEnvVar(this.options.password);
const encoded = window.btoa(`${username}:${password}`);
return { Authorization: `Basic ${encoded}` }; return { Authorization: `Basic ${encoded}` };
} }
return {}; return {};

View File

@ -113,7 +113,7 @@ export default {
}, },
computed: { computed: {
hostname() { hostname() {
return this.options.hostname || widgetApiEndpoints.anonAddy; return this.parseAsEnvVar(this.options.hostname) || widgetApiEndpoints.anonAddy;
}, },
apiVersion() { apiVersion() {
return this.options.apiVersion || 'v1'; return this.options.apiVersion || 'v1';
@ -132,7 +132,7 @@ export default {
}, },
apiKey() { apiKey() {
if (!this.options.apiKey) this.error('An apiKey is required'); if (!this.options.apiKey) this.error('An apiKey is required');
return this.options.apiKey; return this.parseAsEnvVar(this.options.apiKey);
}, },
hideMeta() { hideMeta() {
return this.options.hideMeta; return this.options.hideMeta;

View File

@ -35,7 +35,7 @@ export default {
}, },
apiKey() { apiKey() {
if (!this.options.apiKey) this.error('Missing API Key'); if (!this.options.apiKey) this.error('Missing API Key');
return this.options.apiKey; return this.parseAsEnvVar(this.options.apiKey);
}, },
endpoint() { endpoint() {
return `${widgetApiEndpoints.blacklistCheck}/${this.ipAddress}`; return `${widgetApiEndpoints.blacklistCheck}/${this.ipAddress}`;

View File

@ -38,12 +38,12 @@ export default {
/* The username to fetch data from - REQUIRED */ /* The username to fetch data from - REQUIRED */
username() { username() {
if (!this.options.username) this.error('You must specify a username'); if (!this.options.username) this.error('You must specify a username');
return this.options.username; return this.parseAsEnvVar(this.options.username);
}, },
/* Optionally override hostname, if using a self-hosted instance */ /* Optionally override hostname, if using a self-hosted instance */
hostname() { hostname() {
if (this.options.hostname) return this.options.hostname; if (this.options.hostname) return this.options.hostname;
return widgetApiEndpoints.codeStats; return this.parseAsEnvVar(widgetApiEndpoints.codeStats);
}, },
hideMeta() { hideMeta() {
return this.options.hideMeta || false; return this.options.hideMeta || false;

View File

@ -63,11 +63,11 @@ export default {
computed: { computed: {
apiKey() { apiKey() {
if (!this.options.apiKey) this.error('Missing API Key'); if (!this.options.apiKey) this.error('Missing API Key');
return this.options.apiKey; return this.parseAsEnvVar(this.options.apiKey);
}, },
domain() { domain() {
if (!this.options.domain) this.error('Missing Domain Name Key'); if (!this.options.domain) this.error('Missing Domain Name Key');
return this.options.domain; return this.parseAsEnvVar(this.options.domain);
}, },
endpoint() { endpoint() {
return `${widgetApiEndpoints.domainMonitor}/?domain=${this.domain}&r=whois&apikey=${this.apiKey}`; return `${widgetApiEndpoints.domainMonitor}/?domain=${this.domain}&r=whois&apikey=${this.apiKey}`;

View File

@ -106,7 +106,7 @@ export default {
if (!this.options.apiKey) { if (!this.options.apiKey) {
this.error('An API key is required, please see the docs for more info'); this.error('An API key is required, please see the docs for more info');
} }
return this.options.apiKey; return this.parseAsEnvVar(this.options.apiKey);
}, },
}, },
methods: { methods: {

View File

@ -45,7 +45,7 @@ export default {
computed: { computed: {
/* The users API key for exchangerate-api.com */ /* The users API key for exchangerate-api.com */
apiKey() { apiKey() {
return this.options.apiKey; return this.parseAsEnvVar(this.options.apiKey);
}, },
/* The currency to convert results into */ /* The currency to convert results into */
inputCurrency() { inputCurrency() {

View File

@ -71,7 +71,7 @@ export default {
this.error('An API key must be supplied'); this.error('An API key must be supplied');
return ''; return '';
} }
return usersChoice; return this.parseAsEnvVar(usersChoice);
}, },
/* The direction of flights: Arrival, Departure or Both */ /* The direction of flights: Arrival, Departure or Both */
direction() { direction() {

View File

@ -58,7 +58,7 @@ export default {
}, },
hostname() { hostname() {
if (!this.options.hostname) this.error('`hostname` is required'); if (!this.options.hostname) this.error('`hostname` is required');
return this.options.hostname; return this.parseAsEnvVar(this.options.hostname);
}, },
}, },
methods: { methods: {

View File

@ -56,7 +56,7 @@ export default {
this.error('An API key is required, please see the docs for more info'); this.error('An API key is required, please see the docs for more info');
} }
if (typeof this.options.apiKey === 'string') { if (typeof this.options.apiKey === 'string') {
return [this.options.apiKey]; return [this.parseAsEnvVar(this.options.apiKey)];
} }
return this.options.apiKey; return this.options.apiKey;
}, },

View File

@ -30,11 +30,11 @@ export default {
computed: { computed: {
endpoint() { endpoint() {
if (!this.options.host) this.error('linkgding Host is required'); if (!this.options.host) this.error('linkgding Host is required');
return `${this.options.host}/api/bookmarks`; return `${this.parseAsEnvVar(this.options.host)}/api/bookmarks`;
}, },
apiKey() { apiKey() {
if (!this.options.apiKey) this.error('linkgding apiKey is required'); if (!this.options.apiKey) this.error('linkgding apiKey is required');
return this.options.apiKey; return this.parseAsEnvVar(this.options.apiKey);
}, },
filtertags() { filtertags() {
return this.options.tags; return this.options.tags;

View File

@ -29,7 +29,7 @@ export default {
computed: { computed: {
apiKey() { apiKey() {
if (!this.options.apiKey) this.error('An API key is required, see docs for more info'); if (!this.options.apiKey) this.error('An API key is required, see docs for more info');
return this.options.apiKey; return this.parseAsEnvVar(this.options.apiKey);
}, },
country() { country() {
return this.options.country ? `&country=${this.options.country}` : ''; return this.options.country ? `&country=${this.options.country}` : '';

View File

@ -22,7 +22,7 @@
</span> </span>
<span v-if="canDeleteNotification('delete')"> <span v-if="canDeleteNotification('delete')">
<a @click="deleteNotification(notification.notification_id)" <a @click="deleteNotification(notification.notification_id)"
class="action secondary">{{ tt('delete-notification') }}</a> class="action secondary">{{ tt('delete-notification') }}</a>
</span> </span>
</p> </p>
</div> </div>

View File

@ -44,7 +44,7 @@
<em v-html="formatNumber(shares.num_shares)"></em> <em v-html="formatNumber(shares.num_shares)"></em>
<strong>{{ tt('local') }}</strong> <small> {{ tt('and') }}</small> <strong>{{ tt('local') }}</strong> <small> {{ tt('and') }}</small>
<em v-html="formatNumber(shares.num_fed_shares_sent <em v-html="formatNumber(shares.num_fed_shares_sent
+ shares.num_fed_shares_received)"></em> + shares.num_fed_shares_received)"></em>
<strong> <strong>
{{ tt('federated-shares') }} {{ tt('federated-shares') }}
</strong> </strong>

View File

@ -34,22 +34,22 @@ export default {
computed: { computed: {
clusterUrl() { clusterUrl() {
if (!this.options.cluster_url) this.error('The cluster URL is required.'); if (!this.options.cluster_url) this.error('The cluster URL is required.');
return this.options.cluster_url || ''; return this.parseAsEnvVar(this.options.cluster_url) || '';
}, },
userName() { userName() {
if (!this.options.user_name) this.error('The user name is required.'); if (!this.options.user_name) this.error('The user name is required.');
return this.options.user_name || ''; return this.parseAsEnvVar(this.options.user_name) || '';
}, },
tokenName() { tokenName() {
if (!this.options.token_name) this.error('The token name is required.'); if (!this.options.token_name) this.error('The token name is required.');
return this.options.token_name || ''; return this.parseAsEnvVar(this.options.token_name) || '';
}, },
tokenUuid() { tokenUuid() {
if (!this.options.token_uuid) this.error('The token uuid is required.'); if (!this.options.token_uuid) this.error('The token uuid is required.');
return this.options.token_uuid || ''; return this.parseAsEnvVar(this.options.token_uuid) || '';
}, },
node() { node() {
return this.options.node || ''; return this.parseAsEnvVar(this.options.node) || '';
}, },
nodeData() { nodeData() {
return this.options.node_data || false; return this.options.node_data || false;

View File

@ -35,7 +35,7 @@ export default {
}, },
provider() { provider() {
// Can be either `ip-api`, `ipapi.co` or `ipgeolocation` // Can be either `ip-api`, `ipapi.co` or `ipgeolocation`
return this.options.provider || 'ipapi.co'; return this.parseAsEnvVar(this.options.provider) || 'ipapi.co';
}, },
}, },
data() { data() {

View File

@ -51,7 +51,7 @@ export default {
return this.options.rssUrl || ''; return this.options.rssUrl || '';
}, },
apiKey() { apiKey() {
return this.options.apiKey; return this.parseAsEnvVar(this.options.apiKey);
}, },
parseLocally() { parseLocally() {
return this.options.parseLocally; return this.options.parseLocally;

View File

@ -93,7 +93,7 @@ export default {
return this.options.leagueId; return this.options.leagueId;
}, },
apiKey() { apiKey() {
return this.options.apiKey || '50130162'; return this.parseAsEnvVar(this.options.apiKey) || '50130162';
}, },
limit() { limit() {
return this.options.limit || 20; return this.options.limit || 20;

View File

@ -29,7 +29,7 @@ export default {
}, },
/* The users API key for AlphaVantage */ /* The users API key for AlphaVantage */
apiKey() { apiKey() {
return this.options.apiKey; return this.parseAsEnvVar(this.options.apiKey);
}, },
/* The formatted GET request API endpoint to fetch stock data from */ /* The formatted GET request API endpoint to fetch stock data from */
endpoint() { endpoint() {

View File

@ -45,15 +45,15 @@ export default {
computed: { computed: {
hostname() { hostname() {
if (!this.options.hostname) this.error('A hostname is required'); if (!this.options.hostname) this.error('A hostname is required');
return this.options.hostname; return this.parseAsEnvVar(this.options.hostname);
}, },
username() { username() {
if (!this.options.username) this.error('A username is required'); if (!this.options.username) this.error('A username is required');
return this.options.username; return this.parseAsEnvVar(this.options.username);
}, },
password() { password() {
if (!this.options.password) this.error('A password is required'); if (!this.options.password) this.error('A password is required');
return this.options.password; return this.parseAsEnvVar(this.options.password);
}, },
endpointLogin() { endpointLogin() {
return `${this.hostname}/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=${this.username}&passwd=${this.password}&session=DownloadStation&format=sid`; return `${this.hostname}/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=${this.username}&passwd=${this.password}&session=DownloadStation&format=sid`;

View File

@ -52,15 +52,11 @@ export default {
computed: { computed: {
/* Get API key for access to instance */ /* Get API key for access to instance */
apiKey() { apiKey() {
const { apiKey } = this.options; return this.parseAsEnvVar(this.options.apiKey);
return apiKey;
}, },
/* Get instance URL */ /* Get instance URL */
url() { url() {
const { url } = this.options; return this.parseAsEnvVar(this.options.url);
return url;
}, },
/* Create authorisation header for the instance from the apiKey */ /* Create authorisation header for the instance from the apiKey */
authHeaders() { authHeaders() {

View File

@ -53,7 +53,7 @@ export default {
}, },
address() { address() {
if (!this.options.address) this.error('You must specify a public address'); if (!this.options.address) this.error('You must specify a public address');
return this.options.address; return this.parseAsEnvVar(this.options.address);
}, },
network() { network() {
return this.options.network || 'main'; return this.options.network || 'main';

View File

@ -46,13 +46,12 @@ export default {
return this.options.units || 'metric'; return this.options.units || 'metric';
}, },
endpoint() { endpoint() {
const { const apiKey = this.parseAsEnvVar(this.options.apiKey);
apiKey, city, lat, lon, const { city, lat, lon } = this.options;
} = this.options; const params = (lat && lon)
if (lat && lon) { ? `lat=${lat}&lon=${lon}&appid=${apiKey}&units=${this.units}`
return `${widgetApiEndpoints.weather}?lat=${lat}&lon=${lon}&appid=${apiKey}&units=${this.units}`; : `q=${city}&appid=${apiKey}&units=${this.units}`;
} return `${widgetApiEndpoints.weather}?${params}`;
return `${widgetApiEndpoints.weather}?q=${city}&appid=${apiKey}&units=${this.units}`;
}, },
tempDisplayUnits() { tempDisplayUnits() {
switch (this.units) { switch (this.units) {