feat(auth): implement basic authentication for cache server and update URL
This commit is contained in:
+1009
-6
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,21 @@
|
|||||||
|
|
||||||
// CHANGE THIS URL to the IP address or hostname of your central cache server if running on remote machines
|
// CHANGE THIS URL to the IP address or hostname of your central cache server if running on remote machines
|
||||||
// e.g., "http://192.168.1.50:8000"
|
// e.g., "http://192.168.1.50:8000"
|
||||||
const CACHE_SERVER_URL = "http://localhost:8000";
|
const CACHE_SERVER_URL = "https://stat.xkjq.uk";
|
||||||
|
|
||||||
|
// Credentials for central cache server basic authentication
|
||||||
|
const CACHE_AUTH_USER = "admin";
|
||||||
|
const CACHE_AUTH_PASS = "statdx-secure-cache-2026";
|
||||||
|
|
||||||
|
// Helper: Generate Basic Auth header
|
||||||
|
function getAuthHeader() {
|
||||||
|
try {
|
||||||
|
const credentials = btoa(`${CACHE_AUTH_USER}:${CACHE_AUTH_PASS}`);
|
||||||
|
return `Basic ${credentials}`;
|
||||||
|
} catch (e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const capturedUrls = new Set();
|
const capturedUrls = new Set();
|
||||||
|
|
||||||
@@ -156,7 +170,10 @@
|
|||||||
GM_xmlhttpRequest({
|
GM_xmlhttpRequest({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `${CACHE_SERVER_URL}/api/check-hash`,
|
url: `${CACHE_SERVER_URL}/api/check-hash`,
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": getAuthHeader()
|
||||||
|
},
|
||||||
data: JSON.stringify({ content_hash: contentHash }),
|
data: JSON.stringify({ content_hash: contentHash }),
|
||||||
onload: function(res) {
|
onload: function(res) {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
@@ -187,7 +204,10 @@
|
|||||||
GM_xmlhttpRequest({
|
GM_xmlhttpRequest({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `${CACHE_SERVER_URL}/api/capture`,
|
url: `${CACHE_SERVER_URL}/api/capture`,
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": getAuthHeader()
|
||||||
|
},
|
||||||
data: JSON.stringify(payload),
|
data: JSON.stringify(payload),
|
||||||
onload: function(res) {
|
onload: function(res) {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
|
|||||||
Reference in New Issue
Block a user