mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 15:11:04 +08:00
A Codex token authorizes one person's ChatGPT plan, so the profile is correctly never grantable — but the OAuth endpoints were admin-only too, which left ordinary users unable to reach Codex by any route: they could neither be given the administrator's profile nor sign in for themselves. What made per-user sign-in unsafe was where the profile landed: ``get_model_catalog_service()`` resolves a non-admin to the ADMIN catalog, so a user's sync would have published their profile into the shared one. A sign-in now publishes into the owner's own catalog, keyed by the same owner resolution as the credential store, so a login and its profile can never land in different places. Ordinary users get ``data/users/<uid>/settings/model_catalog.json``; an administrator gets the shared catalog exactly as before. ``redacted_model_access`` — the one place grants are resolved — gains those personal rows (source="personal") for the caller's OWN id only, so the option list, the capability gate, and selection validation agree without three separate merges, and an administrator inspecting somebody's grants still sees only what they assigned. The resolution path merges the same profiles so a personal selection resolves to a real profile, with the owner's copy winning over a shared profile of the same managed id (the ids are per-provider constants, and the administrator's copy lists their models, not the user's). Runtime token ownership needed no change: the provider already reads the token per owner. Endpoint gating is narrower rather than absent — a partner is refused, since it is a synthetic user whose owner is a real account and admitting one would mean acting on that person's login, sign-out included. The restricted-user Settings → LLM page grows the connect/refresh/sign-out card (no catalog, no credentials), and a sign-in now drops the cached model options so a freshly connected account does not keep seeing the old list.