Revoke pesu-auth's PESU Academy tokens after each login
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 42/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- api, authentication, backend, documentation, testing
Direzione di ricerca
Start with authenticate, _upstream_call, close_client, _CLOSE_TASKS, and _close_client_quietly; read tests/unit/test_pesu.py and test_metrics_instrumentation.py for lifecycle and metrics expectations. Follow CONTRIBUTING.md for credential-based testing and inspect the README metrics documentation. Done means successful logins trigger a best-effort logout without changing responses or adding latency, failures are recorded, clients do not leak, and the live functional test passes.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
🔄 Updated for v5.0.0 (2026-10-08). 5.0.0 signs in through PESU Academy's mobile API (#241), so there is no web session or cookie to end any more: a login returns an access token (valid for 30 minutes) and a refresh token. The goal is the same, ending what pesu-auth started, but the investigation is now about the mobile app's logout or token revocation call, and the cleanup no longer goes through
close_client, which is gone.
⚠️ PES University students only. This change sits in the login path and has to be tested end to end against PESU Academy with real PESU credentials (see "Tests that need credentials" in
CONTRIBUTING.md). Run the whole suite with your credentials in.envand paste the summary line into your PR. Every run makes real logins to PESU Academy, so run it when you need it, not in a loop.
Summary
Every successful login through pesu-auth leaves a valid access token (30 minutes) and refresh token on PESU Academy's side. pesu-auth closes its HTTP client and never stores either token, but PESU still considers them live until they expire. If PESU's mobile API has a logout or revocation call, use it, as a best effort, once pesu-auth has finished with the login.
Why
- Being a good client: pesu-auth logs in on behalf of many students and uses each login for a second or two. Leaving a live token pair behind for every one of them is wasteful, and PESU could reasonably object to it.
- Less exposure: a revoked token is useless even if it leaked somehow. The refresh token in particular may live much longer than the access token.
Proposed change
- Find the logout request. pesu-auth's endpoints were read off the PESU Academy mobile app's own traffic (see the comment above the constants in
app/pesu.py). Do the same for logging out:- log out in the mobile app with your own account and capture the request: its method, URL, headers (such as
X-Client-Type: MOBILEandAuthorization) and body; - it may be a dispatcher call with its own
action/mode/menuId, like the profile call, or a separate endpoint; check, don't guess; - record it in the PR with no token values.
- log out in the mobile app with your own account and capture the request: its method, URL, headers (such as
- Check what logout affects. pesu-auth has shown that PESU allows several sessions per account at once: two parallel logins both worked, and an older login's token still worked after a newer one. Check that revoking pesu-auth's token does not end the student's own app or browser session: log in on your phone, log in through a local pesu-auth with this change, then use the app. If it logs the student out everywhere, stop and report back in this issue before continuing, because that would be a regression for every user.
- Implement it as a best effort:
- After a successful login, and after the profile call if one was requested, send the logout through
_upstream_call(self._metrics, "logout"). This adds a thirdoperationlabel value, which is bounded; update the README's metrics docs. - It must never change the response. Catch and log failures at WARNING (never the token); never raise.
- It must not add latency. Run it in a background task that owns the client and closes it afterwards, holding a strong reference (see
_CLOSE_TASKSand_close_client_quietlyfor the pattern). Move the close out ofauthenticate'sfinallyonly for this path; every other path still closes immediately. - On shutdown, finish or cancel these tasks so no client leaks.
lifespaninapp/app.pyhas no cleanup step since 5.0.0, so this adds one (for example a publicPESUAcademy.aclose()that it awaits).
- After a successful login, and after the profile call if one was requested, send the logout through
- Don't log out after a failed login: there's no token to revoke.
Tests
- A successful login schedules exactly one logout with the right method, URL and headers, and the response is returned without waiting for it.
- A logout failure (exception or non-200) is logged and counted, and the response is unaffected.
- A failed login doesn't log out.
- No token appears in any log line (
caplog). - Every client is still closed exactly once, including when shutdown happens during a logout (the client-lifecycle tests in
tests/unit/test_pesu.pyandtest_metrics_instrumentation.py). - The live suite passes. Add a functional test that a login followed by a logout succeeds.
Acceptance criteria
- pesu-auth revokes its tokens after each successful login, or the issue is closed with evidence that the mobile API has no such call
- It doesn't log students out of their own app or browser sessions (verified and written up in the PR)
- No added latency, and no client leaks
- Documented in the README (the flow and the metrics)
How to contribute
- Wait until you're assigned. Comment to ask for this issue, then wait for a maintainer to assign it to you before writing any code. PRs for unassigned issues are closed without review.
- Read
CONTRIBUTING.mdfirst. It covers forking, setting up withuv, and running the tests. - Branch from
devin your fork, and open the PR againstdevwith a Conventional Commit title andCloses #188in the description. - Bump the minor version in
pyproject.tomland runuv lock(CI checks this).uv run pre-commit run --all-filesmust pass, and coverage must stay at 100%. - Update the README,
app/docs/and comments in the same PR as the behaviour they describe. - Never log, print, store or echo a password or token, including in tests, PR descriptions and screenshots.
- Lingua principale
- Python
- Stelle
- 22
- Fork
- 29
- Merge medio
- 1g 3h
- PR unite (30g)
- 19
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
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 pesu-dev/auth
-
Check the README for dead links and fix the misleading Docker Hub badgeForse di nuovo libera @knownshah l’ha presa 19 giorni fa e non c’è nessuna pull request aperta. Apertadocumentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
pesu-dev/auth#220 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug documentation enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 54/100
I maintainer di solito rispondono entro 1 giorno
-
Commit SHA should be used instead of tag git based deployForse già presa @aditeyabaral l’ha presa 13 giorni fa. Apertabug
pesu-dev/auth#236 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Private Functions in `app.py` needs to be in separate fileForse già presa @aditeyabaral l’ha presa 13 giorni fa. Apertaapi enhancement
pesu-dev/auth#235 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Gather the campus mapping and other shared values into constants modulesForse già presa @edgelordlinux l’ha presa 13 giorni fa. Apertaapi enhancement good first issue pesuacademy student profile tests and ci/cd
pesu-dev/auth#230 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di pesu-dev/auth
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
lidofinance/diffyscan#239 ·
I maintainer di solito rispondono entro 1 giorno
-
docs: the dev-setup table and AGENTS.md name the reviewed_by guard that CI's Changelog job runsApertaarea: tools documentation good first issue ready for a contributor
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
eyalgolan/statecraft-israel#873 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
GET rooms API returns 500 due to nonexistent Room.is_active attributeForse già presa @Mars-60 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Add cover art to song rowsApertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 5 giorni
-
Harmony OPeNDAP SubSetter (HOSS) Geographic production rssmif16d 7 XYZ_PROV
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
nasa/harmony-autotester#341 ·