Merge commit from fork
CodeQL / Analyze (javascript) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
Docker Build and Push / docker_build (push) Canceled after 0s
Docker Build and Push / docker_scan (push) Canceled after 0s

This commit is contained in:
Samuel Lock
2026-11-18 19:01:54 +01:00
committed by GitHub
parent 8d21152947
commit 914a7812e7
2 changed files with 4 additions and 7 deletions
+4 -6
View File
@@ -9,7 +9,7 @@ from zipfile import ZipFile
from datetime import datetime, timedelta from datetime import datetime, timedelta
import sqlalchemy import sqlalchemy
from flask import Flask, request, render_template, session, send_file, current_app from flask import Flask, request, render_template, session, send_file, current_app, g
from flask_cors import CORS from flask_cors import CORS
from icmplib import ping, traceroute from icmplib import ping, traceroute
from flask.json.provider import DefaultJSONProvider from flask.json.provider import DefaultJSONProvider
@@ -248,7 +248,7 @@ def auth_req():
if request.method.lower() == 'options': if request.method.lower() == 'options':
return ResponseObject(True) return ResponseObject(True)
DashboardConfig.APIAccessed = False g.api_key_authenticated = False
authenticationRequired = DashboardConfig.GetConfig("Server", "auth_req")[1] authenticationRequired = DashboardConfig.GetConfig("Server", "auth_req")[1]
d = request.headers d = request.headers
if authenticationRequired: if authenticationRequired:
@@ -258,7 +258,6 @@ def auth_req():
apiKeyExist = len(list(filter(lambda x : x.Key == apiKey, DashboardConfig.DashboardAPIKeys))) == 1 apiKeyExist = len(list(filter(lambda x : x.Key == apiKey, DashboardConfig.DashboardAPIKeys))) == 1
DashboardLogger.log(str(request.url), str(request.remote_addr), Message=f"API Key Access: {('true' if apiKeyExist else 'false')} - Key: {apiKey}") DashboardLogger.log(str(request.url), str(request.remote_addr), Message=f"API Key Access: {('true' if apiKeyExist else 'false')} - Key: {apiKey}")
if not apiKeyExist: if not apiKeyExist:
DashboardConfig.APIAccessed = False
response = Flask.make_response(app, { response = Flask.make_response(app, {
"status": False, "status": False,
"message": "API Key does not exist", "message": "API Key does not exist",
@@ -267,9 +266,8 @@ def auth_req():
response.content_type = "application/json" response.content_type = "application/json"
response.status_code = 401 response.status_code = 401
return response return response
DashboardConfig.APIAccessed = True g.api_key_authenticated = True
else: else:
DashboardConfig.APIAccessed = False
appPrefix = APP_PREFIX if len(APP_PREFIX) > 0 else '' appPrefix = APP_PREFIX if len(APP_PREFIX) > 0 else ''
whiteList = [ whiteList = [
# f'/static/', # f'/static/',
@@ -358,7 +356,7 @@ def API_AuthenticateLogin():
if not DashboardConfig.GetConfig("Server", "auth_req")[1]: if not DashboardConfig.GetConfig("Server", "auth_req")[1]:
return ResponseObject(True, DashboardConfig.GetConfig("Other", "welcome_session")[1]) return ResponseObject(True, DashboardConfig.GetConfig("Other", "welcome_session")[1])
if DashboardConfig.APIAccessed: if getattr(g, 'api_key_authenticated', False):
authToken = hashlib.sha256(f"{request.headers.get('wg-dashboard-apikey')}{datetime.now()}".encode()).hexdigest() authToken = hashlib.sha256(f"{request.headers.get('wg-dashboard-apikey')}{datetime.now()}".encode()).hexdigest()
session['role'] = 'admin' session['role'] = 'admin'
session['username'] = authToken session['username'] = authToken
-1
View File
@@ -98,7 +98,6 @@ class DashboardConfig:
self.dbMetadata = db.MetaData() self.dbMetadata = db.MetaData()
self.__createAPIKeyTable() self.__createAPIKeyTable()
self.DashboardAPIKeys = self.__getAPIKeys() self.DashboardAPIKeys = self.__getAPIKeys()
self.APIAccessed = False
self.SetConfig("Server", "version", DashboardConfig.DashboardVersion) self.SetConfig("Server", "version", DashboardConfig.DashboardVersion)
def EnsureDatabaseIntegrity(self, wireguardConfigurations): def EnsureDatabaseIntegrity(self, wireguardConfigurations):