auth.py
python
sha256:106ef9e12cca7f3be3ffb2a6bd3abfa76f032dce453c9e5010d732a8d86f2e14
Reconcile reviewed credential compatibility 32254cd939885d9…
Human
patch
8 days 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
2 commits
sha256:106ef9e12cca7f3be3ffb2a6bd3abfa76f032dce453c9e5010d732a8d86f2e14
Reconcile reviewed credential compatibility 32254cd939885d9…
Human
patch
8 days ago
sha256:c87cf2c2f03da507f66f93922cb339a2cbebb33ad6372a6039032fb09a20da12
Reconcile reviewed Overseer recovery d47291d5d9030de5ebef71…
Human
minor
⚠
8 days ago