refactor(backend): remove the v1 auth and permission leftovers no frontend uses

Platform-v2 step 2.99a. After 2.6 no frontend calls these any more:
- POST /api/auth/login needs `client` (manager/waiter/terminal); the no-`client`
  path with v1 rules and the `legacy_manager` single-session exception are gone.
- GET /api/setup/security-config (bootstrap's `login` replaced it in 2.6b).
- POST /api/recovery/use (a recovery code works in the normal login's
  password field).
- PUT /api/waiters/{id}/permission and /reset-permissions (the permission editor
  saves keys with PUT /{id}/permissions); staff create/update ignore perm_* fields.
- The v1 perm_* projection: core/access/legacy.py deleted, UserOut carries only
  `permissions` (no app reads the 13 booleans, waiter included).
e2e manager login sends client "manager"; smoke_routes too. Backend 281 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 12:08:01 +02:00
co-authored by Claude Opus 5.5
parent eb22997f8e
commit 7cbd0325a4
17 changed files with 57 additions and 249 deletions
+9 -11
View File
@@ -47,7 +47,7 @@ def _check_secret(user, pin, password, db) -> bool:
def do_login(db: Session, request: Request, *, client: str, username: str | None, user_id: int | None,
pin: str | None, password: str | None, legacy: bool = False) -> TokenResponse:
pin: str | None, password: str | None) -> TokenResponse:
"""The one login path. Applies the client's login mode, its access key and the
single-session rule, then creates a session (core/sessions.py)."""
if client not in ("manager", "waiter", "terminal"):
@@ -57,11 +57,10 @@ def do_login(db: Session, request: Request, *, client: str, username: str | None
if client == "manager":
mode = sessions.manager_login_mode(db)
if not legacy: # the current manager UI (no `client`) keeps v1 behaviour: pin or password
if mode == "password" and not password:
raise XeniaError("auth.login_mode_not_allowed", mode="pin")
if mode == "pin" and not (pin or password):
raise XeniaError("auth.invalid_credentials")
if mode == "password" and not password:
raise XeniaError("auth.login_mode_not_allowed", mode="pin")
if mode == "pin" and not (pin or password):
raise XeniaError("auth.invalid_credentials")
if not username:
raise XeniaError("auth.username_required")
else:
@@ -85,7 +84,7 @@ def do_login(db: Session, request: Request, *, client: str, username: str | None
if not holds(user, needed):
raise XeniaError("auth.client_not_allowed", client=client)
row = sessions.start(db, user, client, request, legacy_manager=legacy and client == "manager")
row = sessions.start(db, user, client, request)
return TokenResponse(access_token=make_token(user, row.id), user=UserOut.model_validate(user))
@@ -124,10 +123,9 @@ def _terminal_login(db: Session, request: Request, *, username, user_id, pin, pa
@router.post("/login", response_model=TokenResponse, dependencies=[Depends(public())])
def login(body: LoginRequest, request: Request, db: Session = Depends(get_db)):
"""POST {client: "manager"|"waiter"|"terminal", username?, user_id?, pin?, password?}.
"terminal" = a user on a paired device: send the X-Xenia-Device header.
Without `client` (the current manager UI): a manager login with v1 rules (pin or password)."""
return do_login(db, request, client=body.client or "manager", username=body.username,
user_id=body.user_id, pin=body.pin, password=body.password, legacy=body.client is None)
"terminal" = a user on a paired device: send the X-Xenia-Device header."""
return do_login(db, request, client=body.client, username=body.username,
user_id=body.user_id, pin=body.pin, password=body.password)
@router.post("/login-by-id", response_model=TokenResponse, dependencies=[Depends(public())], deprecated=True)