Why request access to private repos?
I'm concerned about requesting access to private repos. They are set as private for a reason. Mind explaining why that choice?
Now I have a comprehensive understanding. Let me explain:
##Why the repo Scope is Requested
Looking at the code in apps/web/lib/auth.ts (line 70-71):
// repo scope needed for build mode (push, PRs)
scope: ["read:user", "user:email", "repo"],
The repo scope is requested for these specific reasons:
###1. Build Mode Features (Primary Reason)
The comment explicitly states: "repo scope needed for build mode (push, PRs)". This refers to features that allow the AI agent to:
- Push code to repositories
- Create pull requests
These features require write access to your repos, which the repo scope provides.
###2. Moderation Permissions
Looking at apps/web/lib/data/permissions.ts, the app checks if users have push, admin, or triage permissions on a repository to determine if they can moderate posts:
export async function canModerate(userId, owner, repo): Promise<boolean> {
const permissions = await getUserRepoPermissions(owner, repo, accessToken)
return (
permissions?.push === true ||
permissions?.admin === true ||
permissions?.triage === true
)
}
###3. Private Repository Support (Planned)
Looking at private-posts-plan.md, there's a planned feature to support private repositories. This would allow:
- Users with access to a private repo to create and view posts about it
- Posts with "repo" visibility that only repo members can see
##Your Concern is Valid
You're right to be cautious. The repo scope is quite broad—it grants:
- Read/write access to public and private repositories
- Access to code, issues, pull requests, etc.
###What the App Actually Uses It For:
- Verifying your permissions on a repository (read-only check via GitHub API)
- Build mode where the AI can push code/create PRs (when you explicitly use this feature)
###What It Does NOT Do:
- The app doesn't appear to automatically access or index your private repos
- It only accesses repos when you explicitly interact with them
##Potential Improvement
A more minimal approach would be to:
- Start with
read:user+user:email+public_repo(for public repos only) - Request the full
reposcope only when the user wants to use build mode on a private repo
This would be a progressive permission model. If you feel strongly about this, it might be worth opening an issue to suggest this change!
makes sense. can the repo scope be requested for specific repos?
This confirms my suspicion. Let me summarize the findings:
##Short Answer: No, GitHub OAuth scopes cannot be limited to specific repositories.
This is a well-known limitation of GitHub's OAuth system. Here's what the research shows:
###The Problem with repo Scope
From GitHub's OAuth documentation:
repo- Grants full access to public and private repositories including read and write access to code, commit statuses, repository invitations, collaborators, deployment statuses, and repository webhooks.
Once you grant repo scope, it applies to all repositories you have access to—not just one.
###Alternatives That Exist
-
Fine-Grained Personal Access Tokens (PATs) - These can be scoped to specific repositories, but:
- They're for personal use, not OAuth apps
- Users create them manually in GitHub settings
- Can't be used in the OAuth flow that Forums uses
-
GitHub Apps (not OAuth Apps) - These allow per-repository installation:
- Users can choose "Only select repositories" during installation
- More granular permissions model
- Would require Forums to be rebuilt as a GitHub App instead of an OAuth App
-
Deploy Keys - Limited to a single repo, but:
- SSH-based, not OAuth
- Not suitable for user authentication flows
###What This Means for Forums
For Forums to support per-repo permissions, it would need to migrate from an OAuth App to a GitHub App. That's a significant architectural change, but it would allow users to grant access to only the specific repositories they want.
This is a common pain point—there are many GitHub community discussions requesting this feature for OAuth Apps, but GitHub hasn't added it.
END OF POST