Repository navigation
[GH-P2] JWT d'app + cache des tokens d'installation, résolveur par projet, flag DEVFORGE_GITHUB_APP - #233
Merged
Conversation
…auth resolver, DEVFORGE_GITHUB_APP flag
bobdivx
force-pushed
the
feat/gh-app-p2-tokens
branch
from
October 14, 2026 00:58
b421679 to
1f7eeba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[GH-P2] JWT d'app & tokens d'installation en cache, résolveur par projet
Plan :
devforge-plan-github-app.md, phase P2. S'appuie sur P0 (#229) et P1 (#231).Checklist
crates/github/src/app_auth.rs:AppCredentials { app_id, private_key }etapp_jwt()(RS256,iat = now−60,exp = now+540,iss = app_id). Le helper JWT de P1 a été retiré degithub_app_routes.rs; il y a maintenantload_credentials()(clé descellée en mémoire uniquement).SecretString(Debug/Display =***).InstallationTokenCachedansAppState.gh_tokens.POST /app/installations/{id}/access_tokens.scoped():repository_ids+permissionsrestreints, jamais mis en cache (tokens des runners).apps/server/src/github_auth.rs:enum GithubAuth { Pat, Installation { id, repo_id } }etfor_project().projects.github_installation_idest non nul et le mode App est actif, sinon PAT (inchangé).DEVFORGE_GITHUB_APP=1ou présence d'une lignegithub_app.draft_routes::remote_url,correction::remote, les runs d'agents liés à un projet (routes.rs, 2 sites), les routines (rich_chat.rs). Pour ces runs, les outils agent (publish_to_github,create_github_fix,sync_workdir_to_github,read_github_file,github_list_prs,github_workflow_runs) passent parwith_tokenet reçoivent donc le token d'installation.routes.rs) et dev (dev_env.rs).contents:read,metadata:read, TTL GitHub ≤ 1 h).DeployRequest.github_token_ephemeral. Dans ce mode, git s'authentifie par en-tête (GIT_CONFIG_*→http.https://github.com/.extraheader) et le remote est réécrit sans token (remote set-url). Rien n'est persisté dans.git/config, rien ne passe dans l'URL ni dans les logs.redact_tokens()masquex-access-token:…etghs_/ghp_/github_pat_…dans un texte de log.suspended⇒github_installations.suspended_at, puis repli sur le PAT. Différé : l'invalidation + nouvel essai sur un 401 d'un appel API utilisant le token (il faudrait instrumenterHttpGitHubClient). Le risque est faible : un token mis en cache est toujours renouvelé avant les 5 dernières minutes.Tests
app_auth_tests.rs(wiremock, clé RSA générée à la volée par openssl, jamais committée) :iss,exp − iat ≤ 600.Suspended.repository_ids/permissions;scopednon mis en cache.x-access-token:ghs_xxx⇒x-access-token:***.github_auth:Installation, sans installation ⇒Pat, flag absent ⇒Patmême si le projet est lié.github_app) et parsing du flag.deploy: la commande git en mode en-tête ne contient ni le token nix-access-token:et nettoie le remote ; l'URL PAT est inchangée.cargo test --workspace⇒ 617 passés, 0 échec.Validation (manuelle, après merge + P1 validée en prod)
PAT supprimé des réglages + projet lié à l'installation (
github_installation_id/github_repo_id; le lien vient en P6/P7, ou à la main en SQL pour le test) ⇒ le déploiement clone et build sur un runner self-hosted. Pas encore faite.Risques
GIT_CONFIG_COUNT) sur l'hôte de build ; le mode PAT n'est pas concerné. Sous Windows, le chemin historique est conservé.DeployRequestdériveDebuget contientgithub_token. Ce n'est pas journalisé aujourd'hui, mais c'est à masquer au durcissement (P7).