generated from PartridgeRocks/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Summary
Add native GitHub App authentication support to complement the existing PAT and OAuth methods.
Motivation
GitHub Apps are the recommended authentication method for integrations. They provide:
- Higher rate limits (5,000 requests/hour per installation)
- Granular repository permissions
- Bot identity for commits/PRs (shows as
app-name[bot]) - No need to tie auth to a specific user account
Proposed Changes
1. Config additions (config/github-client.php)
'github_app' => [
'app_id' => env('GITHUB_APP_ID'),
'private_key' => env('GITHUB_APP_PRIVATE_KEY'),
'private_key_path' => env('GITHUB_APP_PRIVATE_KEY_PATH'),
'installation_id' => env('GITHUB_APP_INSTALLATION_ID'), // default installation
],2. Installation token resource
New InstallationsResource to:
- List app installations (
GET /app/installations) - Get installation token (
POST /app/installations/{id}/access_tokens) - Cache tokens for ~55 minutes (they expire in 1 hour)
3. Connector enhancement
Allow GithubConnector to accept a GitHubAppAuthentication strategy that:
- Auto-refreshes installation tokens before expiry
- Falls back gracefully if app auth fails
4. Git operations resource (stretch)
Add methods for creating commits/PRs as the app:
createBlob(),createTree(),createCommit(),updateRef()createBranch(),createPullRequest()
These are needed because commits made via the API (not git push) show the app as author.
Example Usage
use JordanPartridge\GithubClient\Facades\Github;
// Configure via .env, then:
$github = Github::forInstallation(98848199);
$github->repos()->get('the-shit/chat');
// Or with explicit config:
$github = Github::withApp(
appId: '2443785',
privateKey: file_get_contents('path/to/key.pem'),
installationId: 98848199
);Labels
enhancement, good first issue, agent