auth: PIN login gate - one-time login issues in-memory session tokens - #4
Merged
Merged
Conversation
- app/services/sessions.py: module-level token set (secrets.token_urlsafe), no persistence - a restart invalidates every token, and since config loads once at startup a PIN change is a restart, so one rule covers both re-prompt triggers - require_pin additively accepts a valid token in X-Session-Token; the raw X-API-PIN header path is unchanged - new GET /auth/status (always 200; pin_required + session_valid true/false/null) and POST /auth/login (401 wrong PIN, 400 when no PIN is configured); router mounted in app/main.py - web: shared gate overlay (GATE_HTML) on both pages styled as a third notebook page, Remember checkbox picks localStorage vs sessionStorage, the old per-action id="pin" field and its JS read sites are gone in favor of one authHeaders() helper, 401 mid-action re-raises the gate, and checkGate() rides the 30 s health poll for restart re-prompt - docs: LOGIN_PLAN.md decision record (review + as-built), WEBDESIGN_PLAN §12 addendum, SOURCE_OF_TRUTH §8/§11, README/.env.example API_PIN text - tests: new unit (sessions, token path of require_pin), API (/auth/status, /auth/login, token-unlocks-route integration) and web gate tests plus an autouse fresh_sessions fixture; suite 316 -> 378, coverage 95.75 %, ruff clean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Type of change
Related issue
How was this tested?
Screenshots (if applicable)
Checklist