Narrow GitHub access to the project's repository: GitHub App instead of OAuth 'repo' scope

オープン
#110 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

  • #327 @satyagyasingh による — マージされずにクローズ

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
12/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
github, javascript

調査の方向性

Start with the OAuth scope in src/oauth/provider.js, then how the lent credential (keys.projectGhCred) is read in src/oauth/member-access.js and lend-decision.js. The design choices are still open, so settle them in the thread before coding. Done means a token for project A is refused on project B, uninstalling cuts access within one request, and docs/mcp-hosted-setup.md covers app setup.

索引モデルが issue の本文から書いたものです。

説明

bug enhancement priority: highest

Problem

The hosted connector signs people in through a GitHub OAuth App with scope repo read:user user:email (src/oauth/provider.js:32). GitHub OAuth Apps can't be limited to one repository: repo grants read and write on every repository the user can reach, public and private, personal and organisation.

That matters most for the credential a manager lends to the project (#50, stored as keys.projectGhCred in the deployment's KV). Google-signed-in members and agent tokens reach the project through it, so the deployment holds a long-lived token that can read and write all of that manager's repositories, not just the project's.

For a team running its own deployment this is its own infrastructure, but it's still far wider access than the product needs. It's the one place where teamctx's "data stays in storage the team controls" position depends on trusting a credential much broader than the project. A leak of the deployment's KV exposes every repository the lender can reach.

Proposed solution

Move GitHub access to a GitHub App installed on only the project's repository (or a chosen set):

  • Installation tokens are short-lived (1 hour), limited to the repositories where the app is installed, with fine-grained permissions (Contents: read/write, Metadata: read, and Members: read if needed for roster checks).
  • Lending becomes installing: the manager installs the app on the project repository. The deployment stores the installation ID, not a user token, and creates tokens on demand. Stopping lending means uninstalling the app on GitHub, which cuts access immediately.
  • Signing in people's identity uses GitHub App user-to-server tokens, which are also limited to the installation's repositories, or stays on OAuth for identity only (read:user user:email, no repo).
  • Keep the OAuth App path working during migration, and treat the repo scope as legacy with a deprecation note on the settings page.

Existing open source first

  • GitHub Apps are a GitHub platform feature, so there's nothing to build for the permission model itself.
  • @octokit/auth-app (MIT) handles app JWTs, installation tokens and caching. @octokit/app / octokit cover webhook and installation handling if needed. Use these instead of hand-writing JWT signing or token refresh.
  • What teamctx builds: the settings-page "install on this repository" step, and mapping a project to its installation ID in src/oauth/member-access.js / lend-decision.js (replacing projectGhCred).

Sub-questions for the plan

  • Self-hosters must register their own GitHub App. That's a setup cost like the OAuth App step in docs/mcp-hosted-setup.md, so document it the same way.
  • Manager checks (#86 handoff, step-out checks) currently reason about "the person lending". With an app installation, the lender is the repository, not a person, so decide how those checks apply.
  • Rate limits: installation tokens have their own limit per installation. Confirm this is equal or better for busy projects.

Acceptance

  • A lent project's stored credential can only reach that project's repository, and a test proves that a token created for project A is refused on project B.
  • Uninstalling the app cuts off Google members' and agents' access within one request.
  • docs/mcp-hosted-setup.md explains setting up the app.
主要言語
JavaScript
スター
1
フォーク
2
平均マージ
1日 19時間
マージ済み PR(30日)
62

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

StatsLateral/teamctx のほかの issue

StatsLateral/teamctx の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。