APmanageur Wi-Fi V1.0
This commit is contained in:
1 parent
ffb20ad344
commit
2effae81b2
7 files changed
+887
-217
No files matched your search
@@ -290,7 +290,7 @@ if not is_auto_channel():
|
||||
else:
|
||||
AP_CHANNEL = get_effective_ap_channel(AP_BAND)
|
||||
|
||||
APP_VERSION = 'V5.5'
|
||||
APP_VERSION = 'V1.1 (Béta)'
|
||||
SERVER_BOOT_TIME = time.time()
|
||||
app_startup_done = False
|
||||
SESSION_TTL = 30 * 86400 # 30 jours (1 mois)
|
||||
@@ -783,6 +783,20 @@ def init_db():
|
||||
updated_at TEXT DEFAULT ''
|
||||
)
|
||||
''')
|
||||
c.execute('''
|
||||
CREATE TABLE IF NOT EXISTS api_keys (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
key_hash TEXT UNIQUE NOT NULL,
|
||||
prefix TEXT NOT NULL,
|
||||
permissions TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
expires_at TEXT DEFAULT NULL,
|
||||
last_used_at TEXT DEFAULT NULL,
|
||||
last_ip TEXT DEFAULT NULL,
|
||||
is_active INTEGER DEFAULT 1
|
||||
)
|
||||
''')
|
||||
init_device_types_table(c)
|
||||
# Assainissement et nettoyage des anciennes données non-MAC (sauvegardes, audits, etc.)
|
||||
try:
|
||||
@@ -1430,8 +1444,129 @@ def list_sessions(current_token='', lang='fr'):
|
||||
})
|
||||
return res
|
||||
|
||||
def parse_api_key_permissions(perms_str):
|
||||
if isinstance(perms_str, list):
|
||||
return [str(p).strip().lower() for p in perms_str if str(p).strip()]
|
||||
if not perms_str:
|
||||
return []
|
||||
try:
|
||||
val = json.loads(perms_str)
|
||||
if isinstance(val, list):
|
||||
return [str(p).strip().lower() for p in val if str(p).strip()]
|
||||
except Exception:
|
||||
pass
|
||||
return [p.strip().lower() for p in str(perms_str).split(',') if p.strip()]
|
||||
|
||||
_api_keys_cache = {}
|
||||
_api_keys_cache_lock = threading.Lock()
|
||||
|
||||
def get_api_key_by_token(token):
|
||||
if not token or not isinstance(token, str) or not token.startswith('ap_key_'):
|
||||
return None
|
||||
token_hash = hashlib.sha256(token.encode('utf-8')).hexdigest()
|
||||
now_time = time.time()
|
||||
with _api_keys_cache_lock:
|
||||
cached = _api_keys_cache.get(token_hash)
|
||||
if cached and (now_time - cached.get('_cached_at', 0) < 15):
|
||||
return cached
|
||||
|
||||
try:
|
||||
c = db()
|
||||
row = c.execute('''
|
||||
SELECT id, name, key_hash, prefix, permissions, created_at, expires_at, last_used_at, last_ip, is_active
|
||||
FROM api_keys WHERE key_hash=?
|
||||
''', (token_hash,)).fetchone()
|
||||
c.close()
|
||||
if row:
|
||||
key_data = {
|
||||
'id': row[0],
|
||||
'name': row[1],
|
||||
'key_hash': row[2],
|
||||
'prefix': row[3],
|
||||
'permissions': parse_api_key_permissions(row[4]),
|
||||
'created_at': row[5],
|
||||
'expires_at': row[6],
|
||||
'last_used_at': row[7],
|
||||
'last_ip': row[8],
|
||||
'is_active': int(row[9] or 0),
|
||||
'_cached_at': now_time
|
||||
}
|
||||
with _api_keys_cache_lock:
|
||||
_api_keys_cache[token_hash] = key_data
|
||||
return key_data
|
||||
except Exception as e:
|
||||
print(f"[ap-api-keys] Erreur récupération clé API: {e}", flush=True)
|
||||
return None
|
||||
|
||||
def update_api_key_usage(key_id, ip=''):
|
||||
try:
|
||||
now_str = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
c = db()
|
||||
c.execute('UPDATE api_keys SET last_used_at=?, last_ip=? WHERE id=?', (now_str, ip or '', key_id))
|
||||
c.commit(); c.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def check_api_key_permission(perms, method, path):
|
||||
if not perms:
|
||||
return False
|
||||
if 'admin' in perms:
|
||||
return True
|
||||
method = method.upper()
|
||||
path_only = path.split('?')[0]
|
||||
|
||||
# Droits 'read' (lecture seule métriques, statut, abonnés, logs)
|
||||
if 'read' in perms and method in ('GET', 'HEAD'):
|
||||
read_prefixes = (
|
||||
'/api/status', '/api/stats', '/api/clients', '/api/devices',
|
||||
'/api/device-types', '/api/logs', '/api/network/topology',
|
||||
'/api/wifi/channel', '/api/vpn/profiles', '/api/vpn/clients',
|
||||
'/api/vpn/check-ip', '/api/vpn/public-ip', '/api/preferences',
|
||||
'/api/settings/proxy', '/api/notifications/settings',
|
||||
'/api/advanced/domains', '/api/advanced/geoip',
|
||||
'/api/advanced/capture/status', '/api/advanced/capture/packets',
|
||||
'/api/system/update'
|
||||
)
|
||||
if any(path_only == p or path_only.startswith(p + '/') for p in read_prefixes):
|
||||
return True
|
||||
|
||||
# Droits 'wifi'
|
||||
if 'wifi' in perms:
|
||||
if method in ('GET', 'HEAD') and path_only in ('/api/wifi/channel', '/api/status'):
|
||||
return True
|
||||
if method == 'POST' and path_only in ('/api/ap/control', '/api/ap/mode', '/api/settings', '/api/setup', '/api/stats/refresh'):
|
||||
return True
|
||||
|
||||
# Droits 'clients'
|
||||
if 'clients' in perms:
|
||||
if method in ('GET', 'HEAD') and (path_only.startswith('/api/clients') or path_only.startswith('/api/devices')):
|
||||
return True
|
||||
if method == 'POST' and (
|
||||
path_only in ('/api/clients/block', '/api/devices/limits', '/api/devices/rename', '/api/devices/set_type', '/api/devices/delete')
|
||||
or path_only.startswith('/api/device-types')
|
||||
):
|
||||
return True
|
||||
|
||||
# Droits 'vpn'
|
||||
if 'vpn' in perms:
|
||||
if method in ('GET', 'HEAD') and path_only.startswith('/api/vpn'):
|
||||
return True
|
||||
if method == 'POST' and path_only.startswith('/api/vpn'):
|
||||
return True
|
||||
|
||||
# Droits 'backup'
|
||||
if 'backup' in perms:
|
||||
if method in ('GET', 'HEAD') and (path_only.startswith('/api/backup') or path_only.startswith('/api/backups')):
|
||||
return True
|
||||
if method == 'POST' and (path_only.startswith('/api/backup') or path_only.startswith('/api/backups')):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def extract_token(h):
|
||||
token = h.headers.get('X-Session-Token', '') if hasattr(h, 'headers') else ''
|
||||
token = h.headers.get('X-API-Key', '') if hasattr(h, 'headers') else ''
|
||||
if not token and hasattr(h, 'headers'):
|
||||
token = h.headers.get('X-Session-Token', '')
|
||||
if not token and hasattr(h, 'headers'):
|
||||
auth_hdr = h.headers.get('Authorization', '')
|
||||
if auth_hdr.lower().startswith('bearer '):
|
||||
@@ -1447,10 +1582,44 @@ def extract_token(h):
|
||||
parsed = urllib.parse.urlparse(h.path)
|
||||
token = urllib.parse.parse_qs(parsed.query).get('token', [''])[0]
|
||||
except Exception: pass
|
||||
if not token and hasattr(h, 'path') and 'api_key=' in h.path:
|
||||
try:
|
||||
parsed = urllib.parse.urlparse(h.path)
|
||||
token = urllib.parse.parse_qs(parsed.query).get('api_key', [''])[0]
|
||||
except Exception: pass
|
||||
return token
|
||||
|
||||
def valid_session(h):
|
||||
token = extract_token(h)
|
||||
if not token:
|
||||
return False
|
||||
|
||||
# Authentification via clé d'API (ap_key_...)
|
||||
if token.startswith('ap_key_'):
|
||||
k = get_api_key_by_token(token)
|
||||
if not k or not k.get('is_active'):
|
||||
return False
|
||||
exp = k.get('expires_at')
|
||||
if exp and exp.strip():
|
||||
now_str = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
if now_str > exp:
|
||||
return False
|
||||
method = getattr(h, 'command', 'GET')
|
||||
path = getattr(h, 'path', '')
|
||||
path_only = path.split('?')[0]
|
||||
perms = k.get('permissions', [])
|
||||
# La gestion des clés d'API requiert un accès administrateur total
|
||||
if path_only.startswith('/api/auth/api-keys') and 'admin' not in perms:
|
||||
return False
|
||||
if not check_api_key_permission(perms, method, path):
|
||||
return False
|
||||
try:
|
||||
update_api_key_usage(k['id'], request_ip(h))
|
||||
except Exception:
|
||||
pass
|
||||
return True
|
||||
|
||||
# Authentification classique de session web
|
||||
s = get_session(token)
|
||||
if s is not None:
|
||||
try:
|
||||
@@ -1462,6 +1631,13 @@ def valid_session(h):
|
||||
|
||||
def username(h):
|
||||
token = extract_token(h)
|
||||
if not token:
|
||||
return ''
|
||||
if token.startswith('ap_key_'):
|
||||
k = get_api_key_by_token(token)
|
||||
if k:
|
||||
return f"API:{k.get('name', 'Clé API')}"
|
||||
return 'API'
|
||||
s = get_session(token)
|
||||
return s.get('username', '') if s else ''
|
||||
|
||||
@@ -8556,6 +8732,15 @@ def export_backup_data():
|
||||
'id': r[0], 'username': r[1], 'public_key': r[2], 'name': r[3],
|
||||
'device_type': r[4], 'sign_count': r[5], 'created_at': r[6], 'last_used_at': r[7]
|
||||
})
|
||||
api_keys = []
|
||||
has_ak = bool(c.execute("SELECT 1 FROM sqlite_master WHERE type='table' AND name='api_keys'").fetchone())
|
||||
if has_ak:
|
||||
for r in c.execute("SELECT id, name, key_hash, prefix, permissions, created_at, expires_at, last_used_at, last_ip, is_active FROM api_keys").fetchall():
|
||||
api_keys.append({
|
||||
'id': r[0], 'name': r[1], 'key_hash': r[2], 'prefix': r[3],
|
||||
'permissions': r[4], 'created_at': r[5], 'expires_at': r[6],
|
||||
'last_used_at': r[7], 'last_ip': r[8], 'is_active': r[9]
|
||||
})
|
||||
client_traffic = []
|
||||
for r in c.execute("SELECT mac, rx_bytes, tx_bytes, last_updated FROM client_traffic").fetchall():
|
||||
client_traffic.append({
|
||||
@@ -8597,6 +8782,7 @@ def export_backup_data():
|
||||
'blocked_clients': blocked_clients,
|
||||
'auth_users': auth_users,
|
||||
'auth_passkeys': auth_passkeys,
|
||||
'api_keys': api_keys,
|
||||
'client_traffic': client_traffic,
|
||||
'client_traffic_daily': client_traffic_daily,
|
||||
'connection_logs': connection_logs
|
||||
@@ -8851,6 +9037,27 @@ def import_backup_data(payload, options=None):
|
||||
last_used_at=excluded.last_used_at
|
||||
''', (pk_id, pk_uname, pk_key, pk_name, pk_dev, pk_count, pk_c_at, pk_u_at))
|
||||
stats['auth_passkeys'] += 1
|
||||
if 'api_keys' in backup and isinstance(backup['api_keys'], list):
|
||||
for ak in backup['api_keys']:
|
||||
ak_name = str(ak.get('name', '')).strip()
|
||||
ak_hash = str(ak.get('key_hash', '')).strip()
|
||||
ak_prefix = str(ak.get('prefix', '')).strip()
|
||||
ak_perms = json.dumps(ak.get('permissions')) if isinstance(ak.get('permissions'), list) else str(ak.get('permissions', '[]'))
|
||||
ak_c_at = str(ak.get('created_at', '')).strip() or time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
ak_exp = ak.get('expires_at')
|
||||
ak_act = 1 if ak.get('is_active', 1) else 0
|
||||
if ak_name and ak_hash and ak_prefix:
|
||||
c.execute('''
|
||||
INSERT INTO api_keys (name, key_hash, prefix, permissions, created_at, expires_at, is_active)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(key_hash) DO UPDATE SET
|
||||
name=excluded.name,
|
||||
prefix=excluded.prefix,
|
||||
permissions=excluded.permissions,
|
||||
expires_at=excluded.expires_at,
|
||||
is_active=excluded.is_active
|
||||
''', (ak_name, ak_hash, ak_prefix, ak_perms, ak_c_at, ak_exp, ak_act))
|
||||
stats['api_keys'] = stats.get('api_keys', 0) + 1
|
||||
|
||||
c.commit()
|
||||
finally:
|
||||
@@ -10821,6 +11028,14 @@ API_MSG_I18N = {
|
||||
'Nom d’icône manquant': {'en-us': 'Missing icon name', 'en-gb': 'Missing icon name'},
|
||||
'Profil connecté': {'en-us': 'Profile connected', 'en-gb': 'Profile connected'},
|
||||
'Profil déconnecté': {'en-us': 'Profile disconnected', 'en-gb': 'Profile disconnected'},
|
||||
'Clé d’API créée avec succès': {'en-us': 'API key created successfully', 'en-gb': 'API key created successfully'},
|
||||
'Clé d’API activée avec succès': {'en-us': 'API key enabled successfully', 'en-gb': 'API key enabled successfully'},
|
||||
'Clé d’API désactivée avec succès': {'en-us': 'API key disabled successfully', 'en-gb': 'API key disabled successfully'},
|
||||
'Clé d’API supprimée avec succès': {'en-us': 'API key deleted successfully', 'en-gb': 'API key deleted successfully'},
|
||||
'Le nom de la clé API est obligatoire': {'en-us': 'API key name is required', 'en-gb': 'API key name is required'},
|
||||
'Au moins une autorisation doit être sélectionnée': {'en-us': 'At least one permission must be selected', 'en-gb': 'At least one permission must be selected'},
|
||||
'Clé API introuvable': {'en-us': 'API key not found', 'en-gb': 'API key not found'},
|
||||
'Droits administrateur requis': {'en-us': 'Administrator privileges required', 'en-gb': 'Administrator privileges required'},
|
||||
|
||||
'Authentification requise': {'en-us': 'Authentication required', 'en-gb': 'Authentication required'},
|
||||
'Nom d’utilisateur ou mot de passe incorrect': {'en-us': 'Incorrect username or password', 'en-gb': 'Incorrect username or password'},
|
||||
@@ -11250,6 +11465,38 @@ class Handler(BaseHTTPRequestHandler):
|
||||
never_label = 'Never' if is_en else 'Jamais'
|
||||
items = [{'id': r[0], 'name': r[1], 'device_type': r[2], 'sign_count': r[3], 'created_at': r[4], 'last_used_at': r[5] or never_label} for r in rows]
|
||||
self.send_json({'ok': True, 'passkeys': items}); return
|
||||
if self.path == '/api/auth/api-keys':
|
||||
if not valid_session(self): self.send_json({'error':'Authentification requise'},401); return
|
||||
token = extract_token(self)
|
||||
if token.startswith('ap_key_'):
|
||||
k = get_api_key_by_token(token)
|
||||
if not k or 'admin' not in k.get('permissions', []):
|
||||
self.send_json({'error': 'Droits administrateur requis'}, 403); return
|
||||
try:
|
||||
c = db()
|
||||
rows = c.execute('''
|
||||
SELECT id, name, prefix, permissions, created_at, expires_at, last_used_at, last_ip, is_active
|
||||
FROM api_keys
|
||||
ORDER BY id DESC
|
||||
''').fetchall()
|
||||
c.close()
|
||||
keys_list = []
|
||||
for r in rows:
|
||||
keys_list.append({
|
||||
'id': r[0],
|
||||
'name': r[1],
|
||||
'prefix': r[2],
|
||||
'permissions': parse_api_key_permissions(r[3]),
|
||||
'created_at': r[4],
|
||||
'expires_at': r[5] or None,
|
||||
'last_used_at': r[6] or None,
|
||||
'last_ip': r[7] or '—',
|
||||
'is_active': int(r[8] or 0)
|
||||
})
|
||||
self.send_json({'ok': True, 'api_keys': keys_list})
|
||||
except Exception as e:
|
||||
self.send_json({'error': f'Erreur chargement clés API: {e}'}, 500)
|
||||
return
|
||||
if self.path == '/api/settings/proxy':
|
||||
if not valid_session(self): self.send_json({'error':'Authentification requise'},401); return
|
||||
cfg = get_reverse_proxy_config()
|
||||
@@ -11702,6 +11949,100 @@ class Handler(BaseHTTPRequestHandler):
|
||||
log('modification_identifiants', f"Renommage machine -> {new_name}", request_ip(self), 'AUTH')
|
||||
self.send_json({'ok': True, 'message': 'Machine renommée avec succès', 'name': new_name})
|
||||
return
|
||||
if self.path == '/api/auth/api-keys/create':
|
||||
if not valid_session(self): self.send_json({'error':'Authentification requise'},401); return
|
||||
token = extract_token(self)
|
||||
if token.startswith('ap_key_'):
|
||||
k = get_api_key_by_token(token)
|
||||
if not k or 'admin' not in k.get('permissions', []):
|
||||
self.send_json({'error': 'Droits administrateur requis'}, 403); return
|
||||
name = str(data.get('name', '')).strip()
|
||||
if not name:
|
||||
self.send_json({'error': 'Le nom de la clé API est obligatoire'}, 400); return
|
||||
perms = parse_api_key_permissions(data.get('permissions', []))
|
||||
if not perms:
|
||||
self.send_json({'error': 'Au moins une autorisation doit être sélectionnée'}, 400); return
|
||||
expires_in_days = int(data.get('expires_in_days', 0) or 0)
|
||||
expires_at = None
|
||||
if expires_in_days > 0:
|
||||
expires_at = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time() + expires_in_days * 86400))
|
||||
|
||||
raw_token = f"ap_key_{secrets.token_hex(20)}"
|
||||
token_hash = hashlib.sha256(raw_token.encode('utf-8')).hexdigest()
|
||||
prefix = f"ap_key_{raw_token[7:13]}...{raw_token[-4:]}"
|
||||
now_str = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
c = db()
|
||||
c.execute('''
|
||||
INSERT INTO api_keys(name, key_hash, prefix, permissions, created_at, expires_at, is_active)
|
||||
VALUES(?, ?, ?, ?, ?, ?, 1)
|
||||
''', (name, token_hash, prefix, json.dumps(perms), now_str, expires_at))
|
||||
new_id = c.execute('SELECT last_insert_rowid()').fetchone()[0]
|
||||
c.commit(); c.close()
|
||||
|
||||
with _api_keys_cache_lock:
|
||||
_api_keys_cache.clear()
|
||||
|
||||
log('cle_api_creee', f"{username(self) or 'admin'} ({name})", request_ip(self), 'SETTINGS')
|
||||
|
||||
self.send_json({
|
||||
'ok': True,
|
||||
'message': 'Clé d’API créée avec succès',
|
||||
'api_key': {
|
||||
'id': new_id,
|
||||
'name': name,
|
||||
'prefix': prefix,
|
||||
'token': raw_token,
|
||||
'permissions': perms,
|
||||
'created_at': now_str,
|
||||
'expires_at': expires_at,
|
||||
'is_active': 1
|
||||
}
|
||||
})
|
||||
return
|
||||
if self.path == '/api/auth/api-keys/toggle':
|
||||
if not valid_session(self): self.send_json({'error':'Authentification requise'},401); return
|
||||
token = extract_token(self)
|
||||
if token.startswith('ap_key_'):
|
||||
k = get_api_key_by_token(token)
|
||||
if not k or 'admin' not in k.get('permissions', []):
|
||||
self.send_json({'error': 'Droits administrateur requis'}, 403); return
|
||||
kid = int(data.get('id', 0))
|
||||
c = db()
|
||||
row = c.execute('SELECT name, is_active FROM api_keys WHERE id=?', (kid,)).fetchone()
|
||||
if not row:
|
||||
c.close()
|
||||
self.send_json({'error': 'Clé API introuvable'}, 404); return
|
||||
new_state = 0 if row[1] else 1
|
||||
c.execute('UPDATE api_keys SET is_active=? WHERE id=?', (new_state, kid))
|
||||
c.commit(); c.close()
|
||||
with _api_keys_cache_lock:
|
||||
_api_keys_cache.clear()
|
||||
status_txt = 'activée' if new_state else 'désactivée'
|
||||
log('cle_api_modifiee', f"{username(self) or 'admin'} ({row[0]} -> {status_txt})", request_ip(self), 'SETTINGS')
|
||||
self.send_json({'ok': True, 'is_active': new_state, 'message': f'Clé d’API {status_txt} avec succès'})
|
||||
return
|
||||
if self.path == '/api/auth/api-keys/delete':
|
||||
if not valid_session(self): self.send_json({'error':'Authentification requise'},401); return
|
||||
token = extract_token(self)
|
||||
if token.startswith('ap_key_'):
|
||||
k = get_api_key_by_token(token)
|
||||
if not k or 'admin' not in k.get('permissions', []):
|
||||
self.send_json({'error': 'Droits administrateur requis'}, 403); return
|
||||
kid = int(data.get('id', 0))
|
||||
c = db()
|
||||
row = c.execute('SELECT name FROM api_keys WHERE id=?', (kid,)).fetchone()
|
||||
if not row:
|
||||
c.close()
|
||||
self.send_json({'error': 'Clé API introuvable'}, 404); return
|
||||
key_name = row[0]
|
||||
c.execute('DELETE FROM api_keys WHERE id=?', (kid,))
|
||||
c.commit(); c.close()
|
||||
with _api_keys_cache_lock:
|
||||
_api_keys_cache.clear()
|
||||
log('cle_api_supprimee', f"{username(self) or 'admin'} ({key_name})", request_ip(self), 'SETTINGS')
|
||||
self.send_json({'ok': True, 'message': 'Clé d’API supprimée avec succès'})
|
||||
return
|
||||
if self.path == '/api/system/update/settings':
|
||||
if not valid_session(self) and auth_state()['configured']: self.send_json({'error':'Authentification requise'},401); return
|
||||
enabled = bool(data.get('enabled', True))
|
||||
@@ -11741,7 +12082,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if not target_commit:
|
||||
raise ValueError('Impossible de déterminer le dernier commit')
|
||||
v_data = {
|
||||
'version': 'V5.5',
|
||||
'version': APP_VERSION,
|
||||
'commit': target_commit,
|
||||
'build_date': datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
}
|
||||
@@ -12164,8 +12505,10 @@ class Handler(BaseHTTPRequestHandler):
|
||||
c.execute('DROP TABLE IF EXISTS recovery_codes')
|
||||
c.execute('DELETE FROM preferences')
|
||||
c.execute('DELETE FROM auth_sessions')
|
||||
c.execute('DELETE FROM api_keys')
|
||||
c.commit(); c.close()
|
||||
sessions.clear()
|
||||
with _api_keys_cache_lock: _api_keys_cache.clear()
|
||||
invalidate_status_cache()
|
||||
try: sync_vpn_client_rules()
|
||||
except Exception: pass
|
||||
|
||||
+375
-207
@@ -2376,7 +2376,7 @@
|
||||
Administration de l’AP Wi‑Fi</h2>
|
||||
<div class="sub" style="margin-top:4px"><span class="app-short-title">AP Manageur</span> <span
|
||||
class="app-version"
|
||||
style="font-weight:700;background:var(--panel2);padding:2px 8px;border-radius:6px;border:1px solid var(--line);color:var(--blue);font-size:11px;margin-left:4px">V5.5</span>
|
||||
style="font-weight:700;background:var(--panel2);padding:2px 8px;border-radius:6px;border:1px solid var(--line);color:var(--blue);font-size:11px;margin-left:4px">V1.1 (Béta)</span>
|
||||
</div>
|
||||
<div id="loaderBadge"
|
||||
style="display:inline-flex;align-items:center;gap:6px;background:rgba(56,189,248,0.12);border:1px solid rgba(56,189,248,0.3);color:var(--blue);padding:3px 12px;border-radius:20px;font-size:12px;font-weight:600;margin-top:8px">
|
||||
@@ -2571,7 +2571,7 @@
|
||||
<div>
|
||||
<h1><span class="app-title" data-i18n="app_main_heading">Administration de l’AP Wi‑Fi</span></h1>
|
||||
<div class="sub"><span class="app-short-title">AP Manageur</span> <span class="app-version"
|
||||
style="font-weight:700;background:var(--panel2);padding:2px 8px;border-radius:6px;border:1px solid var(--line);color:var(--blue);font-size:12px;margin-left:4px">V5.5</span>
|
||||
style="font-weight:700;background:var(--panel2);padding:2px 8px;border-radius:6px;border:1px solid var(--line);color:var(--blue);font-size:12px;margin-left:4px">V1.1 (Béta)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
@@ -3547,6 +3547,43 @@
|
||||
</div>
|
||||
<span id="sessionsMessage" class="muted" style="margin-top:10px;display:block"></span>
|
||||
</div>
|
||||
|
||||
<div id="apiKeysBox" style="margin-top:24px;padding-top:20px;border-top:1px solid var(--line)">
|
||||
<div class="topline" style="flex-wrap:wrap;gap:12px;margin-bottom:12px">
|
||||
<div>
|
||||
<h2 style="margin:0 0 4px" data-i18n="settings_apikeys_title">⚡ Clés d’API & Accès programmatique</h2>
|
||||
<p class="muted" style="margin:0;font-size:13px" data-i18n="settings_apikeys_desc">Générez des clés d’accès pour intégrer AP Manageur avec Home Assistant, des scripts automatisés ou des applications tierces avec des autorisations granulaires.</p>
|
||||
</div>
|
||||
<button id="btnCreateApiKey" type="button" onclick="openCreateApiKeyModal()"
|
||||
style="display:inline-flex;align-items:center;gap:6px;font-size:13px"
|
||||
data-i18n="settings_apikeys_create_btn">
|
||||
➕ Créer une nouvelle clé d’API
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-i18n="th_apikey_name">NOM DE LA CLÉ</th>
|
||||
<th data-i18n="th_apikey_prefix">CLÉ</th>
|
||||
<th data-i18n="th_apikey_perms">AUTORISATIONS</th>
|
||||
<th data-i18n="th_apikey_created">DATE DE CRÉATION</th>
|
||||
<th data-i18n="th_apikey_expires">EXPIRATION</th>
|
||||
<th data-i18n="th_apikey_last_used">DERNIÈRE UTILISATION</th>
|
||||
<th data-i18n="th_apikey_status">STATUT</th>
|
||||
<th style="text-align:right" data-i18n="th_action">ACTION</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="apiKeysTableBody">
|
||||
<tr>
|
||||
<td colspan="8" class="empty" data-i18n="loading_apikeys">Chargement des clés d’API…</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<span id="apiKeysMessage" class="muted" style="margin-top:10px;display:block"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 2b. Profils VPN (WireGuard & OpenVPN) -->
|
||||
@@ -5540,7 +5577,7 @@
|
||||
<div style="background:var(--panel2);padding:10px 12px;border-radius:8px;border:1px solid var(--line)">
|
||||
<div class="label" data-i18n="adv_update_current_ver" style="font-size:11px">Version actuelle</div>
|
||||
<div id="advUpdateCurrentCommit" style="font-family:monospace;font-size:16px;font-weight:700;color:var(--text);margin-top:2px">—</div>
|
||||
<div class="muted" style="font-size:11px;margin-top:2px" id="advUpdateVersionTag">AP Manageur V5.5</div>
|
||||
<div class="muted" style="font-size:11px;margin-top:2px" id="advUpdateVersionTag">AP Manageur V1.1 (Béta)</div>
|
||||
</div>
|
||||
<div style="background:var(--panel2);padding:10px 12px;border-radius:8px;border:1px solid var(--line)">
|
||||
<div class="label" data-i18n="adv_update_latest_ver" style="font-size:11px">Dernière version (Gitea)</div>
|
||||
@@ -6842,7 +6879,7 @@
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px">
|
||||
<span style="font-weight:700;color:var(--text);word-break:break-all"
|
||||
id="importFileName">fichier.json</span>
|
||||
<span class="pill pill-blue" id="importFileVersion" style="font-weight:700">V5.5</span>
|
||||
<span class="pill pill-blue" id="importFileVersion" style="font-weight:700">V1.1 (Béta)</span>
|
||||
</div>
|
||||
<div class="muted" style="font-size:12px" id="importFileMeta" data-i18n="modal_import_created_date">Date de
|
||||
création : —</div>
|
||||
@@ -6951,6 +6988,130 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 9b. Modal Création Clé d'API -->
|
||||
<div id="modalCreateApiKey" class="modal-overlay">
|
||||
<div class="modal-card" style="max-width:560px">
|
||||
<div class="modal-header">
|
||||
<h3 style="margin:0;display:flex;align-items:center;gap:8px" data-i18n="modal_create_apikey_title">⚡ Créer une clé d’API</h3>
|
||||
<button type="button" class="secondary" onclick="closeCreateApiKeyModal()"
|
||||
style="padding:4px 10px;font-size:16px;border-radius:6px">✕</button>
|
||||
</div>
|
||||
<div class="modal-body" style="display:flex;flex-direction:column;gap:14px">
|
||||
<div>
|
||||
<label class="label" for="apiKeyInputName" data-i18n="apikey_name_label">Nom ou description de la clé</label>
|
||||
<input id="apiKeyInputName" type="text" maxlength="64" placeholder="Ex: Home Assistant, Script de sauvegarde..." data-i18n-placeholder="placeholder_apikey_name" style="margin:4px 0 0">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="label" for="apiKeyExpirationSelect" data-i18n="apikey_expiration_label">Durée de validité (Expiration)</label>
|
||||
<select id="apiKeyExpirationSelect" style="display:block;width:100%;margin:4px 0 0;padding:10px;border-radius:8px;border:1px solid var(--line);background:var(--panel2);color:var(--text);font-size:14px">
|
||||
<option value="0" data-i18n="apikey_exp_never">Jamais (illimitée)</option>
|
||||
<option value="30" data-i18n="apikey_exp_30d">30 jours</option>
|
||||
<option value="90" data-i18n="apikey_exp_90d">90 jours</option>
|
||||
<option value="365" data-i18n="apikey_exp_1y">1 an (365 jours)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px">
|
||||
<label class="label" style="margin:0" data-i18n="apikey_perms_label">Types d'autorisations (Droits d'accès)</label>
|
||||
<button type="button" class="secondary" onclick="toggleAllApiKeyPerms()" style="padding:2px 8px;font-size:11px" id="btnToggleAllPerms" data-i18n="apikey_select_all_btn">Tout sélectionner</button>
|
||||
</div>
|
||||
<p class="muted" style="font-size:12px;margin:0 0 10px" data-i18n="apikey_perms_desc">Sélectionnez les accès accordés à cette clé d’API selon son utilisation :</p>
|
||||
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr;gap:10px" id="apiKeyPermsGrid">
|
||||
<label class="check" style="background:var(--panel2);padding:10px 12px;border-radius:8px;border:1px solid var(--line);display:flex;align-items:flex-start;gap:8px;cursor:pointer">
|
||||
<input type="checkbox" id="permRead" value="read" checked style="margin-top:2px">
|
||||
<div>
|
||||
<strong style="font-size:13px;display:block" data-i18n="perm_read_title">👁️ Lecture seule</strong>
|
||||
<span class="muted" style="font-size:11px" data-i18n="perm_read_desc">Statut, métriques, journaux, abonnés connectés</span>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label class="check" style="background:var(--panel2);padding:10px 12px;border-radius:8px;border:1px solid var(--line);display:flex;align-items:flex-start;gap:8px;cursor:pointer">
|
||||
<input type="checkbox" id="permWifi" value="wifi" style="margin-top:2px">
|
||||
<div>
|
||||
<strong style="font-size:13px;display:block" data-i18n="perm_wifi_title">📶 Gestion Wi-Fi</strong>
|
||||
<span class="muted" style="font-size:11px" data-i18n="perm_wifi_desc">SSID, canal, démarrer/arrêter/redémarrer l'AP</span>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label class="check" style="background:var(--panel2);padding:10px 12px;border-radius:8px;border:1px solid var(--line);display:flex;align-items:flex-start;gap:8px;cursor:pointer">
|
||||
<input type="checkbox" id="permClients" value="clients" style="margin-top:2px">
|
||||
<div>
|
||||
<strong style="font-size:13px;display:block" data-i18n="perm_clients_title">👥 Clients & Quotas</strong>
|
||||
<span class="muted" style="font-size:11px" data-i18n="perm_clients_desc">Blocage, débits, quotas, renommage</span>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label class="check" style="background:var(--panel2);padding:10px 12px;border-radius:8px;border:1px solid var(--line);display:flex;align-items:flex-start;gap:8px;cursor:pointer">
|
||||
<input type="checkbox" id="permVpn" value="vpn" style="margin-top:2px">
|
||||
<div>
|
||||
<strong style="font-size:13px;display:block" data-i18n="perm_vpn_title">🛡️ Gestion VPN</strong>
|
||||
<span class="muted" style="font-size:11px" data-i18n="perm_vpn_desc">Profils, connexion, routage des clients</span>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label class="check" style="background:var(--panel2);padding:10px 12px;border-radius:8px;border:1px solid var(--line);display:flex;align-items:flex-start;gap:8px;cursor:pointer">
|
||||
<input type="checkbox" id="permBackup" value="backup" style="margin-top:2px">
|
||||
<div>
|
||||
<strong style="font-size:13px;display:block" data-i18n="perm_backup_title">📦 Sauvegardes</strong>
|
||||
<span class="muted" style="font-size:11px" data-i18n="perm_backup_desc">Export, création, planification, restauration</span>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label class="check" style="background:var(--panel2);padding:10px 12px;border-radius:8px;border:1px solid var(--line);display:flex;align-items:flex-start;gap:8px;cursor:pointer">
|
||||
<input type="checkbox" id="permAdmin" value="admin" style="margin-top:2px">
|
||||
<div>
|
||||
<strong style="font-size:13px;display:block;color:var(--yellow)" data-i18n="perm_admin_title">👑 Accès Total Admin</strong>
|
||||
<span class="muted" style="font-size:11px" data-i18n="perm_admin_desc">Toutes les permissions et administration système</span>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="apiKeyModalError" class="muted" style="color:var(--red);font-size:12px"></div>
|
||||
</div>
|
||||
<div class="modal-footer" style="display:flex;justify-content:flex-end;gap:10px">
|
||||
<button type="button" class="secondary" onclick="closeCreateApiKeyModal()" data-i18n="btn_cancel">Annuler</button>
|
||||
<button type="button" id="btnSubmitCreateApiKey" onclick="submitCreateApiKey()" data-i18n="btn_create_key">Générer la clé</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 9c. Modal Affichage Clé d'API Créée -->
|
||||
<div id="modalApiKeyCreated" class="modal-overlay">
|
||||
<div class="modal-card" style="max-width:540px">
|
||||
<div class="modal-header">
|
||||
<h3 style="margin:0;display:flex;align-items:center;gap:8px;color:var(--green)" data-i18n="modal_key_created_title">✅ Clé d’API créée avec succès !</h3>
|
||||
<button type="button" class="secondary" onclick="closeApiKeyCreatedModal()"
|
||||
style="padding:4px 10px;font-size:16px;border-radius:6px">✕</button>
|
||||
</div>
|
||||
<div class="modal-body" style="display:flex;flex-direction:column;gap:14px">
|
||||
<div style="background:rgba(234,179,8,0.12);border:1px solid rgba(234,179,8,0.3);color:var(--yellow);padding:10px 14px;border-radius:8px;font-size:13px" data-i18n-html="apikey_warning_show_once">
|
||||
⚠️ <strong>Attention :</strong> Copiez cette clé maintenant. Pour des raisons de sécurité, vous ne pourrez plus jamais la revoir. Si vous la perdez, vous devrez en créer une nouvelle.
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="label" data-i18n="apikey_token_label">Votre clé d'accès secrète</label>
|
||||
<div style="display:flex;gap:8px;align-items:center;margin-top:4px">
|
||||
<input type="text" id="createdApiKeyInput" readonly style="font-family:monospace;font-size:13px;font-weight:700;color:var(--blue);margin:0;background:var(--panel2);user-select:all">
|
||||
<button type="button" id="btnCopyApiKey" onclick="copyCreatedApiKey()" style="display:inline-flex;align-items:center;gap:6px;white-space:nowrap" data-i18n="btn_copy">📋 Copier</button>
|
||||
</div>
|
||||
<span id="copyApiKeyStatus" class="muted" style="font-size:11px;margin-top:4px;display:block"></span>
|
||||
</div>
|
||||
|
||||
<div style="background:var(--panel2);border:1px solid var(--line);border-radius:8px;padding:10px 12px;font-size:12px">
|
||||
<strong data-i18n="apikey_usage_example">Exemple d’utilisation :</strong>
|
||||
<pre style="margin:6px 0 0;padding:8px;background:rgba(0,0,0,0.3);border-radius:6px;overflow-x:auto;font-family:monospace;font-size:11px"><code id="apiKeyCurlExample">curl -H "X-API-Key: ap_key_..." http://192.168.1.1/api/status</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer" style="display:flex;justify-content:flex-end">
|
||||
<button type="button" onclick="closeApiKeyCreatedModal()" data-i18n="btn_close">J'ai copié ma clé / Fermer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 10. Modal Easter Egg Arcade Games (Tetris, Dino, Zipline) -->
|
||||
<div id="modalEasterEggGames" class="modal-overlay" style="z-index:99999">
|
||||
<div id="modalEasterEggCard" class="modal-card"
|
||||
@@ -7018,7 +7179,7 @@
|
||||
function $(id) { return document.getElementById(id); }
|
||||
const API_URL = location.protocol === 'file:' ? 'http://127.0.0.1:8080' : '';
|
||||
/* Version de l'application */
|
||||
const APP_VERSION = "V5.5";
|
||||
const APP_VERSION = "V1.1 (Béta)";
|
||||
const ICON_REFRESH_ARROW = '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" style="display:inline-block;vertical-align:middle"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.9 1 6.7 2.4L21 8"/><polyline points="21 3 21 8 16 8"/></svg>';
|
||||
const ICON_GEAR = '⚙️';
|
||||
const ICON_TABLET = '<svg width="1.15em" height="1.15em" viewBox="0 0 24 24" fill="none" style="display:inline-block;vertical-align:-0.18em;flex-shrink:0" aria-label="Tablette"><rect x="2.5" y="1.5" width="19" height="21" rx="2.5" fill="#1e293b" stroke="#64748b" stroke-width="1"/><rect x="4" y="3.2" width="16" height="15.6" rx="1.2" fill="#38bdf8"/><circle cx="12" cy="2.3" r="0.5" fill="#94a3b8"/><rect x="10" y="20" width="4" height="1.2" rx="0.6" fill="#94a3b8"/></svg>';
|
||||
@@ -7469,6 +7630,7 @@
|
||||
try { if (typeof renderTopologyStats === 'function' && typeof topologyDataCache !== 'undefined' && topologyDataCache) renderTopologyStats(topologyDataCache); } catch (_) { }
|
||||
try { if (typeof renderVpnProfiles === 'function' && typeof vpnProfilesCache !== 'undefined') renderVpnProfiles(vpnProfilesCache); } catch (_) { }
|
||||
try { if (typeof renderSessionsTable === 'function') renderSessionsTable(); } catch (_) { }
|
||||
try { if (typeof renderApiKeysTable === 'function') renderApiKeysTable(); } catch (_) { }
|
||||
try { if (typeof loadPasskeysList === 'function' && window.passkeysById) loadPasskeysList(); } catch (_) { }
|
||||
try { if (typeof render2faCurrentState === 'function') render2faCurrentState(); } catch (_) { }
|
||||
try { if (typeof renderDeviceTypesTable === 'function') renderDeviceTypesTable(); } catch (_) { }
|
||||
@@ -9161,7 +9323,7 @@ ${vpnBadgeTopo}
|
||||
panel.classList.toggle('active', k === tabKey);
|
||||
}
|
||||
});
|
||||
if (tabKey === 'admin') { if (typeof loadAdminUser === 'function') loadAdminUser(); if (typeof loadSessions === 'function') loadSessions(); if (typeof loadPasskeysList === 'function') loadPasskeysList(); }
|
||||
if (tabKey === 'admin') { if (typeof loadAdminUser === 'function') loadAdminUser(); if (typeof loadSessions === 'function') loadSessions(); if (typeof loadPasskeysList === 'function') loadPasskeysList(); if (typeof loadApiKeys === 'function') loadApiKeys(); }
|
||||
if (tabKey === 'vpn') {
|
||||
if (typeof loadVpnProfiles === 'function') loadVpnProfiles();
|
||||
if (typeof loadVpnClients === 'function') loadVpnClients();
|
||||
@@ -9231,204 +9393,6 @@ ${vpnBadgeTopo}
|
||||
if ($('nav')) $('nav').style.display = configured ? 'flex' : 'none';
|
||||
if ($('dashboardTab')) $('dashboardTab').style.display = configured ? '' : 'none';
|
||||
if ($('statsTab')) $('statsTab').style.display = configured ? '' : 'none';
|
||||
if ($('devicesTab')) $('devicesTab').style.display = configured ? '' : 'none';
|
||||
if ($('advancedTab')) $('advancedTab').style.display = configured ? '' : 'none';
|
||||
if ($('settingsTab')) $('settingsTab').style.display = configured ? '' : 'none';
|
||||
if ($('logsTab')) $('logsTab').style.display = configured ? '' : 'none';
|
||||
if ($('blockedTab')) $('blockedTab').style.display = configured ? '' : 'none';
|
||||
if ($('apControl')) {
|
||||
$('apControl').style.display = configured ? '' : 'none';
|
||||
$('apControl').textContent = active ? t('btn_stop', 'Arrêter') : t('btn_start', 'Démarrer');
|
||||
$('apControl').style.background = active ? 'var(--red)' : 'var(--blue)';
|
||||
$('apControl').style.color = active ? 'white' : 'var(--blue-text, #071326)';
|
||||
}
|
||||
if ($('apRestart')) {
|
||||
$('apRestart').style.display = configured ? '' : 'none';
|
||||
$('apRestart').disabled = !active;
|
||||
$('apRestart').style.opacity = active ? '1' : '0.4';
|
||||
$('apRestart').style.cursor = active ? 'pointer' : 'not-allowed';
|
||||
$('apRestart').title = active ? t('btn_restart', 'Redémarrer') : t('ap_stopped_no_restart', "L'AP est arrêtée (démarrage requis)");
|
||||
}
|
||||
if ($('refresh')) $('refresh').style.display = configured ? '' : 'none';
|
||||
const updateInfo = (status && status.update) ? status.update : null;
|
||||
if (updateInfo) lastUpdateData = updateInfo;
|
||||
const updateAvailable = !!(updateInfo && updateInfo.available);
|
||||
if ($('btnUpdateAvailable')) {
|
||||
$('btnUpdateAvailable').style.display = (configured && updateAvailable) ? 'inline-flex' : 'none';
|
||||
}
|
||||
}
|
||||
|
||||
let lastUpdateData = null;
|
||||
|
||||
function openUpdateModal() {
|
||||
const modal = $('modalUpdateApp');
|
||||
if (!modal) return;
|
||||
const u = lastUpdateData || (status && status.update) || {};
|
||||
const isAvail = !!u.available;
|
||||
if ($('updateCurrentCommit')) $('updateCurrentCommit').textContent = u.current_commit || (u.current_commit_full ? u.current_commit_full.substring(0, 7) : '—');
|
||||
if ($('updateLatestCommit')) $('updateLatestCommit').textContent = u.latest_commit || (u.latest_commit_full ? u.latest_commit_full.substring(0, 7) : '—');
|
||||
if ($('updateCommitMsg')) $('updateCommitMsg').textContent = u.commit_msg || t('update_no_msg', 'Aucun message de commit');
|
||||
if ($('updateCommitAuthor')) $('updateCommitAuthor').textContent = u.author ? ('Par ' + u.author) : '';
|
||||
if ($('updateCommitDate')) {
|
||||
let dStr = '';
|
||||
if (u.date) {
|
||||
try { dStr = 'le ' + new Date(u.date).toLocaleString(); } catch (_) { dStr = 'le ' + u.date; }
|
||||
}
|
||||
$('updateCommitDate').textContent = dStr;
|
||||
}
|
||||
if ($('updateStatusAlert')) {
|
||||
$('updateStatusAlert').style.background = isAvail ? 'rgba(16,185,129,0.1)' : 'rgba(56,189,248,0.1)';
|
||||
$('updateStatusAlert').style.borderColor = isAvail ? 'rgba(16,185,129,0.3)' : 'rgba(56,189,248,0.3)';
|
||||
}
|
||||
if ($('updateStatusIcon')) {
|
||||
$('updateStatusIcon').textContent = isAvail ? '🚀' : '✅';
|
||||
}
|
||||
if ($('updateStatusTitle')) {
|
||||
$('updateStatusTitle').textContent = isAvail ? t('update_new_version_found', 'Une nouvelle version de AP Manageur est prête !') : t('update_up_to_date', 'AP Manageur est à jour !');
|
||||
$('updateStatusTitle').style.color = isAvail ? '#10b981' : 'var(--blue)';
|
||||
}
|
||||
if ($('updateStatusDesc')) {
|
||||
$('updateStatusDesc').textContent = isAvail ? t('update_new_version_desc', "Une mise à jour plus récente de l'application est disponible sur le dépôt.") : t('update_up_to_date_desc', "Vous disposez déjà de la version la plus récente de l'application.");
|
||||
}
|
||||
if ($('updateDockerCmdSection')) {
|
||||
$('updateDockerCmdSection').style.display = isAvail ? 'block' : 'none';
|
||||
}
|
||||
|
||||
modal.classList.add('active');
|
||||
}
|
||||
window.openUpdateModal = openUpdateModal;
|
||||
|
||||
function closeUpdateModal() {
|
||||
const modal = $('modalUpdateApp');
|
||||
if (modal) modal.classList.remove('active');
|
||||
}
|
||||
window.closeUpdateModal = closeUpdateModal;
|
||||
|
||||
async function copyUpdateCommand() {
|
||||
const input = $('updateDockerCmd');
|
||||
const btnText = $('btnCopyUpdateCmdText');
|
||||
if (!input) return;
|
||||
const cmd = input.value;
|
||||
try {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
await navigator.clipboard.writeText(cmd);
|
||||
} else {
|
||||
input.select();
|
||||
document.execCommand('copy');
|
||||
}
|
||||
if (btnText) {
|
||||
const original = btnText.textContent;
|
||||
btnText.textContent = t('update_cmd_copied', '✓ Copié !');
|
||||
setTimeout(() => { if (btnText) btnText.textContent = original; }, 2000);
|
||||
}
|
||||
} catch (err) {
|
||||
input.select();
|
||||
document.execCommand('copy');
|
||||
}
|
||||
}
|
||||
window.copyUpdateCommand = copyUpdateCommand;
|
||||
|
||||
async function triggerManualUpdateCheck() {
|
||||
const btn = $('btnCheckUpdateManual');
|
||||
if (btn) btn.disabled = true;
|
||||
try {
|
||||
const res = await apiFetch('/api/system/update?force=1', { cache: 'no-store' });
|
||||
if (res.ok) {
|
||||
const u = await res.json();
|
||||
lastUpdateData = u;
|
||||
if (status) status.update = u;
|
||||
updateApButtons();
|
||||
openUpdateModal();
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Erreur vérification mise à jour :', e);
|
||||
} finally {
|
||||
if (btn) btn.disabled = false;
|
||||
}
|
||||
}
|
||||
window.triggerManualUpdateCheck = triggerManualUpdateCheck;
|
||||
|
||||
async function toggleBlock(mac, blocked) {
|
||||
return runAction(async () => {
|
||||
try {
|
||||
const response = await apiFetch('/api/clients/block', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ mac, blocked }) });
|
||||
const data = await response.json(); if (!response.ok) throw Error(data.error || 'Opération refusée');
|
||||
await load();
|
||||
} catch (e) { alert(tErr(e.message)) }
|
||||
});
|
||||
}
|
||||
|
||||
function render() {
|
||||
updateApButtons();
|
||||
$('clientCount').textContent = status.max_clients > 0 ? `${clients.length} / ${status.max_clients}` : clients.length;
|
||||
$('ssid').textContent = status.ssid || 'SSID inconnu';
|
||||
$('uptime').textContent = status.active ? uptime(status.uptime_seconds) : '—';
|
||||
$('settingsSsid').value = status.ssid || '';
|
||||
$('settingsPassword').value = status.password || '';
|
||||
$('settingsSecurity').value = status.security || 'wpa2';
|
||||
if ($('settingsMaxClients')) $('settingsMaxClients').value = status.max_clients !== undefined ? status.max_clients : 0;
|
||||
const isBridge = status.mode === 'bridge';
|
||||
if ($('networkModeBadge')) {
|
||||
$('networkModeBadge').textContent = isBridge ? t('badge_mode_bridge', 'Pont (DHCP Box)') : t('badge_mode_ap', 'AP (Routeur/NAT)');
|
||||
$('networkModeBadge').className = 'pill ' + (isBridge ? 'pill-blue' : 'pill-green');
|
||||
$('networkModeBadge').style.background = '';
|
||||
$('networkModeBadge').style.color = '';
|
||||
}
|
||||
if ($('settingsModeAp') && $('settingsModeBridge')) {
|
||||
if (isBridge) $('settingsModeBridge').checked = true; else $('settingsModeAp').checked = true;
|
||||
if ($('settingsBridgeBlock')) $('settingsBridgeBlock').style.display = isBridge ? 'block' : 'none';
|
||||
}
|
||||
const ethList = status.ethernet_interfaces || [];
|
||||
const populateEth = (selId, cur) => {
|
||||
const el = $(selId); if (!el) return; const val = el.value || cur;
|
||||
el.innerHTML = ethList.length ? ethList.map(e => `<option value="${e}">${e}</option>`).join('') : '<option value="">Auto-détection</option>';
|
||||
if (val && ethList.includes(val)) el.value = val; else if (cur && ethList.includes(cur)) el.value = cur;
|
||||
};
|
||||
populateEth('setupBridgeEth', status.bridge_eth); populateEth('settingsBridgeEth', status.bridge_eth);
|
||||
$('settingsAutoconnect').checked = !!status.autoconnect;
|
||||
$('updated').textContent = formatLastUpdated();
|
||||
$('state').innerHTML = status.active ? '<i class="dot"></i> ' + t('status_active', 'Actif') : '<i class="dot" style="background:var(--red)"></i> ' + t('status_inactive', 'Inactif');
|
||||
|
||||
const totalPages = Math.max(1, Math.ceil(clients.length / 10));
|
||||
if (clientsPage > totalPages) clientsPage = totalPages; if (clientsPage < 1) clientsPage = 1;
|
||||
const pagedClients = clients.slice((clientsPage - 1) * 10, clientsPage * 10);
|
||||
|
||||
$('clients').innerHTML = pagedClients.length ? pagedClients.map(c => {
|
||||
const speedHtml = c.blocked
|
||||
? `<span class="signal-faible">● ${t('status_blocked', 'Bloqué')}</span>`
|
||||
: `<span style="font-family:monospace;font-size:13px;white-space:nowrap"><span style="color:var(--blue);font-weight:700" title="Débit descendant">↓ ${c.download_speed_str || formatSpeed(c.download_speed)}</span><span style="color:var(--muted);margin:0 5px">|</span><span style="color:var(--green);font-weight:700" title="Débit montant">↑ ${c.upload_speed_str || formatSpeed(c.upload_speed)}</span></span>`;
|
||||
const vpnHtml = c.vpn_routed
|
||||
? `<span class="pill pill-green" style="font-size:11px;font-weight:600;display:inline-flex;align-items:center;gap:4px" title="Trafic chiffré via ${escapeHtml(c.vpn_profile_name)}">🛡️ ${escapeHtml(c.vpn_profile_name)}${c.vpn_public_ip ? ` <span style="font-family:monospace;font-size:10px;opacity:.9">(${escapeHtml(c.vpn_public_ip)})</span>` : ''}</span>`
|
||||
: (c.vpn_profile_name
|
||||
? (c.kill_switch
|
||||
? `<span class="pill" style="background:rgba(255,107,107,.15);color:var(--red);font-size:11px;font-weight:600">🛡️ ${t('vpn_killswitch_chk', 'Kill-Switch')}</span>`
|
||||
: `<span class="pill" style="background:rgba(246,173,85,.15);color:#f6ad55;font-size:11px">⚠️ Direct</span>`)
|
||||
: `<span class="muted" style="font-size:12px;display:inline-flex;align-items:center;gap:4px">🌐 ${t('topo_direct_wan', 'Direct WAN (Box)')}</span>`);
|
||||
const ipLabel = c.ip || t('not_assigned', 'Non attribuée');
|
||||
const nameLabel = String(c.name || t('name_unknown', 'Nom non communiqué')).replace(/[&<>"']/g, ch => '&#' + ch.charCodeAt(0) + ';');
|
||||
return `<tr><td><div class="client"><div class="avatar">${String(c.name || '?')[0].toUpperCase()}</div><strong>${nameLabel}</strong></div></td><td>${ipLabel}</td><td>${c.mac || '—'}</td><td>${vpnHtml}</td><td>${signalQuality(c.signal_dbm, c)}</td><td>${speedHtml}</td></tr>`;
|
||||
}).join('') : `<tr><td colspan="6" class="empty">${t('no_clients', 'Aucun client connecté')}</td></tr>`;
|
||||
|
||||
renderPagination('clientsPagination', clientsPage, clients.length, 'changeClientsPage', 10);
|
||||
qr();
|
||||
}
|
||||
|
||||
window.changeClientsPage = (p) => { clientsPage = p; render(); };
|
||||
|
||||
let isLoadInProgress = false;
|
||||
let loadFailureCount = 0;
|
||||
|
||||
async function load() {
|
||||
if (isLoadInProgress) return;
|
||||
isLoadInProgress = true;
|
||||
try {
|
||||
let [a, b] = await Promise.all([apiFetch('/api/status', { cache: 'no-store', timeout: 10000 }), apiFetch('/api/clients', { cache: 'no-store', timeout: 10000 })]);
|
||||
if (!a.ok || !b.ok) {
|
||||
const response = !a.ok ? a : b; let detail = 'HTTP ' + response.status;
|
||||
try { const body = await response.json(); detail = body.error || detail; } catch (_) { }
|
||||
throw Error(detail);
|
||||
}
|
||||
const nextStatus = await a.json(); const nextClients = await b.json();
|
||||
const signature = nextClients.map(client => client.mac).sort().join('|');
|
||||
const changed = previousClientSignature !== null && signature !== previousClientSignature;
|
||||
status = nextStatus; clients = nextClients; previousClientSignature = signature;
|
||||
@@ -9494,7 +9458,10 @@ ${vpnBadgeTopo}
|
||||
'suppression_sauvegarde_distante': t('log_suppr_distant', '🗑️ Suppr. sur le drive'),
|
||||
'export_sauvegarde_complete': t('log_export_sauvegarde', '💾 Export sauvegarde'),
|
||||
'export_base_sqlite': t('log_export_sqlite', '💾 Export SQLite'),
|
||||
'export_configuration_json': t('log_export_json', '💾 Export JSON')
|
||||
'export_configuration_json': t('log_export_json', '💾 Export JSON'),
|
||||
'cle_api_creee': t('log_cle_api_creee', '⚡ Clé API créée'),
|
||||
'cle_api_modifiee': t('log_cle_api_modifiee', '⚡ Clé API modifiée'),
|
||||
'cle_api_supprimee': t('log_cle_api_supprimee', '🗑️ Clé API supprimée')
|
||||
};
|
||||
tbody.innerHTML = paged.map(log => {
|
||||
const ev = String(log.event || '').toLowerCase();
|
||||
@@ -9505,7 +9472,7 @@ ${vpnBadgeTopo}
|
||||
eventHtml = '<span style="color:var(--red);font-weight:600">' + t('log_deconnexion', '○ Déconnexion Wi-Fi') + '</span>';
|
||||
} else {
|
||||
const label = labels[log.event] || log.event;
|
||||
if (ev.includes('admin') || ev.includes('2fa') || ev === 'création' || ev === 'démarrage' || ev.includes('sauvegarde') || ev.includes('distant') || ev.includes('export')) {
|
||||
if (ev.includes('admin') || ev.includes('2fa') || ev.includes('cle_api') || ev === 'création' || ev === 'démarrage' || ev.includes('sauvegarde') || ev.includes('distant') || ev.includes('export')) {
|
||||
eventHtml = `<span style="color:var(--blue);font-weight:600">${label}</span>`;
|
||||
} else if (ev.includes('vpn') || ev === 'vpn_route' || ev === 'vpn_connect') {
|
||||
eventHtml = `<span style="color:var(--green);font-weight:600">${label}</span>`;
|
||||
@@ -11722,7 +11689,7 @@ ${vpnBadgeTopo}
|
||||
}
|
||||
if (logs) loadLogs();
|
||||
if (blocked) loadBlocked();
|
||||
if (settings) { selectSettingsTab(currentSettingsTab || 'wifi'); load2fa(); if ((currentSettingsTab || 'wifi') === 'admin') { if (typeof loadAdminUser === 'function') loadAdminUser(); if (typeof loadSessions === 'function') loadSessions(); if (typeof loadPasskeysList === 'function') loadPasskeysList(); } }
|
||||
if (settings) { selectSettingsTab(currentSettingsTab || 'wifi'); load2fa(); if ((currentSettingsTab || 'wifi') === 'admin') { if (typeof loadAdminUser === 'function') loadAdminUser(); if (typeof loadSessions === 'function') loadSessions(); if (typeof loadPasskeysList === 'function') loadPasskeysList(); if (typeof loadApiKeys === 'function') loadApiKeys(); } }
|
||||
}
|
||||
|
||||
if ($('dashboardTab')) $('dashboardTab').onclick = () => selectTab('dashboard');
|
||||
@@ -13735,6 +13702,207 @@ ${vpnBadgeTopo}
|
||||
if ($('btnAddPasskey')) $('btnAddPasskey').onclick = () => runAction(registerPasskey);
|
||||
if ($('btnAuthPasskey')) $('btnAuthPasskey').onclick = loginWithPasskey;
|
||||
|
||||
/* ==========================================================================
|
||||
Gestion des Clés d'API & Droits d'Accès Programmatique
|
||||
========================================================================== */
|
||||
let apiKeysDataCache = [];
|
||||
|
||||
async function loadApiKeys() {
|
||||
const tbody = $('apiKeysTableBody');
|
||||
if (!tbody) return;
|
||||
try {
|
||||
const res = await apiFetch('/api/auth/api-keys', { cache: 'no-store' });
|
||||
if (!res.ok) throw new Error('HTTP ' + res.status);
|
||||
const data = await res.json();
|
||||
apiKeysDataCache = data.api_keys || [];
|
||||
renderApiKeysTable();
|
||||
} catch (e) {
|
||||
tbody.innerHTML = `<tr><td colspan="8" class="empty">${t('apikey_load_error', 'Impossible de charger les clés d’API')} (${escapeHtml(e.message)})</td></tr>`;
|
||||
}
|
||||
}
|
||||
|
||||
function renderApiKeysTable() {
|
||||
const tbody = $('apiKeysTableBody');
|
||||
if (!tbody) return;
|
||||
if (!apiKeysDataCache || !apiKeysDataCache.length) {
|
||||
tbody.innerHTML = `<tr><td colspan="8" class="empty">${t('no_api_keys', 'Aucune clé d’API configurée')}</td></tr>`;
|
||||
return;
|
||||
}
|
||||
|
||||
const permBadges = {
|
||||
'read': `<span class="pill" style="font-size:10px;background:rgba(56,189,248,0.12);color:var(--blue);border:1px solid rgba(56,189,248,0.3)">👁️ ${t('perm_read_title', 'Lecture')}</span>`,
|
||||
'wifi': `<span class="pill" style="font-size:10px;background:rgba(16,185,129,0.12);color:var(--green);border:1px solid rgba(16,185,129,0.3)">📶 ${t('perm_wifi_title', 'Wi-Fi')}</span>`,
|
||||
'clients': `<span class="pill" style="font-size:10px;background:rgba(168,85,247,0.12);color:#c084fc;border:1px solid rgba(168,85,247,0.3)">👥 ${t('perm_clients_title', 'Clients')}</span>`,
|
||||
'vpn': `<span class="pill" style="font-size:10px;background:rgba(20,184,166,0.12);color:#2dd4bf;border:1px solid rgba(20,184,166,0.3)">🛡️ ${t('perm_vpn_title', 'VPN')}</span>`,
|
||||
'backup': `<span class="pill" style="font-size:10px;background:rgba(249,115,22,0.12);color:#fb923c;border:1px solid rgba(249,115,22,0.3)">📦 ${t('perm_backup_title', 'Sauvegarde')}</span>`,
|
||||
'admin': `<span class="pill" style="font-size:10px;background:rgba(234,179,8,0.12);color:var(--yellow);border:1px solid rgba(234,179,8,0.3)">👑 ${t('perm_admin_title', 'Admin')}</span>`
|
||||
};
|
||||
|
||||
tbody.innerHTML = apiKeysDataCache.map(k => {
|
||||
const isAct = Boolean(k.is_active);
|
||||
const statusPill = isAct
|
||||
? `<span class="pill" style="font-size:11px;background:rgba(16,185,129,0.12);color:var(--green);border:1px solid rgba(16,185,129,0.3)">● ${t('active', 'Active')}</span>`
|
||||
: `<span class="pill" style="font-size:11px;background:rgba(239,68,68,0.12);color:var(--red);border:1px solid rgba(239,68,68,0.3)">○ ${t('disabled', 'Désactivée')}</span>`;
|
||||
|
||||
const permsHtml = (k.permissions || []).map(p => permBadges[p] || `<span class="pill" style="font-size:10px">${escapeHtml(p)}</span>`).join(' ') || '—';
|
||||
const expText = k.expires_at ? escapeHtml(k.expires_at) : `<span class="muted">${t('never', 'Jamais')}</span>`;
|
||||
const lastUsedText = k.last_used_at ? `${escapeHtml(k.last_used_at)} <span class="muted" style="font-size:10px">(${escapeHtml(k.last_ip || '—')})</span>` : `<span class="muted">${t('never', 'Jamais')}</span>`;
|
||||
|
||||
const toggleBtnTitle = isAct ? t('btn_disable_key', 'Désactiver') : t('btn_enable_key', 'Activer');
|
||||
const toggleBtnIcon = isAct ? '⏸️' : '▶️';
|
||||
|
||||
return `<tr>
|
||||
<td><strong>${escapeHtml(k.name)}</strong></td>
|
||||
<td><code style="font-size:12px;background:var(--panel2);padding:2px 6px;border-radius:4px;border:1px solid var(--line);color:var(--blue)">${escapeHtml(k.prefix)}</code></td>
|
||||
<td><div style="display:flex;gap:4px;flex-wrap:wrap">${permsHtml}</div></td>
|
||||
<td style="font-size:12px">${escapeHtml(k.created_at)}</td>
|
||||
<td style="font-size:12px">${expText}</td>
|
||||
<td style="font-size:12px">${lastUsedText}</td>
|
||||
<td>${statusPill}</td>
|
||||
<td style="text-align:right">
|
||||
<div style="display:inline-flex;gap:6px">
|
||||
<button type="button" class="secondary" onclick="toggleApiKey(${k.id})" title="${toggleBtnTitle}" style="padding:4px 8px;font-size:12px">${toggleBtnIcon}</button>
|
||||
<button type="button" class="secondary" onclick="deleteApiKey(${k.id}, '${escapeHtml(k.name)}')" title="${t('btn_delete', 'Supprimer')}" style="padding:4px 8px;font-size:12px;color:var(--red)">🗑️</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
window.openCreateApiKeyModal = function() {
|
||||
const m = $('modalCreateApiKey');
|
||||
if (!m) return;
|
||||
$('apiKeyInputName').value = '';
|
||||
$('apiKeyExpirationSelect').value = '0';
|
||||
$('permRead').checked = true;
|
||||
$('permWifi').checked = false;
|
||||
$('permClients').checked = false;
|
||||
$('permVpn').checked = false;
|
||||
$('permBackup').checked = false;
|
||||
$('permAdmin').checked = false;
|
||||
$('apiKeyModalError').textContent = '';
|
||||
m.classList.add('active');
|
||||
setTimeout(() => $('apiKeyInputName').focus(), 100);
|
||||
};
|
||||
|
||||
window.closeCreateApiKeyModal = function() {
|
||||
const m = $('modalCreateApiKey');
|
||||
if (m) m.classList.remove('active');
|
||||
};
|
||||
|
||||
window.toggleAllApiKeyPerms = function() {
|
||||
const ids = ['permRead', 'permWifi', 'permClients', 'permVpn', 'permBackup', 'permAdmin'];
|
||||
const allChecked = ids.every(id => $(id)?.checked);
|
||||
ids.forEach(id => { if ($(id)) $(id).checked = !allChecked; });
|
||||
};
|
||||
|
||||
window.submitCreateApiKey = async function() {
|
||||
const name = $('apiKeyInputName').value.trim();
|
||||
const errEl = $('apiKeyModalError');
|
||||
if (!name) {
|
||||
errEl.textContent = t('apikey_name_required', 'Veuillez saisir un nom pour cette clé d’API');
|
||||
return;
|
||||
}
|
||||
const perms = [];
|
||||
if ($('permRead')?.checked) perms.push('read');
|
||||
if ($('permWifi')?.checked) perms.push('wifi');
|
||||
if ($('permClients')?.checked) perms.push('clients');
|
||||
if ($('permVpn')?.checked) perms.push('vpn');
|
||||
if ($('permBackup')?.checked) perms.push('backup');
|
||||
if ($('permAdmin')?.checked) perms.push('admin');
|
||||
|
||||
if (!perms.length) {
|
||||
errEl.textContent = t('apikey_perms_required', 'Veuillez sélectionner au moins une autorisation');
|
||||
return;
|
||||
}
|
||||
|
||||
const expires_in_days = parseInt($('apiKeyExpirationSelect').value, 10) || 0;
|
||||
errEl.textContent = '';
|
||||
const btn = $('btnSubmitCreateApiKey');
|
||||
if (btn) btn.disabled = true;
|
||||
|
||||
try {
|
||||
const res = await apiFetch('/api/auth/api-keys/create', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name, permissions: perms, expires_in_days })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error || 'Erreur lors de la création');
|
||||
|
||||
closeCreateApiKeyModal();
|
||||
await loadApiKeys();
|
||||
|
||||
if (data.api_key && data.api_key.token) {
|
||||
$('createdApiKeyInput').value = data.api_key.token;
|
||||
const host = location.origin || 'http://192.168.1.1';
|
||||
$('apiKeyCurlExample').textContent = `curl -H "X-API-Key: ${data.api_key.token}" ${host}/api/status`;
|
||||
$('copyApiKeyStatus').textContent = '';
|
||||
$('modalApiKeyCreated').classList.add('active');
|
||||
}
|
||||
} catch (e) {
|
||||
errEl.textContent = tErr(e.message);
|
||||
} finally {
|
||||
if (btn) btn.disabled = false;
|
||||
}
|
||||
};
|
||||
|
||||
window.closeApiKeyCreatedModal = function() {
|
||||
const m = $('modalApiKeyCreated');
|
||||
if (m) m.classList.remove('active');
|
||||
};
|
||||
|
||||
window.copyCreatedApiKey = function() {
|
||||
const input = $('createdApiKeyInput');
|
||||
if (!input) return;
|
||||
input.select();
|
||||
navigator.clipboard.writeText(input.value).then(() => {
|
||||
$('copyApiKeyStatus').textContent = '✅ ' + t('copied_to_clipboard', 'Clé copiée dans le presse-papier !');
|
||||
setTimeout(() => { if ($('copyApiKeyStatus')) $('copyApiKeyStatus').textContent = ''; }, 3000);
|
||||
}).catch(() => {
|
||||
$('copyApiKeyStatus').textContent = t('copy_failed', 'Appuyez sur Ctrl+C pour copier la clé');
|
||||
});
|
||||
};
|
||||
|
||||
window.toggleApiKey = async function(id) {
|
||||
const sm = $('apiKeysMessage');
|
||||
try {
|
||||
const res = await apiFetch('/api/auth/api-keys/toggle', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ id })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error || 'Erreur modification');
|
||||
await loadApiKeys();
|
||||
if (sm) sm.textContent = tMsg(data.message);
|
||||
setTimeout(() => { if (sm && (sm.textContent.includes('succès') || sm.textContent.includes('successfully'))) sm.textContent = ''; }, 3000);
|
||||
} catch (e) {
|
||||
if (sm) sm.textContent = tErr(e.message);
|
||||
}
|
||||
};
|
||||
|
||||
window.deleteApiKey = async function(id, name) {
|
||||
if (!confirm(t('apikey_delete_confirm', `Êtes-vous sûr de vouloir supprimer définitivement la clé d’API « ${name} » ?\nTous les services l'utilisant perdront leur accès.`))) {
|
||||
return;
|
||||
}
|
||||
const sm = $('apiKeysMessage');
|
||||
try {
|
||||
const res = await apiFetch('/api/auth/api-keys/delete', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ id })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error || 'Erreur suppression');
|
||||
await loadApiKeys();
|
||||
if (sm) sm.textContent = tMsg(data.message);
|
||||
setTimeout(() => { if (sm && (sm.textContent.includes('succès') || sm.textContent.includes('successfully'))) sm.textContent = ''; }, 3000);
|
||||
} catch (e) {
|
||||
if (sm) sm.textContent = tErr(e.message);
|
||||
}
|
||||
};
|
||||
|
||||
/* Système de configuration et test des notifications multi-canaux */
|
||||
const NOTIF_EVENT_META = {
|
||||
new_device: { defaultTitle: "📱 Nouvel appareil détecté", defaultMsg: "L'appareil « {name} » vient de se connecter pour la première fois au réseau Wi-Fi." },
|
||||
|
||||
+54
-1
@@ -1315,5 +1315,58 @@ window.I18N['en-gb'] = {
|
||||
"interval_3d": "Every 3 days",
|
||||
"interval_7d": "Every 7 days (1 week)",
|
||||
"interval_14d": "Every 14 days (2 weeks)",
|
||||
"interval_30d": "Every 30 days (1 month)"
|
||||
"interval_30d": "Every 30 days (1 month)",
|
||||
"settings_apikeys_title": "⚡ API Keys & Programmatic Access",
|
||||
"settings_apikeys_desc": "Generate access keys to integrate AP Manageur with Home Assistant, automated scripts, or third-party applications with granular permissions.",
|
||||
"settings_apikeys_create_btn": "➕ Create a new API key",
|
||||
"th_apikey_name": "KEY NAME",
|
||||
"th_apikey_prefix": "KEY",
|
||||
"th_apikey_perms": "PERMISSIONS",
|
||||
"th_apikey_created": "CREATION DATE",
|
||||
"th_apikey_expires": "EXPIRATION",
|
||||
"th_apikey_last_used": "LAST USED",
|
||||
"th_apikey_status": "STATUS",
|
||||
"loading_apikeys": "Loading API keys…",
|
||||
"no_api_keys": "No API keys configured",
|
||||
"modal_create_apikey_title": "⚡ Create API Key",
|
||||
"apikey_name_label": "Key name or description",
|
||||
"placeholder_apikey_name": "E.g. Home Assistant, Backup script...",
|
||||
"apikey_expiration_label": "Validity period (Expiration)",
|
||||
"apikey_exp_never": "Never (no expiration)",
|
||||
"apikey_exp_30d": "30 days",
|
||||
"apikey_exp_90d": "90 days",
|
||||
"apikey_exp_1y": "1 year (365 days)",
|
||||
"apikey_perms_label": "Permission types (Access rights)",
|
||||
"apikey_select_all_btn": "Select all",
|
||||
"apikey_perms_desc": "Select the permissions granted to this API key according to its usage:",
|
||||
"perm_read_title": "👁️ Read-only",
|
||||
"perm_read_desc": "Status, metrics, logs, connected devices",
|
||||
"perm_wifi_title": "📶 Wi-Fi Management",
|
||||
"perm_wifi_desc": "SSID, channel, start/stop/restart AP",
|
||||
"perm_clients_title": "👥 Clients & Quotas",
|
||||
"perm_clients_desc": "Blocking, speed limits, quotas, rename",
|
||||
"perm_vpn_title": "🛡️ VPN Management",
|
||||
"perm_vpn_desc": "Profiles, connection, client routing",
|
||||
"perm_backup_title": "📦 Backups",
|
||||
"perm_backup_desc": "Export, create, schedule, restore",
|
||||
"perm_admin_title": "👑 Full Admin Access",
|
||||
"perm_admin_desc": "All permissions and system administration",
|
||||
"btn_create_key": "Generate Key",
|
||||
"modal_key_created_title": "✅ API Key created successfully!",
|
||||
"apikey_warning_show_once": "⚠️ <strong>Warning:</strong> Copy this key now. For security reasons, you will never be able to view it again. If lost, you will need to create a new one.",
|
||||
"apikey_token_label": "Your secret access key",
|
||||
"btn_copy": "📋 Copy",
|
||||
"apikey_usage_example": "Usage example:",
|
||||
"btn_close": "I copied my key / Close",
|
||||
"apikey_load_error": "Unable to load API keys",
|
||||
"apikey_name_required": "Please enter a name for this API key",
|
||||
"apikey_perms_required": "Please select at least one permission",
|
||||
"copied_to_clipboard": "Key copied to clipboard!",
|
||||
"copy_failed": "Press Ctrl+C to copy the key",
|
||||
"btn_disable_key": "Disable",
|
||||
"btn_enable_key": "Enable",
|
||||
"apikey_delete_confirm": "Are you sure you want to permanently delete the API key « {name} » ?\\nAll services using it will lose access.",
|
||||
"log_cle_api_creee": "⚡ API Key created",
|
||||
"log_cle_api_modifiee": "⚡ API Key modified",
|
||||
"log_cle_api_supprimee": "🗑️ API Key deleted"
|
||||
};
|
||||
+54
-1
@@ -1315,5 +1315,58 @@ window.I18N['en-us'] = {
|
||||
"interval_3d": "Every 3 days",
|
||||
"interval_7d": "Every 7 days (1 week)",
|
||||
"interval_14d": "Every 14 days (2 weeks)",
|
||||
"interval_30d": "Every 30 days (1 month)"
|
||||
"interval_30d": "Every 30 days (1 month)",
|
||||
"settings_apikeys_title": "⚡ API Keys & Programmatic Access",
|
||||
"settings_apikeys_desc": "Generate access keys to integrate AP Manageur with Home Assistant, automated scripts, or third-party applications with granular permissions.",
|
||||
"settings_apikeys_create_btn": "➕ Create a new API key",
|
||||
"th_apikey_name": "KEY NAME",
|
||||
"th_apikey_prefix": "KEY",
|
||||
"th_apikey_perms": "PERMISSIONS",
|
||||
"th_apikey_created": "CREATION DATE",
|
||||
"th_apikey_expires": "EXPIRATION",
|
||||
"th_apikey_last_used": "LAST USED",
|
||||
"th_apikey_status": "STATUS",
|
||||
"loading_apikeys": "Loading API keys…",
|
||||
"no_api_keys": "No API keys configured",
|
||||
"modal_create_apikey_title": "⚡ Create API Key",
|
||||
"apikey_name_label": "Key name or description",
|
||||
"placeholder_apikey_name": "E.g. Home Assistant, Backup script...",
|
||||
"apikey_expiration_label": "Validity period (Expiration)",
|
||||
"apikey_exp_never": "Never (no expiration)",
|
||||
"apikey_exp_30d": "30 days",
|
||||
"apikey_exp_90d": "90 days",
|
||||
"apikey_exp_1y": "1 year (365 days)",
|
||||
"apikey_perms_label": "Permission types (Access rights)",
|
||||
"apikey_select_all_btn": "Select all",
|
||||
"apikey_perms_desc": "Select the permissions granted to this API key according to its usage:",
|
||||
"perm_read_title": "👁️ Read-only",
|
||||
"perm_read_desc": "Status, metrics, logs, connected devices",
|
||||
"perm_wifi_title": "📶 Wi-Fi Management",
|
||||
"perm_wifi_desc": "SSID, channel, start/stop/restart AP",
|
||||
"perm_clients_title": "👥 Clients & Quotas",
|
||||
"perm_clients_desc": "Blocking, speed limits, quotas, rename",
|
||||
"perm_vpn_title": "🛡️ VPN Management",
|
||||
"perm_vpn_desc": "Profiles, connection, client routing",
|
||||
"perm_backup_title": "📦 Backups",
|
||||
"perm_backup_desc": "Export, create, schedule, restore",
|
||||
"perm_admin_title": "👑 Full Admin Access",
|
||||
"perm_admin_desc": "All permissions and system administration",
|
||||
"btn_create_key": "Generate Key",
|
||||
"modal_key_created_title": "✅ API Key created successfully!",
|
||||
"apikey_warning_show_once": "⚠️ <strong>Warning:</strong> Copy this key now. For security reasons, you will never be able to view it again. If lost, you will need to create a new one.",
|
||||
"apikey_token_label": "Your secret access key",
|
||||
"btn_copy": "📋 Copy",
|
||||
"apikey_usage_example": "Usage example:",
|
||||
"btn_close": "I copied my key / Close",
|
||||
"apikey_load_error": "Unable to load API keys",
|
||||
"apikey_name_required": "Please enter a name for this API key",
|
||||
"apikey_perms_required": "Please select at least one permission",
|
||||
"copied_to_clipboard": "Key copied to clipboard!",
|
||||
"copy_failed": "Press Ctrl+C to copy the key",
|
||||
"btn_disable_key": "Disable",
|
||||
"btn_enable_key": "Enable",
|
||||
"apikey_delete_confirm": "Are you sure you want to permanently delete the API key « {name} » ?\\nAll services using it will lose access.",
|
||||
"log_cle_api_creee": "⚡ API Key created",
|
||||
"log_cle_api_modifiee": "⚡ API Key modified",
|
||||
"log_cle_api_supprimee": "🗑️ API Key deleted"
|
||||
};
|
||||
+54
-1
@@ -1315,5 +1315,58 @@ window.I18N['fr'] = {
|
||||
"interval_3d": "Tous les 3 jours",
|
||||
"interval_7d": "Tous les 7 jours (1 semaine)",
|
||||
"interval_14d": "Tous les 14 jours (2 semaines)",
|
||||
"interval_30d": "Tous les 30 jours (1 mois)"
|
||||
"interval_30d": "Tous les 30 jours (1 mois)",
|
||||
"settings_apikeys_title": "⚡ Clés d’API & Accès programmatique",
|
||||
"settings_apikeys_desc": "Générez des clés d’accès pour intégrer AP Manageur avec Home Assistant, des scripts automatisés ou des applications tierces avec des autorisations granulaires.",
|
||||
"settings_apikeys_create_btn": "➕ Créer une nouvelle clé d’API",
|
||||
"th_apikey_name": "NOM DE LA CLÉ",
|
||||
"th_apikey_prefix": "CLÉ",
|
||||
"th_apikey_perms": "AUTORISATIONS",
|
||||
"th_apikey_created": "DATE DE CRÉATION",
|
||||
"th_apikey_expires": "EXPIRATION",
|
||||
"th_apikey_last_used": "DERNIÈRE UTILISATION",
|
||||
"th_apikey_status": "STATUT",
|
||||
"loading_apikeys": "Chargement des clés d’API…",
|
||||
"no_api_keys": "Aucune clé d’API configurée",
|
||||
"modal_create_apikey_title": "⚡ Créer une clé d’API",
|
||||
"apikey_name_label": "Nom ou description de la clé",
|
||||
"placeholder_apikey_name": "Ex: Home Assistant, Script de sauvegarde...",
|
||||
"apikey_expiration_label": "Durée de validité (Expiration)",
|
||||
"apikey_exp_never": "Jamais (illimitée)",
|
||||
"apikey_exp_30d": "30 jours",
|
||||
"apikey_exp_90d": "90 jours",
|
||||
"apikey_exp_1y": "1 an (365 jours)",
|
||||
"apikey_perms_label": "Types d'autorisations (Droits d'accès)",
|
||||
"apikey_select_all_btn": "Tout sélectionner",
|
||||
"apikey_perms_desc": "Sélectionnez les accès accordés à cette clé d’API selon son utilisation :",
|
||||
"perm_read_title": "👁️ Lecture seule",
|
||||
"perm_read_desc": "Statut, métriques, journaux, abonnés connectés",
|
||||
"perm_wifi_title": "📶 Gestion Wi-Fi",
|
||||
"perm_wifi_desc": "SSID, canal, démarrer/arrêter/redémarrer l'AP",
|
||||
"perm_clients_title": "👥 Clients & Quotas",
|
||||
"perm_clients_desc": "Blocage, débits, quotas, renommage",
|
||||
"perm_vpn_title": "🛡️ Gestion VPN",
|
||||
"perm_vpn_desc": "Profils, connexion, routage des clients",
|
||||
"perm_backup_title": "📦 Sauvegardes",
|
||||
"perm_backup_desc": "Export, création, planification, restauration",
|
||||
"perm_admin_title": "👑 Accès Total Admin",
|
||||
"perm_admin_desc": "Toutes les permissions et administration système",
|
||||
"btn_create_key": "Générer la clé",
|
||||
"modal_key_created_title": "✅ Clé d’API créée avec succès !",
|
||||
"apikey_warning_show_once": "⚠️ <strong>Attention :</strong> Copiez cette clé maintenant. Pour des raisons de sécurité, vous ne pourrez plus jamais la revoir. Si vous la perdez, vous devrez en créer une nouvelle.",
|
||||
"apikey_token_label": "Votre clé d'accès secrète",
|
||||
"btn_copy": "📋 Copier",
|
||||
"apikey_usage_example": "Exemple d’utilisation :",
|
||||
"btn_close": "J'ai copié ma clé / Fermer",
|
||||
"apikey_load_error": "Impossible de charger les clés d’API",
|
||||
"apikey_name_required": "Veuillez saisir un nom pour cette clé d’API",
|
||||
"apikey_perms_required": "Veuillez sélectionner au moins une autorisation",
|
||||
"copied_to_clipboard": "Clé copiée dans le presse-papier !",
|
||||
"copy_failed": "Appuyez sur Ctrl+C pour copier la clé",
|
||||
"btn_disable_key": "Désactiver",
|
||||
"btn_enable_key": "Activer",
|
||||
"apikey_delete_confirm": "Êtes-vous sûr de vouloir supprimer définitivement la clé d’API « {name} » ?\\nTous les services l'utilisant perdront leur accès.",
|
||||
"log_cle_api_creee": "⚡ Clé API créée",
|
||||
"log_cle_api_modifiee": "⚡ Clé API modifiée",
|
||||
"log_cle_api_supprimee": "🗑️ Clé API supprimée"
|
||||
};
|
||||
+1
-1
@@ -1032,7 +1032,7 @@
|
||||
</h1>
|
||||
<div class="sub">
|
||||
<span class="app-short-title">AP Manageur</span>
|
||||
<span class="pill" style="margin-left:6px;font-size:11px">V5.5</span>
|
||||
<span class="pill" style="margin-left:6px;font-size:11px">V1.1 (Béta)</span>
|
||||
<span class="pill" style="margin-left:4px;font-size:11px;color:var(--blue);border-color:var(--blue)"
|
||||
data-i18n="app_badge_setup">Configuration initiale</span>
|
||||
</div>
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "V5.5",
|
||||
"commit": "2fb1b7fb3c17f7355cf58c18d6890597797c2191",
|
||||
"build_date": "2026-11-22T21:09:00Z"
|
||||
"version": "V1.1 (Béta)",
|
||||
"commit": "6f353a5ff5725279cc59812972ee5a34f15f1013",
|
||||
"build_date": "2026-11-22T21:30:00Z"
|
||||
}
|
||||
Reference in new issue
Block a user