bug(auth): PATCH /auth/v1/logins/<id>/ stores expiry_seconds but never extends expires_at

Open
#1,255 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Start with the PATCH handler in campus/auth/routes/logins.py around line 142, which passes expiry_seconds to login_resource[session_id].update(). Then read update() in campus/auth/resources/login.py near line 129, and post_init to see how expires_at is first derived from created_at. Settle the open questions in the issue first: whether extensions count from now or created_at, and what cap applies to expiry_seconds. Done means a contract test reads the session back after the PATCH and sees the new expires_at.

Written by the indexing model from the issue text.

Description

bug

What

PATCH /auth/v1/logins/<session_id>/ is documented as extending a login session. It stores expiry_seconds and leaves expires_at alone, so the session's real deadline does not move.

Established by reading the code path. Not exercised by a test.

Where

  • campus/auth/routes/logins.py:142 passes expiry_seconds straight to login_resource[session_id].update(...).
  • campus/auth/resources/login.py:129, update(), writes the given fields as they are (# TODO: Validate update fields). expires_at is derived only in __post_init__ at creation, from created_at plus expiry_seconds.
  • The expiry check at routes/logins.py:249 reads expires_at.

Effect

A caller that asks for another hour gets a 200 and an unchanged deadline. Once the auth housekeeping job starts sweeping by expires_at, the session is removed at the original time however often it was "extended".

Proposed fix

In update(), when expiry_seconds is supplied, recompute and store expires_at in the same write. Two things to decide first:

  • Whether an extension counts from now or from created_at. Creation uses created_at.
  • A cap on expiry_seconds, since it is caller-supplied and currently unvalidated.

Add a contract test that reads the session back after the PATCH and checks expires_at.

Dominant language
Python
Stars
0
Forks
2
Avg merge
39m
Merged PRs (30d)
235

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nyjc-computing/campus

All issues in nyjc-computing/campus

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.