Skip to content

feat(github): connect with a personal access token, not only the App - #292

Merged
artempartos merged 4 commits into
developfrom
feat/github-pat-connect
Sep 18, 2026
Merged

artempartos merged 4 commits into
developfrom
feat/github-pat-connect

Conversation

@artempartos

@artempartos artempartos commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes the "GitHub integration: Personal Access Token setup path for local / developer try-out" task.

Problem

GitHub connect was GitHub App only. Connect → GitHub went straight to github_app_install, which needs a configured App on the deployment (GITHUB_APP_ID, private key, webhook secret, public Setup URL), someone who can install it on the org, and a host github.com can call back. A local or personal-account setup has none of that, so a developer could not connect GitHub, attach a repo, or run a workflow against real GitHub code at all. GitLab has had in-app PAT connect all along; Azure DevOps has App vs PAT.

What this adds

Connect → GitHub now opens a dialog with two modes instead of redirecting:

  1. I own the organization and can install the app (Recommended) — the current flow, unchanged.
  2. I'm a developer and just want to try it (personal access token) — paste a token, Connect.

The App stays the default. On a deployment with no App configured the dialog opens on the token path and the App radio is disabled with the reason, rather than offering a button whose only outcome is "GitHub App is not configured" (the page gets a github: { appConfigured: } prop for this).

Backend

  • Github::TokenService carries both credential shapes behind the same two methods. In PAT mode the stored token is the credential: nothing is minted, repositories: cannot narrow it, and the App installation-token path is never walked with a PAT. Every consumer — clone, refresh_github_token, tool GITHUB_TOKEN, CI status probe, Coder bootstrap — is unchanged as a result.
  • verify_token verifies against GET /user and reads X-OAuth-Scopes off the same response. A classic token with neither repo nor public_repo is refused at connect time rather than failing later at clone time; a fine-grained token reports no scopes, so it is accepted on the call succeeding.
  • Github::IntegrationService#create_with_pat stores the token encrypted with auth_mode: "pat" in settings. A token that does not verify is not persisted — an unverified token repairs by being pasted again, so a saved row would only be litter with a dead secret in it. Re-pasting replaces the token on the project's existing PAT row (keeping its attached repositories) and a rejected re-paste leaves the working connection completely untouched.
  • Github::RepositoryService#list_available asks /user/repos in PAT mode; /installation/repositories refuses a token with 403.
  • Repository's owner-must-match-the-installation-account check is now App-only. A PAT reaches every repository its owner can see across every org, so checking the owner against the token holder's own login would refuse exactly the org repositories the token was pasted for.
  • The connect endpoint branches on the declared mode, never on which parameter is present, so a mode switch in the dialog cannot submit the other path's credential.
  • A rejected token answers with an Inertia field error instead of a flash alert, so the dialog stays open with what was typed.

Migration

None. A GitHub connection with no auth_mode in settings reads as "app", which is what every existing one is.

Deliberately not done

GitHub delivers no webhooks to a token, and a local deployment is usually unreachable from github.com anyway. CI gates on a PAT connection therefore resolve through GateReconciler's polling rather than a push / pull_request / check_run event — stated in the dialog and in the docs, with no App-only event faked. Also out: replacing the App in production, company-wide GitHub, per-capability checkboxes, GitHub Enterprise Server.


What it looks like

Image URLs are pinned to this PR's merge commit: the screenshots were dropped from the
tree afterwards (they backed this description, not any document), and a commit-pinned blob
keeps rendering regardless.

Choosing how to connect

Opening Connect → GitHub now asks which path, rather than leaving for
github.com immediately. The App is marked Recommended and preselected; the token
option says what it is for in the same breath, so nobody has to guess which one
they are entitled to.

GitHub App — the default Personal access token

The token panel carries the three things that are easy to get wrong: that the
token acts as its owner and receives no webhooks, which scopes are needed for a
classic versus a fine-grained token, and that expiry is answered by pasting a
new one. The link pre-ticks repo on GitHub's own token form.

A token GitHub rejects

Verification happens before anything is stored, so an invalid, revoked or expired
token never produces an active integration. The reason lands against the field
and the dialog keeps what was typed — a flash alert would have closed it. The
count in the header is unchanged behind the dialog: nothing was persisted.

A deployment with no GitHub App

The case the whole change exists for. Both modes are still shown — the App is not
hidden, it is disabled and says which variables are missing — and the dialog
opens on the path that can actually complete.

Afterwards

A token connection is marked as one on the row, with whose token it is and the
scopes GitHub reported. Both facts matter when a gate does not close: it acts as
a person, and it gets no webhooks.


Tests

  • Github::TokenService — PAT contract tests against GET /user (identity, classic scopes, fine-grained nil scopes, scopeless refusal, 401, works with no App id).
  • Github::IntegrationService — PAT connect, fine-grained token, no-App deployment, rejected token persists nothing, re-paste replaces in place, rejected re-paste leaves the row intact, App row untouched.
  • Github::RepositoryService — /user/repos and branch listing authenticate with the stored token.
  • Integration / Repository models — auth-mode defaulting and the App-only owner check.
  • Request tests — the appConfigured prop, PAT connect without an App, the field error, and the mode ignoring a posted installation id.
  • GithubConnectModal.test.tsx — both modes, what each submits, that switching mode does not carry the other credential, the disabled App path, scopes copy, and the warning.

Checks

be_check_all and fe_check_all are green on CI (rails test, rubocop, brakeman, eslint, tsc, steiger, vitest). Two things CI caught on the first push and are fixed here: a PAT branch-listing stub that did not account for auto_paginate's per_page=100, and seven Minitest/RefutePredicate offenses.

