{"id":34569070,"url":"https://github.com/notrab/go-traefik","last_synced_at":"2026-05-28T02:31:50.263Z","repository":{"id":297503445,"uuid":"994928539","full_name":"notrab/go-traefik","owner":"notrab","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-02T17:54:37.000Z","size":6,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-24T03:35:50.124Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/notrab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-02T17:45:16.000Z","updated_at":"2025-06-05T02:06:04.000Z","dependencies_parsed_at":"2025-06-05T21:01:33.856Z","dependency_job_id":null,"html_url":"https://github.com/notrab/go-traefik","commit_stats":null,"previous_names":["notrab/go-traefik"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/notrab/go-traefik","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notrab%2Fgo-traefik","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notrab%2Fgo-traefik/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notrab%2Fgo-traefik/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notrab%2Fgo-traefik/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/notrab","download_url":"https://codeload.github.com/notrab/go-traefik/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notrab%2Fgo-traefik/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33592074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-24T09:14:14.425Z","updated_at":"2026-05-28T02:31:50.243Z","avatar_url":"https://github.com/notrab.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Traefik Test with ForwardAuth\n\nA demonstration of Traefik v3 with ForwardAuth middleware using Go services and Redis.\n\n## Architecture\n\n- **Traefik**: Reverse proxy with ForwardAuth middleware\n- **Auth Service**: Handles API key validation and management (Go with standard library HTTP router)\n- **API Service**: Protected and public endpoints (Go with standard library HTTP router)\n- **Redis**: API key storage\n\n## Quick Start\n\n### Prerequisites\n\n- Docker and Docker Compose\n- curl (for testing)\n\n### 1. Start the Services\n\n```bash\ndocker compose up -d\n```\n\nThis will start:\n- Traefik on port 80 (main) and 8080 (dashboard)\n- Redis on port 6379\n- Auth service (internal)\n- API service (internal)\n\n### 2. Verify Services are Running\n\n```bash\ndocker compose ps\n```\n\n### 3. Check Health\n\n```bash\ncurl http://localhost/auth/health\n```\n\nExpected response: `Auth service healthy`\n\n## API Key Management\n\n### Create an API Key\n\n```bash\ncurl -X POST http://localhost/auth/create-key \\\n  -d \"user_id=john_doe\u0026api_key=secret123\"\n```\n\nExpected response: `API key created for user: john_doe`\n\n### Test API Access\n\nWithout authentication (should fail):\n```bash\ncurl http://localhost/api\n```\n\nExpected response: `Missing Authorization header`\n\nWith valid API key:\n```bash\ncurl -H \"Authorization: Bearer secret123\" http://localhost/api/protected\n```\n\nThe request will be forwarded to the API service with user headers.\n\nTest public endpoints (no auth required):\n```bash\ncurl http://localhost/api/health\ncurl http://localhost/api/public\n```\n\n## Endpoints\n\n### Auth Service (`/auth`)\n\n- `GET /auth/health` - Health check\n- `POST /auth/create-key` - Create API key (requires `user_id` and `api_key` form data)\n- `GET/POST /auth` - Internal ForwardAuth endpoint (used by Traefik)\n\n### API Service (`/api`)\n\n#### Protected Endpoints (require authentication):\n- `GET /api/protected` - Protected endpoint with user info\n- `GET /api/data` - Protected data endpoint\n- Requires `Authorization: Bearer \u003capi-key\u003e` header\n\n#### Public Endpoints (no authentication required):\n- `GET /api/health` - Health check\n- `GET /api/public` - Public endpoint\n\n## Development\n\n### Technology Stack\n\n- **Go Services**: Built with Go 1.24+ using the standard library HTTP router (zero external dependencies for routing)\n- **Redis**: For API key storage\n- **Docker**: Containerized deployment\n- **Traefik**: Advanced routing with separate routers for protected vs public endpoints\n\n### Rebuild Services\n\nAfter making code changes:\n\n```bash\n# Rebuild specific service\ndocker compose build auth-service\ndocker compose up -d auth-service\n\n# Or rebuild all services\ndocker compose build\ndocker compose up -d\n```\n\n### View Logs\n\n```bash\n# All services\ndocker compose logs -f\n\n# Specific service\ndocker compose logs -f traefik\ndocker compose logs -f auth-service\n```\n\n### Traefik Dashboard\n\nVisit http://localhost:8080 to see the Traefik dashboard with routing information.\n\n## Cleanup\n\n```bash\ndocker compose down\n```\n\nTo remove volumes as well:\n```bash\ndocker compose down -v\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotrab%2Fgo-traefik","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotrab%2Fgo-traefik","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotrab%2Fgo-traefik/lists"}