mirror of
https://github.com/WGDashboard/WGDashboard.git
synced 2026-12-01 17:07:47 +00:00
Compare commits
1
Commits
dec86ad222
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
914a7812e7 |
+1
-1
@@ -4,5 +4,5 @@
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| > 4.3 | :white_check_mark: |
|
||||
| 4.3 | :white_check_mark: |
|
||||
| < 4.3 | :x: |
|
||||
|
||||
+4
-6
@@ -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
|
||||
from flask import Flask, request, render_template, session, send_file, current_app, g
|
||||
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)
|
||||
|
||||
DashboardConfig.APIAccessed = False
|
||||
g.api_key_authenticated = False
|
||||
authenticationRequired = DashboardConfig.GetConfig("Server", "auth_req")[1]
|
||||
d = request.headers
|
||||
if authenticationRequired:
|
||||
@@ -258,7 +258,6 @@ 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",
|
||||
@@ -267,9 +266,8 @@ def auth_req():
|
||||
response.content_type = "application/json"
|
||||
response.status_code = 401
|
||||
return response
|
||||
DashboardConfig.APIAccessed = True
|
||||
g.api_key_authenticated = True
|
||||
else:
|
||||
DashboardConfig.APIAccessed = False
|
||||
appPrefix = APP_PREFIX if len(APP_PREFIX) > 0 else ''
|
||||
whiteList = [
|
||||
# f'/static/',
|
||||
@@ -358,7 +356,7 @@ def API_AuthenticateLogin():
|
||||
if not DashboardConfig.GetConfig("Server", "auth_req")[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()
|
||||
session['role'] = 'admin'
|
||||
session['username'] = authToken
|
||||
|
||||
@@ -98,7 +98,6 @@ 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):
|
||||
|
||||
@@ -101,14 +101,6 @@ export default {
|
||||
<samp>{{Peer.allowed_ip}}</samp>
|
||||
</small>
|
||||
</div>
|
||||
<div :class="{'d-flex gap-2 align-items-center' : dashboardStore.Configuration.Server.dashboard_peer_list_display === 'list'}">
|
||||
<small class="text-muted">
|
||||
<LocaleText t="Endpoint"></LocaleText>
|
||||
</small>
|
||||
<small class="d-block">
|
||||
<samp>{{Peer.endpoint && Peer.endpoint !== 'N/A' ? Peer.endpoint : '(none)'}}</samp>
|
||||
</small>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-1"
|
||||
:class="{'ms-auto': dashboardStore.Configuration.Server.dashboard_peer_list_display === 'list'}"
|
||||
>
|
||||
|
||||
@@ -88,16 +88,6 @@ defineEmits(['close'])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="word-break: break-all" class="col-12 col-lg-6">
|
||||
<div class="card rounded-3 bg-transparent h-100">
|
||||
<div class="card-body py-2 d-flex flex-column justify-content-center">
|
||||
<p class="mb-0 text-muted"><small>
|
||||
<LocaleText t="Endpoint"></LocaleText>
|
||||
</small></p>
|
||||
<samp>{{selectedPeer.endpoint && selectedPeer.endpoint !== 'N/A' ? selectedPeer.endpoint : '(none)'}}</samp>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="word-break: break-all" class="col-12 col-lg-6">
|
||||
<div class="card rounded-3 bg-transparent h-100">
|
||||
<div class="card-body py-2 d-flex flex-column justify-content-center">
|
||||
|
||||
@@ -191,12 +191,6 @@ const searchPeers = computed(() => {
|
||||
wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags || (!wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags && taggedPeers.value.includes(x.id))
|
||||
));
|
||||
|
||||
if (dashboardStore.Configuration.Server.dashboard_sort === "traffic"){
|
||||
return result.sort((a, b) => {
|
||||
return (b.total_data + b.cumu_data) - (a.total_data + a.cumu_data)
|
||||
}).slice(0, showPeersCount.value);
|
||||
}
|
||||
|
||||
if (dashboardStore.Configuration.Server.dashboard_sort === "restricted"){
|
||||
return result.sort((a, b) => {
|
||||
if ( a[dashboardStore.Configuration.Server.dashboard_sort]
|
||||
|
||||
@@ -24,7 +24,6 @@ export default {
|
||||
status: GetLocale("Status"),
|
||||
name: GetLocale("Name"),
|
||||
allowed_ip: GetLocale("Allowed IPs"),
|
||||
traffic: GetLocale("Total Usage"),
|
||||
restricted: GetLocale("Restricted")
|
||||
},
|
||||
interval: {
|
||||
|
||||
Reference in New Issue
Block a user