Gabungkan aplikasi RPS & Portofolio OBE (dashboard jadi bagian aplikasi)
Dashboard pemetaan statis kini dilayani aplikasi di /dashboard (app/static/dashboard.html). Fitur lengkap Tahap 1-4 + dasbor monitoring, menu global, filter semester, input nilai langsung, penggabungan nilai team teaching, tabel bisa urut. Dockerfile berubah dari nginx statis ke uvicorn/FastAPI: healthcheck, proxy-headers, volume /data (SQLite). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Autentikasi: hashing password (PBKDF2) & token sesi."""
|
||||
import hashlib
|
||||
import hmac
|
||||
import secrets
|
||||
|
||||
_ITERASI = 200_000
|
||||
|
||||
|
||||
def hash_password(password: str) -> str:
|
||||
salt = secrets.token_hex(16)
|
||||
h = hashlib.pbkdf2_hmac("sha256", password.encode("utf-8"),
|
||||
bytes.fromhex(salt), _ITERASI)
|
||||
return f"{salt}${h.hex()}"
|
||||
|
||||
|
||||
def verifikasi_password(password: str, tersimpan: str) -> bool:
|
||||
try:
|
||||
salt, h = tersimpan.split("$", 1)
|
||||
calon = hashlib.pbkdf2_hmac("sha256", password.encode("utf-8"),
|
||||
bytes.fromhex(salt), _ITERASI)
|
||||
return hmac.compare_digest(calon.hex(), h)
|
||||
except (ValueError, TypeError):
|
||||
return False
|
||||
|
||||
|
||||
def token_baru() -> str:
|
||||
return secrets.token_urlsafe(32)
|
||||
Reference in New Issue
Block a user