The screenshots above were taken against a local deployment built from this
branch; the rejected-token one is a real 401 from api.github.com.

Docs

docs/user-guide/integrations.md (+ the portal copy) now documents both paths, the scopes for classic and fine-grained tokens, expiry, and the webhook gap. docs/quickstart.md and docs/reference/configuration.md (+ portal copies) say the GITHUB_APP_* variables are not needed to connect GitHub.

🤖 Generated with Claude Code

GitHub connect was GitHub App only, so anyone who cannot install an app
— a local deployment with no GITHUB_APP_*, no org-admin rights, no host
github.com can call back — could not connect GitHub or attach a repo at
all. GitLab has had in-app PAT connect all along; Azure DevOps has App
vs PAT. GitHub now has the same choice, with the App still recommended
and still the default.

Connect → GitHub opens a dialog with the two modes instead of
redirecting straight to the install. The App path is unchanged: signed
state, install callback, installation_id. The PAT path posts the token
to the project integrations endpoint, verifies it against GET /user,
and stores it encrypted, write-only.

Github::TokenService now carries both credential shapes behind the same
two methods: in PAT mode the stored token IS the credential, so nothing
is minted and `repositories:` cannot narrow it — the App
installation-token path is never walked with a PAT. Every consumer
(clone, refresh, tools, CI status, Coder bootstrap) is unchanged as a
result. Github::RepositoryService asks /user/repos instead of
/installation/repositories, which a token cannot read.

Repository's owner-must-match-the-installation-account check is now
App-only: a PAT reaches every repository its owner can see across every
org, so checking the owner against the token holder's login would refuse
exactly the org repositories the token was pasted for.

Existing App connections need no migration — a connection with no
`auth_mode` in settings reads as "app", which is what they are.

Out of scope, and said so in the UI and the docs: GitHub delivers no
webhooks to a token, so CI gates on a PAT connection resolve through the
reconciler's polling rather than a push/pull_request/check_run event. No
App-only event is faked.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
@artempartos
artempartos force-pushed the feat/github-pat-connect branch from c509431 to 0e11237 Compare September 18, 2026 00:44
artempartos and others added 3 commits September 18, 2026 04:58
The two connect modes, a rejected token, a deployment with no App, and what
a token connection reads as afterwards. Captured against a local deployment;
the rejected-token shot is a real 401 from api.github.com.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
The dialog and the docs listed `Contents` + `Metadata` for a fine-grained
token, which covers cloning and pushing and nothing else. Three capabilities
the app does use were missing, and each fails on its own rather than failing
the connection, so the omission surfaced as a working connection that could
not do one specific thing:

- `Pull requests` write — an agent opens and answers PRs itself, with `gh` or
  the API, on this token. There are no server-side GitHub PR tools, so this is
  the only grant behind that.
- `Checks` + `Actions` read — Github::CheckStatusService reads
  `pull_request`, `check_suites_for_ref` and `workflow_run` to resolve CI
  gates, which is the polling path a token connection depends on precisely
  because it gets no webhooks.
- `workflow` on a classic token — GitHub rejects a push that touches
  `.github/workflows` without it.

Also says outright that Aixle's own board tasks, workflows and sessions are
not GitHub objects and need no scope, since that is the next question.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
The three shots that show the token panel carried the old copy, which named
two of the five grants. Retaken from the branch as it stands.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
@artempartos
artempartos merged commit 369b5fd into develop Sep 18, 2026
7 checks passed
artempartos added a commit that referenced this pull request Sep 18, 2026
Six PNGs sat in the tree that nothing in it references.

`01-admin-projects-single-company.png` has been at the repository root
since 48c15ea, unreferenced — a screenshot that escaped into the commit
rather than into a pull request.

`docs/design/images/github-pat-connect/` (5 files, #292) backed that pull
request's description and no document, which is the difference from
`docs/design/images/federated-identity/` on the open #288 branch: those
are embedded in `docs/design/federated-identity.md` with relative links,
so they are the document's own assets and stay.

#292's description now points at its merge commit rather than at its
branch, so the screenshots keep rendering from history after both this
removal and the branch's eventual deletion. Verified: all five answer 200.

Signed-off-by: Artem Petrov <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
aixle-com Bot pushed a commit that referenced this pull request Nov 30, 2026
aixle-com Bot pushed a commit that referenced this pull request Nov 30, 2026
aixle-com Bot pushed a commit that referenced this pull request Nov 30, 2026
aixle-com Bot pushed a commit that referenced this pull request Nov 30, 2026
aixle-com Bot pushed a commit that referenced this pull request Nov 30, 2026
aixle-com Bot pushed a commit that referenced this pull request Dec 1, 2026
…ened through the tools (#292) (#940)

* feat(board): a Pull requests section with the pull requests agents opened through the tools (#292)

Signed-off-by: Alex <[email protected]>

* style: format the pull requests section

Signed-off-by: Aixle Flow <[email protected]>
Signed-off-by: Alex <[email protected]>

* test: read the section key indifferently (#292)

Signed-off-by: Alex <[email protected]>

* refactor(board): serialize a pull request link with ExternalResourceResource (#292)

Signed-off-by: Alex <[email protected]>

* fix(board): declare the id, url and key attributes without blocks (#292)

Signed-off-by: Alex <[email protected]>

* fix(board): read the listed pull requests as the association source (#292)

Signed-off-by: Alex <[email protected]>

* chore(types): regenerate the TypeScript types with typelizer (#292)

Signed-off-by: Alex <[email protected]>

---------

Signed-off-by: Alex <[email protected]>
Signed-off-by: Aixle Flow <[email protected]>
Co-authored-by: Alex <[email protected]>
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