SUBTASK #86: Sessions and route protection in the Application Controller (2.0)
Maintainers usually reply within 1 day
@javi120467 is already working on this.
Since Nov 2, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- api, authentication, authorization, backend
Research direction
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.
Written by the indexing model from the issue text.
Description
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)
- Dominant language
- Python
- Stars
- 1
- Forks
- 1
- Avg merge
- 9h 31m
- Merged PRs (30d)
- 36
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Bearkat-Professionals/Software-Engineering-Project
-
SUBTASK #86: Password hashing (BB-5)Possibly taken @Edgeless6 claimed this 2 days ago. Openbackend Low Priority subtask
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Bearkat-Professionals/Software-Engineering-Project#87 · 1 assignee ·
Maintainers usually reply within 1 day
-
Enhancement: Regression tests for Validate Input crash fixes (SH-1)Possibly taken @yoshi301 claimed this 1 day ago. Openbackend Low Priority
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Bearkat-Professionals/Software-Engineering-Project#59 · 1 assignee ·
Maintainers usually reply within 1 day
-
SUBTASK #86: Manage user accounts (admin)Possibly taken @Edgeless6 claimed this 2 days ago. Openbackend Low Priority subtask
Difficulty 4/5 Over a week Newbie friendliness 20/100
Bearkat-Professionals/Software-Engineering-Project#92 · 1 assignee ·
Maintainers usually reply within 1 day
-
SUBTASK #86: Login screen and signed-in layoutPossibly taken @Solo-Her0 claimed this 2 days ago. Openfrontend Low Priority subtask
Difficulty 4/5 3-5 days Newbie friendliness 28/100
Bearkat-Professionals/Software-Engineering-Project#91 · 1 assignee ·
Maintainers usually reply within 1 day
-
SUBTASK #86: Sign in and account rules (2.1)Possibly taken @PavlockBlaine03 claimed this 2 days ago. Openbackend Low Priority subtask
Difficulty 4/5 3-5 days Newbie friendliness 42/100
Bearkat-Professionals/Software-Engineering-Project#89 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in Bearkat-Professionals/Software-Engineering-Project
Similar issues
-
bug module:nodes tests
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rocketride-org/rocketride-server#3020 ·
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
bretterer/home-assistant-rivian#335 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
mampfes/hacs_waste_collection_schedule#8114 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
TIGER-AI-Lab/ClawBench#475 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
UKGovernmentBEIS/inspect_ai#6322 ·
Maintainers usually reply within 1 day