{"id":37133137,"url":"https://github.com/shammianand/go-auth","last_synced_at":"2026-01-14T15:32:48.166Z","repository":{"id":250587416,"uuid":"834627199","full_name":"ShammiAnand/go-auth","owner":"ShammiAnand","description":"drop-in auth service for your distributed backend written in go","archived":false,"fork":false,"pushed_at":"2025-10-19T17:40:40.000Z","size":303,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T23:54:24.387Z","etag":null,"topics":["authentication-backend","authorization","golang","jwt"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShammiAnand.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-27T21:16:53.000Z","updated_at":"2025-10-19T17:40:43.000Z","dependencies_parsed_at":"2025-10-19T17:26:32.273Z","dependency_job_id":"2b757079-c757-4262-8fae-1166d196e217","html_url":"https://github.com/ShammiAnand/go-auth","commit_stats":null,"previous_names":["shammianand/go-auth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ShammiAnand/go-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShammiAnand%2Fgo-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShammiAnand%2Fgo-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShammiAnand%2Fgo-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShammiAnand%2Fgo-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShammiAnand","download_url":"https://codeload.github.com/ShammiAnand/go-auth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShammiAnand%2Fgo-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28424374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["authentication-backend","authorization","golang","jwt"],"created_at":"2026-01-14T15:32:47.539Z","updated_at":"2026-01-14T15:32:48.159Z","avatar_url":"https://github.com/ShammiAnand.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go-Auth\n\n\u003e Lightweight authentication microservice with JWKS support for multi-backend architectures\n\n![Go Version](https://img.shields.io/badge/Go-1.24-blue.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)\n\n## Table of Contents\n\n1. [Overview](#overview)\n2. [Features](#features)\n3. [Quick Start](#quick-start)\n4. [Architecture](#architecture)\n5. [API Documentation](#api-documentation)\n6. [CLI Commands](#cli-commands)\n7. [Configuration](#configuration)\n8. [Development](#development)\n9. [Deployment](#deployment)\n10. [Documentation](#documentation)\n11. [License](#license)\n\n## Overview\n\nGo-Auth is a production-ready authentication microservice built with Go, designed to provide centralized authentication for microservice architectures. It implements JWT-based authentication with JWKS (JSON Web Key Set) for secure public key distribution, enabling multiple backend services to verify tokens without shared secrets.\n\n## Features\n\n- **JWT Authentication** - RS256 signed tokens with JWKS support\n- **User Management** - Signup, signin, email verification, password reset\n- **RBAC System** - Role-Based Access Control with flexible permissions\n- **Email Integration** - Mailhog for development, SES-ready for production\n- **CLI Interface** - Cobra-based CLI for all operations\n- **Health Checks** - `/health` and `/ready` endpoints\n- **Docker Support** - Multi-stage builds, docker-compose setup\n- **Audit Logging** - Track all RBAC changes\n- **Redis Caching** - Session management and JWKS caching\n- **PostgreSQL** - Robust data persistence with ent ORM\n\n## Quick Start\n\n### Prerequisites\n\n- Go 1.24+\n- Docker \u0026 Docker Compose\n- Make\n\n### 1. Clone and Setup\n\n```bash\ngit clone \u003crepository-url\u003e\ncd go-auth\ncp .env.sample .env\n```\n\n### 2. Start Dependencies\n\n```bash\nmake dev\n```\n\nThis starts PostgreSQL, Redis, and Mailhog.\n\n### 3. Initialize RBAC\n\n```bash\nmake init\n```\n\nThis creates default roles (super-admin, admin, user) and permissions.\n\n### 4. Create Super Admin\n\n```bash\nmake create-superuser\n```\n\n### 5. Start API Server\n\n```bash\nmake run\n```\n\nServer runs on `http://localhost:42069`\n\n### 6. Test the API\n\n```bash\n# Signup\ncurl -X POST http://localhost:42069/api/v1/auth/signup \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"email\": \"user@example.com\",\n    \"password\": \"SecurePass123!\",\n    \"first_name\": \"John\",\n    \"last_name\": \"Doe\"\n  }'\n\n# Signin\ncurl -X POST http://localhost:42069/api/v1/auth/signin \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"email\": \"user@example.com\",\n    \"password\": \"SecurePass123!\"\n  }'\n```\n\n## Architecture\n\n```\n┌─────────────┐     ┌──────────────┐     ┌──────────────┐\n│   Client    │────▶│   Go-Auth    │────▶│  PostgreSQL  │\n│ (micro-svc) │     │  (API Server)│     │   (Users/    │\n│             │◀────│              │◀────│    RBAC)     │\n└─────────────┘     └──────────────┘     └──────────────┘\n                           │\n                           ├──────────────┐\n                           │              │\n                    ┌──────▼─────┐ ┌─────▼─────┐\n                    │   Redis    │ │  Mailhog  │\n                    │  (Cache/   │ │  (Emails) │\n                    │  Sessions) │ │           │\n                    └────────────┘ └───────────┘\n```\n\n### Components\n\n- **Gin Framework** - High-performance HTTP router\n- **Ent ORM** - Type-safe database queries\n- **Cobra CLI** - Command-line interface\n- **Redis** - Session storage, JWKS caching, rate limiting\n- **PostgreSQL** - Primary data store\n- **Mailhog** - Email testing (development)\n\n## API Documentation\n\n### Authentication Endpoints\n\n| Method | Endpoint | Description | Auth Required |\n|--------|----------|-------------|---------------|\n| POST | `/api/v1/auth/signup` | Create new account | No |\n| POST | `/api/v1/auth/signin` | Authenticate user | No |\n| POST | `/api/v1/auth/logout` | Invalidate session | Yes |\n| GET | `/api/v1/auth/me` | Get user info | Yes |\n| PUT | `/api/v1/auth/me` | Update profile | Yes |\n| POST | `/api/v1/auth/forgot-password` | Request reset | No |\n| POST | `/api/v1/auth/reset-password` | Complete reset | No |\n| GET | `/api/v1/auth/verify-email` | Verify email | No |\n| POST | `/api/v1/auth/resend-verification` | Resend email | No |\n| GET | `/api/v1/.well-known/jwks.json` | Public keys | No |\n\n### Health Check Endpoints\n\n| Method | Endpoint | Description |\n|--------|----------|-------------|\n| GET | `/health` | Basic health check |\n| GET | `/ready` | Readiness check (DB connectivity) |\n\n## CLI Commands\n\n```bash\n# Server\ngo-auth server [--port PORT]             # Start HTTP server\n\n# RBAC Initialization\ngo-auth init [--config PATH]             # Bootstrap roles/permissions\n\n# Admin\ngo-auth admin create-superuser \\         # Create super-admin\n  --email EMAIL \\\n  --password PASSWORD \\\n  --first-name FIRST \\\n  --last-name LAST\n\n# Jobs\ngo-auth jobs jwks-refresh \\              # JWKS key rotation job\n  --interval DURATION\n```\n\n## Configuration\n\n### Environment Variables\n\nCreate `.env` file:\n\n```bash\n# Database\nDB_URL=localhost\nDB_PORT=5432\nDB_USER=admin\nDB_PASS=admin\nDB_NAME=auth\n\n# Redis\nREDIS_HOST=127.0.0.1\nREDIS_PORT=6379\n\n# JWT\nSECRET_KEY_ID=your-secret-id\nSECRET_PRIVATE_KEY=your-private-key\n\n# API\nAPI_PORT=42069\n```\n\n### RBAC Configuration\n\nEdit `configs/rbac-config.yaml` to customize roles and permissions:\n\n```yaml\npermissions:\n  - code: \"users.read\"\n    name: \"View Users\"\n    resource: \"users\"\n    action: \"read\"\n\nroles:\n  - code: \"admin\"\n    name: \"Administrator\"\n    is_system: true\n    permissions:\n      - \"users.*\"\n      - \"rbac.*\"\n```\n\n## Development\n\n### Makefile Commands\n\n```bash\nmake help              # Show all commands\nmake build             # Build binary\nmake run               # Build and run server\nmake init              # Initialize RBAC\nmake create-superuser  # Create admin user\nmake test              # Run tests\nmake gen-ent           # Generate Ent code\nmake clean             # Remove build artifacts\nmake dev               # Start dev environment\n```\n\n### Project Structure\n\n```\ngo-auth/\n├── cmd/              # CLI commands (Cobra)\n├── configs/          # Configuration files\n├── ent/              # Ent schema \u0026 generated code\n├── internal/\n│   ├── auth/         # JWT \u0026 password utilities\n│   ├── common/       # Shared types \u0026 middleware\n│   ├── config/       # Config loading\n│   ├── modules/      # Feature modules\n│   │   ├── auth/     # Authentication\n│   │   ├── email/    # Email service\n│   │   └── rbac/     # RBAC \u0026 bootstrap\n│   └── storage/      # DB connections\n├── Dockerfile\n├── docker-compose.yml\n├── Makefile\n└── README.md\n```\n\n## Documentation\n\nFor detailed information, see the following documentation:\n\n- **[Architecture Guide](docs/ARCHITECTURE.md)** - Complete system architecture, component breakdown, data flow diagrams, and security considerations\n- **[API Flow Examples](docs/API_FLOWS.md)** - Detailed API request/response examples for all major flows (signup, signin, RBAC, etc.)\n- **[Setup Guide](docs/SETUP.md)** - Prerequisites, installation steps, configuration, CLI usage, and troubleshooting\n\n### Quick Links\n\n- [Database Schema](docs/ARCHITECTURE.md#database-schema)\n- [Authentication Flow](docs/ARCHITECTURE.md#authentication-flow)\n- [RBAC Flow](docs/ARCHITECTURE.md#rbac-flow)\n- [API Endpoints Reference](docs/ARCHITECTURE.md#api-endpoints)\n- [Security Considerations](docs/ARCHITECTURE.md#security-considerations)\n- [Production Deployment](docs/SETUP.md#production-deployment)\n- [Troubleshooting](docs/SETUP.md#troubleshooting)\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshammianand%2Fgo-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshammianand%2Fgo-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshammianand%2Fgo-auth/lists"}