mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 05:09:51 +08:00
The remote callback endpoint added in #716 cannot be authenticated: the browser reaches /auth/callback on the far end of the user's own tunnel, a different origin from the DeepTutor Web session, so no cookie is sent. The user ContextVar is only ever set inside require_auth, which left get_codex_oauth_service() resolving every callback to the default root while the login operation lived under data/users/<id> — so remote Codex sign-in returned login_not_active for every non-administrator. Deliver by OAuth state instead. The state is a secret this process minted for exactly one login and is compared in constant time, which is already the trust model the loopback listener uses; no new authorization surface is opened. Delivery keeps the endpoint's existing status codes: 409 when nothing is waiting, 400 when a login is waiting but the state does not match. The PR's endpoint tests monkeypatched the service factory, so user resolution was never exercised; they now patch the delivery seam, and three service-level tests cover routing to a non-default instance.