Skip to content

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
feat/phase-4-api-endpointsfrom
feat/phase-5-auth-security
Open

feat(auth): GitHub App auth, OIDC middleware, secret masking (Phase 5 — T5.1–T5.3)#5
canonical-muhammadbassiony wants to merge 2 commits into
feat/phase-4-api-endpointsfrom
feat/phase-5-auth-security

Conversation

@canonical-muhammadbassiony

Copy link
Copy Markdown
Owner

Summary

Implements authentication and security hardening for the API, completing Phase 5 of spec 001.

Tasks Implemented

  • T5.1: GitHub App authentication as first fallback in GetGitHubToken(). When GITHUB_APP_ID is set, signs a short-lived RS256 JWT with the App private key and exchanges it for an installation access token. PAT env vars and gh auth token remain as lower-priority fallbacks. Supports PEM from file (GITHUB_APP_PRIVATE_KEY_PATH) or env var (GITHUB_APP_PRIVATE_KEY with literal \n handling).
  • T5.2: internal/auth/middleware.go with JWTMiddleware — validates Bearer tokens against JWKS fetched from the OIDC issuer discovery document. Bypassed when BAUER_OIDC_ISSUER is 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.
  • T5.3: internal/logging/masking.go with MaskSecret and MaskPath helpers. Full table-driven unit tests (9 cases). Audit of existing slog calls confirmed no raw token/credential logging.

Security Notes

  • RS256 JWT signing for GitHub App tokens
  • OIDC middleware validates issuer, audience, signature, and expiry
  • Fail-closed when OIDC is configured but JWKS fetch fails (returns 503)
  • Masking helpers handle edge cases (empty, short ≤4 chars, longer strings)

Files Changed

  • internal/github/auth.go — GitHub App token generation
  • internal/auth/middleware.go — OIDC JWT validation middleware
  • internal/logging/masking.goMaskSecret, MaskPath
  • internal/logging/masking_test.go — unit tests
  • cmd/app/main.go — public vs protected mux split
  • go.mod / go.sumgolang-jwt/jwt/v5, lestrrat-go/jwx/v2

How 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).

Bauer Agent 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant