feat(auth): GitHub App auth, OIDC middleware, secret masking (Phase 5 — T5.1–T5.3) - #5
Open
canonical-muhammadbassiony wants to merge 2 commits into
Open
Conversation
added 2 commits
May 20, 2026 14:11
… masking T5.1: GetGitHubToken now tries GitHub App auth before PAT fallback T5.1: generateAppInstallationToken: RSA JWT signing + installation token exchange T5.1: GITHUB_APP_ID, GITHUB_APP_INSTALLATION_ID, GITHUB_APP_PRIVATE_KEY(_PATH) env vars T5.2: internal/auth/middleware.go JWTMiddleware wraps protected routes T5.2: bypassed when BAUER_OIDC_ISSUER unset; fetches JWKS via OIDC discovery T5.2: GET /api/v1/health and /health/ready excluded from auth T5.3: internal/logging/masking.go MaskSecret + MaskPath helpers T5.3: unit tests for both helpers T5.3: slog audit complete; sensitive fields now masked in log output
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.
Summary
Implements authentication and security hardening for the API, completing Phase 5 of spec 001.
Tasks Implemented
GetGitHubToken(). WhenGITHUB_APP_IDis set, signs a short-lived RS256 JWT with the App private key and exchanges it for an installation access token. PAT env vars andgh auth tokenremain as lower-priority fallbacks. Supports PEM from file (GITHUB_APP_PRIVATE_KEY_PATH) or env var (GITHUB_APP_PRIVATE_KEYwith literal\nhandling).internal/auth/middleware.gowithJWTMiddleware— validates Bearer tokens against JWKS fetched from the OIDC issuer discovery document. Bypassed whenBAUER_OIDC_ISSUERis unset (safe for local dev). Protected endpoints (workflows, issues, jira webhook) wrapped with middleware on a separate sub-mux. Health/readiness probes remain on public mux.internal/logging/masking.gowithMaskSecretandMaskPathhelpers. Full table-driven unit tests (9 cases). Audit of existingslogcalls confirmed no raw token/credential logging.Security Notes
Files Changed
internal/github/auth.go— GitHub App token generationinternal/auth/middleware.go— OIDC JWT validation middlewareinternal/logging/masking.go—MaskSecret,MaskPathinternal/logging/masking_test.go— unit testscmd/app/main.go— public vs protected mux splitgo.mod/go.sum—golang-jwt/jwt/v5,lestrrat-go/jwx/v2How to Review
git diff feat/phase-4-api-endpoints..feat/phase-5-auth-security -- .Part of the Bauer v2 stacked PR series (Branch 11 of 12).