feat(web): add Hub OAuth client, signed session, and allowlist gate #11
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/hub-oauth-login-allowlist"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements step 3 of the multi-user remote MCP epic: the upstream YouTrack Hub OAuth client and the user login / allowlist gate. No downstream authorization-server endpoints or HTTP wiring yet (those land in later steps), so the new
webmodule isallow(dead_code)scaffolding the binary does not yet call, mirroring the crypto and db steps.src/web/oauth_hub.rs: builds the Hub authorize URL with PKCE S256 and the offline scope, exchanges the callback code for Hub access + refresh tokens via theoauth2crate (rustls-only reqwest), fetches identity from Hubusers/me, and refreshes an expired Hub token on demand (retaining the prior refresh token when Hub omits a new one).complete_loginapplies the allowlist gate: a non-allowlisted identity is denied and no user row is created, while an allowlisted identity is upserted (with first-admin bootstrap viaYT_MCP_ADMIN_HUB_LOGIN) and its Hub tokens stored encrypted.src/web/session.rs: a short-lived HMAC-SHA256 signed-cookie browser session that carries the CSRF state and PKCE verifier across the Hub round-trip. HMAC is computed over the existingsha20.10 primitive to avoid ahmaccrate that tracks a newerdigest.Adds the
oauth2(default features off,reqwest+rustls-tls) andreqwest(rustls-only) dependencies. Bootstrap config readsYT_MCP_HUB_ISSUER,YT_MCP_HUB_CLIENT_ID,YT_MCP_HUB_CLIENT_SECRET,YT_MCP_PUBLIC_BASE_URL,YT_MCP_ADMIN_HUB_LOGIN, andYT_MCP_HUB_SCOPE. Tests drive the code/refresh/identity exchanges against an in-process mock HTTP server and the gate against an in-memory SQLite database.#YTMCP-5