SUBTASK #86: Sessions and route protection in the Application Controller (2.0)
I maintainer di solito rispondono entro 1 giorno
@javi120467 ci sta già lavorando.
Dal 2/11/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 22/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- api, authentication, authorization, backend
Direzione di ricerca
Start from the Application Controller package from #50, then add the auth module at backend/controller/auth.py with its tests in tests/controller/test_auth.py. The SECRET_KEY note goes in the .env section of README.md. Build the @requires and @public decorators and the /api/login, /api/logout and /api/me routes, and run the Flask test client tests without a database. Done when those tests pass and an unauthenticated GET /api/devices returns 401. The issue depends on #88, #89 and #50, which are not yet complete.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What to do
Connect access control to the Flask app from #50: sign-in, sign-out and "who am I" endpoints, a secure session cookie, and a permission check on every API route, so a request that isn't allowed never reaches a service.
Background
- Spec SEC-01, SEC-03, SEC-07, SEC-09, CP-01, CM-11; AT-13 (an action the role doesn't permit is rejected and logged)
- System design 11.2: session cookie Secure, HttpOnly, SameSite=Strict;
ApplicationController.checkPermissions() → AccessControlService.authorizeAction() - System design 12: Flask's built-in session handling
- Permissions are subtask 2; sign-in is subtask 3. Session length is a decision on #PARENT.
Steps
- Settings:
-
SECRET_KEYfrom.env. The app refuses to start if it's missing or shorter than 32 characters. The README shows how to make one:py -3.13 -c "import secrets; print(secrets.token_hex(32))" - Cookie:
HttpOnly,SameSite=Strict, andSecurewhenever the app is served over HTTPS (HTTPS itself arrives in M7) - Signed out after 8 hours in any case, and after 30 minutes without a request (a "last seen" time in the session, checked on each request)
-
- Endpoints:
-
POST /api/loginwith{username, password}: 200 with the user (to_dict()) and their permissions, or 401 with{"error": reason}. On success, clear the session before storing the user id, so a session made before sign-in can't be reused (session fixation). -
POST /api/logout: clears the session, 204 -
GET /api/me: the signed-in user and their permissions, or 401
-
- Route protection:
-
@requires(Permission.X)on every route: loads the user from the session on each request; 401 if not signed in, timed out or disabled (and clears the session); 403 with the reason fromauthorizeif the role isn't allowed; otherwise puts the user onflask.g.user -
@publiconly onPOST /api/login - A test that walks
app.url_mapand fails if any/api/route has neither
-
- Refused requests are logged at WARNING: user, permission and path, never the request body
- Starting a scan (#51) takes the user from
g.user, not from the request body (CM-11) - Requests that change data must be JSON (
Content-Type: application/json), otherwise 415. Together withSameSite=Strict, this stops another website from submitting changes using a signed-in user's cookie (CSRF). - Unit tests (Flask test client, fake stores, a fake clock):
- Signed out: every
/api/route except login gives 401 - A viewer gets 403 on starting a scan, and 200 on the device list
- The login response sets a cookie marked
HttpOnlyandSameSite=Strict - After sign-out, the old cookie gives 401
- A user disabled after signing in gets 401 on their next request
- 31 minutes without a request gives 401
- No response body contains
password_hashor$argon2 - A refused request is logged without the password (
assertLogs) - A form-encoded POST gives 415
- Signed out: every
Where
- The Application Controller package from #50 (e.g.
backend/controller/auth.py) tests/controller/test_auth.pyREADME.md(theSECRET_KEYline in the.envsection)
Done when
- All the tests above pass without a database
- With the app running,
GET /api/devicessigned out gives 401, and after signing in as a viewer gives the list
Depends on
- Roles and permissions (#88) and Sign in (#89)
- Application entry point and Application Controller (#50)
- Scan and device API endpoints (#51)
- Lingua principale
- Python
- Stelle
- 1
- Fork
- 1
- Merge medio
- 9h 31m
- PR unite (30g)
- 36
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Bearkat-Professionals/Software-Engineering-Project
-
SUBTASK #86: Password hashing (BB-5)Forse già presa @Edgeless6 l’ha presa 3 giorni fa. Apertabackend Low Priority subtask
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Bearkat-Professionals/Software-Engineering-Project#87 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Enhancement: Regression tests for Validate Input crash fixes (SH-1)Forse già presa @yoshi301 l’ha presa 2 giorni fa. Apertabackend Low Priority
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
Bearkat-Professionals/Software-Engineering-Project#59 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
SUBTASK #86: Manage user accounts (admin)Forse già presa @Edgeless6 l’ha presa 3 giorni fa. Apertabackend Low Priority subtask
Difficoltà 4/5 Più di una settimana Idoneità per principianti 20/100
Bearkat-Professionals/Software-Engineering-Project#92 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
SUBTASK #86: Login screen and signed-in layoutForse già presa @Solo-Her0 l’ha presa 3 giorni fa. Apertafrontend Low Priority subtask
Difficoltà 4/5 3-5 giorni Idoneità per principianti 28/100
Bearkat-Professionals/Software-Engineering-Project#91 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
SUBTASK #86: Sign in and account rules (2.1)Forse già presa @PavlockBlaine03 l’ha presa 3 giorni fa. Apertabackend Low Priority subtask
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
Bearkat-Professionals/Software-Engineering-Project#89 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Bearkat-Professionals/Software-Engineering-Project
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
cline/mcp-marketplace#3576 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
griptape-ai/griptape-nodes-library-elevenlabs#30 ·
I maintainer di solito rispondono entro 1 giorno
-
docs: Release playbookApertadocumentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
awslabs/social-messaging-agent-runtime-toolkit#140 ·
I maintainer di solito rispondono entro 1 giorno
-
subtask
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
fga-eps-mds/2026.2-MeasureSoftGram-DOC#187 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
NSPG13/agent-bounties#1747 ·
I maintainer di solito rispondono entro 1 giorno