Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

:passport_control: Adds auth to AdGuard widgets

Alicia Sykesf7bba8068ab7
diff --git a/src/components/Widgets/AdGuardFilterStatus.vue b/src/components/Widgets/AdGuardFilterStatus.vue
index 20a6481f..bf1899fe 100644
--- a/src/components/Widgets/AdGuardFilterStatus.vue
+++ b/src/components/Widgets/AdGuardFilterStatus.vue
@@ -46,6 +46,13 @@ export default {
endpoint() {
return `${this.hostname}/control/filtering/status`;
},
+ authHeaders() {
+ if (this.options.username && this.options.password) {
+ const encoded = window.btoa(`${this.options.username}:${this.options.password}`);
+ return { Authorization: `Basic ${encoded}` };
+ }
+ return {};
+ },
},
data() {
return {
@@ -62,7 +69,7 @@ export default {
methods: {
/* Make GET request to AdGuard endpoint */
fetchData() {
- this.makeRequest(this.endpoint).then(this.processData);
+ this.makeRequest(this.endpoint, this.authHeaders).then(this.processData);
},
/* Assign data variables to the returned data */
processData(data) {
diff --git a/src/components/Widgets/AdGuardStats.vue b/src/components/Widgets/AdGuardStats.vue
index 48ae5d69..3e497333 100644
--- a/src/components/Widgets/AdGuardStats.vue
+++ b/src/components/Widgets/AdGuardStats.vue
@@ -19,11 +19,18 @@ export default {
endpoint() {
return `${this.hostname}/control/stats`;
},
+ authHeaders() {
+ if (this.options.username && this.options.password) {
+ const encoded = window.btoa(`${this.options.username}:${this.options.password}`);
+ return { Authorization: `Basic ${encoded}` };
+ }
+ return {};
+ },
},
methods: {
/* Make GET request to AdGuard endpoint */
fetchData() {
- this.makeRequest(this.endpoint).then(this.processData);
+ this.makeRequest(this.endpoint, this.authHeaders).then(this.processData);
},
/* Assign data variables to the returned data */
processData(data) {
diff --git a/src/components/Widgets/AdGuardTopDomains.vue b/src/components/Widgets/AdGuardTopDomains.vue
index 7f343a7e..c914293e 100644
--- a/src/components/Widgets/AdGuardTopDomains.vue
+++ b/src/components/Widgets/AdGuardTopDomains.vue
@@ -38,6 +38,13 @@ export default {
if (!this.options.hostname) this.error('You must specify the path to your AdGuard server');
return this.options.hostname;
},
+ authHeaders() {
+ if (this.options.username && this.options.password) {
+ const encoded = window.btoa(`${this.options.username}:${this.options.password}`);
+ return { Authorization: `Basic ${encoded}` };
+ }
+ return {};
+ },
showOnOffStatusOnly() {
return this.options.showOnOffStatusOnly;
},
@@ -63,7 +70,7 @@ export default {
methods: {
/* Make GET request to AdGuard endpoint */
fetchData() {
- this.makeRequest(this.endpoint).then(this.processData);
+ this.makeRequest(this.endpoint, this.authHeaders).then(this.processData);
},
/* Assign data variables to the returned data */
processData(data) {