Re-check the disabled workspace after consuming the invitation in register/complete

Open
#58 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
1-2 days
Newbie friendliness
54/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
fastapi, python

Research direction

Start with server/orcaster_server/auth/router.py, reading accept_register_complete around lines 386–417 and comparing the post-consume check in the join endpoint around lines 283–284. Then find the registration tests that cover normal completion and early refusal, and add the two-call refusal case from the acceptance criteria. Done means it returns 410 with reason refused, leaves no user, credential, membership, or consumed invitation, and adds a CHANGELOG entry; the workspace locking question needs an owner decision.

Written by the indexing model from the issue text.

Description

bug P1 server

Problem

In POST /auth/accept/{token}/register/complete, the host refusal check (for example a disabled workspace) runs before the user is created (server/orcaster_server/auth/router.py:386). The invitation is consumed later (server/orcaster_server/auth/router.py:400) and the transaction is committed after the callback (server/orcaster_server/auth/router.py:417). There is no second check after the consume.

If the workspace is disabled between the first check and the commit, the registration still succeeds and the callback adds a membership to a disabled workspace. The join endpoint already checks after the consume and rolls back on refusal (server/orcaster_server/auth/router.py:283 and server/orcaster_server/auth/router.py:284).

Proposed change

  • In accept_register_complete, after consume_invitation returns OK, call _refused(db, inv) again.
  • If it is refused, return the same 410 response with reason refused as the early check. Nothing is committed, so the user, credential and consume are rolled back, as for the other early returns.
  • Keep the early check, so a refused invitation still creates no rows.

Acceptance criteria

  • A test makes is_invitation_refused return false on the first call and true on the second, and shows that register/complete answers 410 with reason refused, creates no user, no credential and no membership, and leaves the invitation unconsumed.
  • The normal registration and the existing early refusal keep their responses.
  • The response codes and reason values of the endpoint do not change, so existing deployments and clients keep working without changes.
  • CHANGELOG entry under Unreleased.

Open questions

  • Should the check also lock the workspace row, so that a disable cannot commit between the re-check and the commit? The re-check narrows the window but a row lock would close it. This needs an owner decision, since it adds locking to the registration path.
Dominant language
Python
Stars
0
Forks
0
Avg merge
1d 1h
Merged PRs (30d)
10

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 AInvirion/orcaster

All issues in AInvirion/orcaster

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.