Skip to content

Document connections use fixed provider OAuth clients - #863

Merged
zlareb1 merged 4 commits into
mainfrom
feat/connected-provider-oauth-clients
Nov 18, 2026
Merged

zlareb1 merged 4 commits into
mainfrom
feat/connected-provider-oauth-clients

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Related: #860

Changelog category (leave one):

  • Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

Document connections have provider-specific OAuth clients with bounded requests, exact scope checks and credential-redacted failures.

Why

Document ingestion clients accept service-account keys, integration tokens or API keys. Connected accounts need separate OAuth exchange and rotation contracts. The existing shared token helper follows redirects and reads an unbounded response, so it cannot supply this credential boundary unchanged.

Scope and risk

One server-side client implements Google, Notion and Linear consent URLs, code exchange, identity metadata, refresh and revocation. Provider origins are fixed. Consent uses the configured public base, browser-state input and S256 where documented. Google requests only Drive read plus identity scopes; Linear requests read access as the user. Notion's read-content registration remains an external permission bound; opaque scope text supplies no capability proof.

Requests refuse redirects, share the caller's remaining deadline, cap metadata bodies and perform no retries. Request duration and response size come from document-connection settings, preserving the 30-second and 64 KiB defaults. Token pairs and account grants have redacted representations; provider bodies and network exception text do not reach rendered failures. Google can retain an omitted replacement refresh token, while Notion and Linear require replacement material. Notion display email and expiry remain optional rather than being invented.

This is the provider HTTP boundary. It exposes no connection route, credential-return operation or usable source binding. Its caller must consume browser-bound state, authorize the canonical Loom owner and source, serialize account generations, seal refresh material and clear local access before revocation. Those lifecycle handlers remain separate implementation work; no account, mirror, capability or live-search path is enabled here.

The architecture defines the provider contract required by this helper. Source entry points describe the implemented helper and its caller obligations.

Compatibility, rollout and rollback

  • Wire: no Loom operation, SDK signature or header changes.
  • Storage: no table, migration or credential-format changes. This helper persists nothing.
  • Operators: LOOM_KNOWLEDGE_CONNECTED_OAUTH_TIMEOUT_S and LOOM_KNOWLEDGE_CONNECTED_OAUTH_RESPONSE_MAX_BYTES bound provider requests. The caller deadline still applies. Provider registrations remain required for the complete connected-account feature.
  • Rollback: removing the helper and design text leaves no runtime or stored state to migrate.

Tests

  • The 27 directly related OAuth cases and the exact tunable-constant and default-snapshot checks pass: 29 cases in 4.20 seconds. The OAuth cases use real HTTPX clients with MockTransport; no provider, service, DB or browser starts.
  • Cases cover exact consent/token/identity/revocation wire shapes, the independent S256 example vector, scope expansion, missing rotation material, malformed bearer material, configured callbacks, unread error bodies, exception redaction, redirect refusal, streaming size limits, a shrinking shared deadline and cancellation cleanup.
  • Scoped Ruff format/lint, mypy for the source module, changed-page Prettier, prose and diff checks pass. Settings reference, schema, example and default snapshot include both fields.
  • Required full unit, package and integration checks run in GitHub CI and must pass on the final head. No broad local suite ran.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated: Codex wrote the change; fresh independent whole-diff review and final-head CI are required before merge.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Required final-head CI passes.
  • Fresh whole-diff review has no findings or nits.
  • Architecture states provider contracts and caller authorization obligations.
  • Settings reference, schema, example and default snapshot are updated; no migration, plugin, frontend or runtime changes.
  • Public text follows repository copy rules.
  • Commits are signed off.

Read provider wait and response caps from the settings catalog so operators can tune them. Preserve the existing defaults and caller deadline, generate the configuration outputs, and verify both overrides at the HTTP boundary.

Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit ed92b23 into main Nov 18, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant