auth.py python
18 lines 511 B
Raw
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83 chore(governance): sync handover+roadmap to 84db8c8 (drift:… Human 11 hours ago
1 """Viewer Bearer credential helpers (§HGD.6.1)."""
2
3 from __future__ import annotations
4
5 import secrets
6
7 # ≥ 128 bits entropy (16 bytes → 32 hex chars).
8 _VIEWER_TOKEN_BYTES = 16
9
10
11 def generate_viewer_token() -> str:
12 """Return a cryptographically secure viewer Bearer credential."""
13 return secrets.token_hex(_VIEWER_TOKEN_BYTES)
14
15
16 def constant_time_equal(a: str, b: str) -> bool:
17 """Compare two strings in constant time."""
18 return secrets.compare_digest(a.encode("utf-8"), b.encode("utf-8"))
File History 1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199 fix(ISR): default require_independent_second_reviewer to require Human minor 11 hours ago