feat(backend): DB sessions, login modes, single-session rules
Platform v2 step 1.6 (APPS_PLATFORM D-8, D-9, §6.2, §6.4).
- sessions table (revision 0006); every JWT carries `sid` and is accepted
only while its session is active (validated per request, 10 s cache that
is dropped the moment a session ends); the in-memory blacklist is gone, so
logout and "end session" survive restarts
- one login path, POST /api/auth/login {client, username?, user_id?, pin?,
password?}: manager mode password|pin (username-only "none" removed, D-8),
waiter mode pin|password|tap (tap answers auth.mode_needs_device until
paired devices exist), optional "waiter must type username", and the app's
access key (core.dashboard.access / waiter_app.access)
- auth.single_session_manager / _waiter: off | refuse_new | end_old
- /login without `client` = the current manager UI with v1 rules (pin or
password; refuse_new treated as end_old because its lock screen re-logs-in);
/login-by-id is a deprecated wrapper for the current waiter app;
/login-no-auth removed
- GET /api/auth/sessions, POST /api/auth/sessions/{id}/end (core.staff.manage);
blocking a user ends their sessions; refresh keeps the session; logout
takes the bearer header (or ?token= as before)
- settings API validates enum/bool/int values from the manifests;
security.login_method migrated to auth.manager_login_mode
- tests: modes, single-session rules, logout, refresh, forged token without
session, manager session list/end
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -42,10 +42,11 @@ def security_config(db: Session = Depends(get_db)):
|
||||
"""Public endpoint — returns only the security settings needed by the login page."""
|
||||
from models.settings import PosSettings
|
||||
rows = {r.key: r.value for r in db.query(PosSettings).filter(
|
||||
PosSettings.key.in_(["security.login_method", "security.autofill_username"])
|
||||
PosSettings.key.in_(["auth.manager_login_mode", "security.autofill_username"])
|
||||
).all()}
|
||||
# `login_method` is what the current manager login page reads; "none" no longer exists (D-8)
|
||||
return SecurityConfigResponse(
|
||||
login_method=rows.get("security.login_method", "password"),
|
||||
login_method=rows.get("auth.manager_login_mode", "password"),
|
||||
autofill_username=rows.get("security.autofill_username", "true") == "true",
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user