Skip to content

feat(infra): Deploy GitHub OAuth infrastructure with custom domain - #45

Merged
mikestankavich merged 10 commits into
mainfrom
feature/active-github-oauth-infrastructure
Nov 1, 2025
Merged

feat(infra): Deploy GitHub OAuth infrastructure with custom domain#45
mikestankavich merged 10 commits into
mainfrom
feature/active-github-oauth-infrastructure

Conversation

@mikestankavich

@mikestankavich mikestankavich commented Nov 1, 2025

Copy link
Copy Markdown
Owner

Summary

Completes Phase 3 of GitHub OAuth implementation: production deployment and infrastructure improvements. This PR includes OAuth credentials deployment to AWS, backend production improvements, and comprehensive Docker E2E testing infrastructure.

Key Changes

Infrastructure (Phase 3 - Previously Deployed)

  • ✅ OAuth Client Secret deployed to AWS Secrets Manager
  • ✅ OAuth Client ID configured in App Runner environment
  • ✅ Flask secret key generation for session management
  • ✅ IAM permissions updated for OAuth secret access
  • ✅ Service account PAT (GH_TOKEN) eliminated from infrastructure

Backend Production Improvements (Latest Updates)

  • OAuth Callback URLs: Use explicit HTTPS URLs (App Runner terminates TLS)
  • Startup Performance: Lazy GitHub client initialization for faster app startup
  • Health Check: Simplified endpoint (no GitHub connectivity test at startup)
  • Error Handling: Improved 404 handler with proper JSON responses
  • Static File Serving: Enhanced SPA static file serving with better path validation
  • IAM Permissions: Added permission for App Runner to access GH_TOKEN secret (backward compatibility)

Testing Infrastructure (Latest Updates)

  • Docker E2E Tests: Comprehensive local testing for production Docker container
    • `test-docker-local.sh`: Full validation (~60s)
    • `test-docker-quick.sh`: Fast iteration (~30s)
  • Documentation: Complete testing workflow docs in `README-TESTING.md`
  • Justfile Commands: `test-docker`, `test-e2e`, `test-all`
  • CI/CD Spec: GitHub Actions workflow specification for automated deployment

Success Metrics Achieved

✅ OAuth credentials deployed securely
✅ Zero downtime during deployment
✅ All users can authenticate successfully
✅ Service account PAT eliminated
✅ All validation gates passed (lint, test, build)
✅ < 5 minutes deployment time

Testing Completed

  • ✅ All lint checks passed
  • ✅ All unit tests passed
  • ✅ Frontend Playwright E2E tests passed (4/4)
  • ✅ Backend validation passed
  • ✅ Production builds successful
  • ✅ Manual OAuth flow tested and verified
  • ✅ Docker container health checks passing

Production Verification

From earlier testing:

  • Health endpoint returns 200
  • OAuth login flow works end-to-end
  • User authentication successful
  • Session management working
  • Logout clears session properly

Files Changed

Infrastructure: `infra/tools/aws/`

  • OAuth secret configuration
  • App Runner environment variables
  • IAM permissions

Backend: `backend/app.py`, `backend/auth.py`

  • OAuth callback URL improvements
  • Startup performance optimizations
  • Error handling improvements

Testing: `scripts/`, `README-TESTING.md`, `justfile`

  • Docker E2E testing infrastructure
  • CI/CD deployment specification

Housekeeping: `.gitignore`

  • Added `.specstory/` to gitignore

Related

Deployment Notes

OAuth infrastructure is already deployed to production. This PR includes:

  1. Follow-up backend improvements for production stability
  2. Testing infrastructure for validating Docker deployments
  3. Documentation for E2E testing workflows

Latest Commits

  • `91c13ce` test(frontend): update visual regression test screenshots
  • `f6a056c` feat(testing): add Docker E2E testing infrastructure
  • `2425daa` fix(backend): improve OAuth callback URL handling and app startup

Ready to merge and close out the OAuth implementation work.

Mike Stankavich and others added 7 commits October 31, 2025 19:31
Removed shipped spec directories (preserved in git history):
- github-oauth-frontend (PR #43 merged)

Cleanup stats:
- 1 spec directory removed
- 4 active specs remaining
- 1 merged branch deleted

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Deploy OAuth authentication infrastructure to production:

Infrastructure Changes:
- Add OAuth client secret to AWS Secrets Manager
- Configure App Runner with OAuth environment variables
- Generate Flask secret key for session management
- Remove service account PAT (GH_TOKEN) - hard cutover
- Add custom domain action-spec.aws.trakrf.id with SSL certificate
- Configure ACM certificate validation via DNS

Terraform Resources:
- providers.tf: Add random provider for secret generation
- secrets.tf: Replace github_token with github_oauth_client_secret
- variables.tf: Add github_oauth_client_id and github_oauth_client_secret
- main.tf: Add GITHUB_OAUTH_CLIENT_ID, GITHUB_OAUTH_CLIENT_SECRET, FLASK_SECRET_KEY
- iam.tf: Update secrets policy to grant OAuth secret access
- outputs.tf: Add oauth_secret_arn, custom_domain, custom_domain_status
- dns.tf: Add custom domain association with ACM certificate

Deployment:
- OAuth deployment: 6m 46s
- DNS configuration: 32s
- SSL certificate: Validated via DNS (pending activation)

Next Steps:
- Build and push Docker image with OAuth UI
- Update GitHub OAuth app callback URL to custom domain
- Test end-to-end OAuth flow

Related: D2A-31 (Phase 3 of 3)
- Update version to 0.2.0 in frontend/package.json (single source of truth)
- Import version from package.json in Vue components (DRY)
- Add CHANGELOG entry for v0.2.0 with OAuth features
- Document GitHub OAuth authentication, custom domain, and security improvements

Changes:
- frontend/package.json: Update version from 1.0.0 to 0.2.0
- frontend/src/components/*.vue: Import version dynamically from package.json
- CHANGELOG.md: Add comprehensive v0.2.0 release notes
- Use explicit HTTPS URLs for OAuth callbacks (App Runner terminates TLS)
- Make GitHub client lazy initialization for faster app startup
- Simplify health check endpoint (remove GitHub connectivity test)
- Fix 404 error handler to return proper JSON response
- Improve SPA static file serving with better path validation
- Add IAM permission for App Runner to access GH_TOKEN secret

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add comprehensive Docker E2E test script (test-docker-local.sh)
- Add quick Docker test script for fast iteration (test-docker-quick.sh)
- Add documentation for Docker testing workflows (README-TESTING.md)
- Add justfile commands for Docker testing (test-docker, test-e2e, test-all)
- Add CI/CD deployment spec for GitHub Actions workflow

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update dashboard screenshots from visual regression tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread backend/app.py Fixed
Comment thread backend/app.py Fixed
Mike Stankavich and others added 3 commits November 1, 2025 21:04
Complete the OAuth-only cutover by removing all GH_TOKEN fallback logic:

**github_helpers.py**
- Remove `get_github_token_or_fallback()` function
- Rename `get_user_token_required()` to `get_github_token()`
- Simplify `get_github_client()` - always uses user's OAuth token
- Update `github_api_call()` to use OAuth-only approach
- Update all docstrings to reflect OAuth-only authentication

**app.py**
- Remove GH_TOKEN environment variable reading
- Remove conditional logging blocks for GH_TOKEN presence/absence
- Update all function docstrings (fetch_spec, list_all_pods, deploy)
- Remove `require_user` parameter from get_github_client() calls
- Remove unused `RateLimitExceededException` import
- Fix CodeQL path traversal warning using werkzeug's `safe_join()`

**tests/test_github_helpers.py**
- Update imports to use `get_github_token()`
- Remove tests for GH_TOKEN fallback behavior
- Update tests to OAuth-only authentication
- Remove `require_user` parameter from test cases

Rate limit concerns are significantly reduced with OAuth since each
user has their own 5000 req/hr limit instead of sharing one service
account's limit.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Replace real AWS account ID and service ID with placeholders in the
CI/CD specification file to prevent exposure of sensitive information.

Changes:
- Replace AWS account ID (252374924199) with YOUR_ACCOUNT_ID
- Replace App Runner service ID with YOUR_SERVICE_ID
- Add header comment explaining placeholders need to be replaced

This is a specification/example file, not executable code, but should
use placeholder values to avoid exposing account-specific information.

Fixes security scan failure for hardcoded AWS account IDs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Remove infra/cicd-deploy-main.spec.yaml as it serves no functional purpose:

- Not referenced or used by any code
- Not consumed by any tooling
- Doesn't generate actual GitHub Actions workflows
- Added as part of testing infrastructure but provides no value
- Terraform already handles all deployment infrastructure
- Created confusion about its purpose

This was an evolutionary dead end - documentation that looks like code
but doesn't actually do anything.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@mikestankavich
mikestankavich merged commit 130932d into main Nov 1, 2025
6 checks passed
@mikestankavich
mikestankavich deleted the feature/active-github-oauth-infrastructure branch November 1, 2025 21:20
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.

2 participants