mirror of
https://github.com/WGDashboard/WGDashboard.git
synced 2026-12-01 17:07:47 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c92c50e007 |
+6
-4
@@ -9,7 +9,7 @@ from zipfile import ZipFile
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import sqlalchemy
|
||||
from flask import Flask, request, render_template, session, send_file, current_app, g
|
||||
from flask import Flask, request, render_template, session, send_file, current_app
|
||||
from flask_cors import CORS
|
||||
from icmplib import ping, traceroute
|
||||
from flask.json.provider import DefaultJSONProvider
|
||||
@@ -248,7 +248,7 @@ def auth_req():
|
||||
if request.method.lower() == 'options':
|
||||
return ResponseObject(True)
|
||||
|
||||
g.api_key_authenticated = False
|
||||
DashboardConfig.APIAccessed = False
|
||||
authenticationRequired = DashboardConfig.GetConfig("Server", "auth_req")[1]
|
||||
d = request.headers
|
||||
if authenticationRequired:
|
||||
@@ -258,6 +258,7 @@ def auth_req():
|
||||
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}")
|
||||
if not apiKeyExist:
|
||||
DashboardConfig.APIAccessed = False
|
||||
response = Flask.make_response(app, {
|
||||
"status": False,
|
||||
"message": "API Key does not exist",
|
||||
@@ -266,8 +267,9 @@ def auth_req():
|
||||
response.content_type = "application/json"
|
||||
response.status_code = 401
|
||||
return response
|
||||
g.api_key_authenticated = True
|
||||
DashboardConfig.APIAccessed = True
|
||||
else:
|
||||
DashboardConfig.APIAccessed = False
|
||||
appPrefix = APP_PREFIX if len(APP_PREFIX) > 0 else ''
|
||||
whiteList = [
|
||||
# f'/static/',
|
||||
@@ -356,7 +358,7 @@ def API_AuthenticateLogin():
|
||||
if not DashboardConfig.GetConfig("Server", "auth_req")[1]:
|
||||
return ResponseObject(True, DashboardConfig.GetConfig("Other", "welcome_session")[1])
|
||||
|
||||
if getattr(g, 'api_key_authenticated', False):
|
||||
if DashboardConfig.APIAccessed:
|
||||
authToken = hashlib.sha256(f"{request.headers.get('wg-dashboard-apikey')}{datetime.now()}".encode()).hexdigest()
|
||||
session['role'] = 'admin'
|
||||
session['username'] = authToken
|
||||
|
||||
@@ -98,6 +98,7 @@ class DashboardConfig:
|
||||
self.dbMetadata = db.MetaData()
|
||||
self.__createAPIKeyTable()
|
||||
self.DashboardAPIKeys = self.__getAPIKeys()
|
||||
self.APIAccessed = False
|
||||
self.SetConfig("Server", "version", DashboardConfig.DashboardVersion)
|
||||
|
||||
def EnsureDatabaseIntegrity(self, wireguardConfigurations):
|
||||
|
||||
Generated
+16
-16
@@ -23,7 +23,7 @@
|
||||
"fuse.js": "^7.5.0",
|
||||
"i": "^0.3.7",
|
||||
"is-cidr": "^7.0.3",
|
||||
"npm": "^12.2.1",
|
||||
"npm": "^12.2.2",
|
||||
"ol": "^10.11.0",
|
||||
"pinia": "^4.1.0",
|
||||
"pinia-plugin-persistedstate": "^4.7.1",
|
||||
@@ -4318,9 +4318,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/npm": {
|
||||
"version": "12.2.1",
|
||||
"resolved": "https://registry.npmjs.org/npm/-/npm-12.2.1.tgz",
|
||||
"integrity": "sha512-bKCmFRVT/BB+YPEYbZwQ1XUI3N5t4xKSpU1MxOjo7z3iWzKBJ0ZXRC1xFdEN+TC7N5TdywaBzf2dMXGJq/e2PQ==",
|
||||
"version": "12.2.2",
|
||||
"resolved": "https://registry.npmjs.org/npm/-/npm-12.2.2.tgz",
|
||||
"integrity": "sha512-KglgbZyacf7jH+FHuNRqVuCzQi8VhI2a7J87Ix43FsPTuZoGWmIXXGdZtBUOA79vwL+IJREqURVzupA7PsQTcA==",
|
||||
"bundleDependencies": [
|
||||
"@isaacs/string-locale-compare",
|
||||
"@npmcli/arborist",
|
||||
@@ -4408,13 +4408,13 @@
|
||||
"@npmcli/map-workspaces": "^6.0.0",
|
||||
"@npmcli/metavuln-calculator": "^10.0.0",
|
||||
"@npmcli/package-json": "^8.0.0",
|
||||
"@npmcli/promise-spawn": "^10.0.0",
|
||||
"@npmcli/promise-spawn": "^10.0.1",
|
||||
"@npmcli/redact": "^5.0.0",
|
||||
"@npmcli/run-script": "^11.0.0",
|
||||
"@sigstore/tuf": "^5.0.0",
|
||||
"abbrev": "^5.0.0",
|
||||
"archy": "~1.0.0",
|
||||
"bin-links": "^7.0.0",
|
||||
"bin-links": "^7.0.1",
|
||||
"cacache": "^21.0.1",
|
||||
"chalk": "^5.6.2",
|
||||
"ci-info": "^4.4.0",
|
||||
@@ -4430,7 +4430,7 @@
|
||||
"json-parse-even-better-errors": "^6.0.0",
|
||||
"libnpmaccess": "^11.0.0",
|
||||
"libnpmdiff": "^9.0.4",
|
||||
"libnpmexec": "^11.0.4",
|
||||
"libnpmexec": "^11.0.5",
|
||||
"libnpmfund": "^8.0.4",
|
||||
"libnpmorg": "^9.0.0",
|
||||
"libnpmpack": "^10.0.4",
|
||||
@@ -4453,12 +4453,12 @@
|
||||
"npm-registry-fetch": "^20.0.1",
|
||||
"npm-user-validate": "^5.0.0",
|
||||
"p-map": "^7.0.4",
|
||||
"pacote": "^22.0.0",
|
||||
"pacote": "^22.0.1",
|
||||
"parse-conflict-json": "^6.0.0",
|
||||
"proc-log": "^7.0.0",
|
||||
"qrcode-terminal": "^0.12.0",
|
||||
"read": "^6.0.0",
|
||||
"semver": "^7.8.5",
|
||||
"semver": "^7.8.6",
|
||||
"spdx-expression-parse": "^4.0.0",
|
||||
"ssri": "^14.0.0",
|
||||
"supports-color": "^10.2.2",
|
||||
@@ -4743,7 +4743,7 @@
|
||||
}
|
||||
},
|
||||
"node_modules/npm/node_modules/@npmcli/promise-spawn": {
|
||||
"version": "10.0.0",
|
||||
"version": "10.0.1",
|
||||
"inBundle": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
@@ -4902,7 +4902,7 @@
|
||||
}
|
||||
},
|
||||
"node_modules/npm/node_modules/bin-links": {
|
||||
"version": "7.0.0",
|
||||
"version": "7.0.1",
|
||||
"inBundle": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
@@ -5176,7 +5176,7 @@
|
||||
}
|
||||
},
|
||||
"node_modules/npm/node_modules/ip-address": {
|
||||
"version": "10.7.2",
|
||||
"version": "10.7.5",
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -5267,7 +5267,7 @@
|
||||
}
|
||||
},
|
||||
"node_modules/npm/node_modules/libnpmexec": {
|
||||
"version": "11.0.4",
|
||||
"version": "11.0.5",
|
||||
"inBundle": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
@@ -5707,7 +5707,7 @@
|
||||
}
|
||||
},
|
||||
"node_modules/npm/node_modules/pacote": {
|
||||
"version": "22.0.0",
|
||||
"version": "22.0.1",
|
||||
"inBundle": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
@@ -5860,7 +5860,7 @@
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/npm/node_modules/semver": {
|
||||
"version": "7.8.5",
|
||||
"version": "7.8.6",
|
||||
"inBundle": true,
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
@@ -6070,7 +6070,7 @@
|
||||
}
|
||||
},
|
||||
"node_modules/npm/node_modules/undici": {
|
||||
"version": "6.29.0",
|
||||
"version": "6.29.1",
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"fuse.js": "^7.5.0",
|
||||
"i": "^0.3.7",
|
||||
"is-cidr": "^7.0.3",
|
||||
"npm": "^12.2.1",
|
||||
"npm": "^12.2.2",
|
||||
"ol": "^10.11.0",
|
||||
"pinia": "^4.1.0",
|
||||
"pinia-plugin-persistedstate": "^4.7.1",
|
||||
|
||||
Reference in New Issue
Block a user