[Desk] Removing a member's roles leaves sessions, invites, passkeys and TOTP sign-in live, and dual-cookie browsers split reporter accounts
Report
Summary
In xeprotocol/desk@ab9df7f, auth.resolve (desk/auth.py:726) treats a User with roles == [] as no longer a team member (# no roles, no team member), and users.set_roles(..., []) (desk/services/users.py:60) revokes agent tokens when a member leaves the team. However, six authentication/credential paths still treat a roleless User (u.active and u.roles == []) as an active team member, and browsers holding both desk_session and desk_reporter cookies fail to resolve their reporter session across reporter routes and UI pages:
- Roleless
User(u.roles == []) retains live sessions, invites, passkey login, and TOTP login (Medium):users.set_roles(desk/services/users.py:56-62) does not acquireauth.member_lock(db, u.id)before writingu.roles, does not delete existingSessionrows, and does not callauth.drop_invites(db, u.id)whennot u.roles.auth.session_from_request,auth.consume_invite,auth.passkey_begin_login,auth.passkey_finish_login(desk/auth.py:167, 406, 599, 647), andauthn.totp_login(desk/api/authn.py:131) checku.activewithoutbool(u.roles).- Moreover, a stale
desk_sessionbelonging to a rolelessUsercausesauth.resolve(L724-728) to returnAuth(Principal(), session=None)early without falling through toreporter_session_from_request, locking that browser out of its reporter session until cookies are cleared.
- Dual-cookie browser (
desk_session+desk_reporter) breaks reporter routes and creates split accounts on identity linking:- While
rapi.logout(desk/api/reporter.py:388,XE-2101) explicitly callsauth.reporter_session_from_request(db, request)whenwho.session is not None, every other route indesk/api/reporter.pyanddesk/ui.py:128readswho.reporterdirectly (which isNonewheneverwho.sessionis present, pertest_db.py:3904). - Consequently, in a browser holding both cookies (with valid team CSRF token),
xe_login(rsvc.from_xe(..., link_to=who.reporter)) andemail_start(_email_link) treat the signed-in reporter as signed out and silently create a separate duplicateReporteraccount instead of linking to the browser's reporter account, while/v1/reporter/mereturns{"reporter": null}and/payout,/tickets,/auth/github/link,/auth/discord/link, and/sessions/revoke-othersfail with401.
- While
Rule
A User with roles == [] is not a team member on any session, invite, passkey, or TOTP path, and a browser holding both desk_session and desk_reporter resolves its reporter session on reporter routes and UI pages while deps.current retains the team principal and team CSRF check.
Proposed Fix
Ready-to-merge patch and regression tests submitted in https://github.com/xeprotocol/desk/pull/1.
Thread
Thanks for the report. We have read it against the current code and it is being handled. The assessment and any award follow the fix.