Skip to content

feat: GitHub connector OAuth#1580

Open
felixschmetz wants to merge 18 commits intomainfrom
feat/github-oauth
Open

feat: GitHub connector OAuth#1580
felixschmetz wants to merge 18 commits intomainfrom
feat/github-oauth

Conversation

@felixschmetz
Copy link
Member

@felixschmetz felixschmetz commented Mar 9, 2026

Summary by cubic

Add GitHub OAuth browser flow and unify token handling under a single token field. Tokens are validated via the source lifecycle, and the UI now prefers OAuth when available.

  • New Features

    • Enable GitHub OAuth2 authorization_code (oauth_type: access_only); add OAuth endpoints to dev and self-hosted integration YAMLs; send Accept: application/json on token exchange.
    • Unify credentials under GitHubAuthConfig.token; normalize personal_access_token/access_token; validate ghp_, github_pat_, gho_, and 40-hex formats; update frontend and cursor validation rules.
    • Frontend respects backend auth_methods order and defaults to the first.
  • Other Changes

    • OAuth callback validates via SourceLifecycleService.validate; fix token validation by passing the raw string; lifecycle wraps into auth config when auth_config_ref is present.
    • GitHubSource: rename personal_access_token to token; allow token-only instantiation for validation paths; prefer oauth_browser in auth_methods; update auth headers.
    • Auth providers and tools updated for token rename: Composio and Pipedream now map token; monke broker normalizes access_tokentoken; GitHub bongo uses token.
    • Exclude local_storage from uvicorn reload; add tests for GitHub auth config, lifecycle validate, and OAuth callback; fix test imports and lints; format tests with ruff.

Written for commit 10f3d6f. Summary will update on new commits.

Add OAuth2 authorization_code support alongside existing PAT auth for the
GitHub source. Map OAuth access_token to personal_access_token transparently
via model_validator, and ensure Accept: application/json header is sent on
token exchange so GitHub returns JSON instead of URL-encoded form data.
Skip repo_name requirement in GitHubSource.create() when config is None
(token-validation-only path). Add Accept: application/json header to
domains OAuth2 token exchange so GitHub returns JSON.
Iterate auth_methods in backend-defined order instead of hardcoding
direct_auth first. Default selection now picks the first available
method, so sources with OAuth first (like GitHub) show it on top.
…tion

- Add BaseSource.validate_token() classmethod for lightweight OAuth
  token checks without full source instantiation
- GitHubSource.validate_token() pings GET /user to verify token
- callback_service uses validate_token() instead of create()+validate()
- GitHubAuthConfig: two explicit Optional fields (personal_access_token,
  access_token) with model_validator(after) requiring exactly one;
  token property returns whichever is set. No silent field remapping.
- GitHubSource.create() restored to strict typed signature
- Frontend validation accepts gho_ OAuth token prefix
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 17 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/airweave/platform/configs/tests/test_github_auth.py">

<violation number="1" location="backend/airweave/platform/configs/tests/test_github_auth.py:45">
P1: Custom agent: **Check for Cursor Rules Drift**

Update Cursor rule docs for GitHub token validation to include OAuth app tokens (`gho_`), since this PR adds that accepted format and currently violates the rule’s requirement to keep Cursor rules synchronized with API/auth pattern changes.</violation>
</file>

<file name="backend/airweave/domains/oauth/callback_service.py">

<violation number="1" location="backend/airweave/domains/oauth/callback_service.py:568">
P2: `SourceLifecycleService.validate` expects the raw access token for token-only sources (e.g., Todoist/Notion). Passing `{"access_token": ...}` results in a dict being treated as the token, breaking validation. Pass the access token string directly (as you already do in source connection creation).</violation>
</file>

<file name="backend/airweave/domains/sources/lifecycle.py">

<violation number="1" location="backend/airweave/domains/sources/lifecycle.py:183">
P2: `model_validate()` can raise before the `SourceCreationError` wrapper, so invalid credential payloads escape as raw exceptions instead of the service’s documented creation error type.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="monke/auth/broker.py">

<violation number="1" location="monke/auth/broker.py:186">
P1: Custom agent: **Check for Cursor Rules Drift**

Update the Monke Cursor rules to match the new `token`-based credential flow; they still instruct `personal_access_token`/`access_token`, which is now drift for `monke/**` auth guidance.</violation>
</file>

<file name="backend/airweave/platform/auth_providers/composio.py">

<violation number="1" location="backend/airweave/platform/auth_providers/composio.py:40">
P1: Custom agent: **Check for Cursor Rules Drift**

Update the relevant Cursor rules for the unified GitHub `token` field. Rule `Check for Cursor Rules Drift` requires the auth-provider guidance to stay in sync, but the current rules still teach `personal_access_token`, so Cursor will keep suggesting the old credential shape for this flow.</violation>
</file>

<file name="monke/bongos/github.py">

<violation number="1" location="monke/bongos/github.py:30">
P1: Custom agent: **Check for Cursor Rules Drift**

Update the Cursor rules for GitHub Monke auth to use `token` instead of `personal_access_token`; they currently describe an auth contract this change no longer accepts.</violation>

<violation number="2" location="monke/bongos/github.py:30">
P2: Keep the legacy GitHub credential aliases here, or direct-auth GitHub runs will fail before the test starts.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Sources without auth_config_ref (Todoist, Notion) expect a plain token
string. Lifecycle now wraps string credentials for auth_config_ref sources.
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