A high-performance authentication and authorization service built with Go, Fiber v3, and designed for microservices architecture.
- β User registration with email verification
- β JWT-based authentication (access + refresh tokens)
- β Password reset with secure tokens
- β OAuth2 support (Google, GitHub, Microsoft)
- π Two-factor authentication (TOTP) [Planned]
- β Session management with Redis
- β Secure password hashing (Argon2)
- β Role-based access control (RBAC)
- β Fine-grained permissions system
- β API key management
- β Permission caching with Redis
- β Tenant isolation support
- β Advanced password validation
- β Rate limiting (IP & user-based)
- β Brute force protection
- β Comprehensive audit logging
- β Token revocation
- β CORS protection
- β Security headers
- β Prometheus metrics
- β Structured logging (Zap)
- β Graceful shutdown
- β Health checks
- β Docker support
- β Kubernetes manifests
- β Local development with Minikube
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β API Gateway ββββββ Auth Service ββββββ PostgreSQL β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βββββββββββββββββββ
β Redis β
β (Sessions) β
βββββββββββββββββββ
- Language: Go 1.22
- Web Framework: Fiber v3
- Database: PostgreSQL with GORM
- Cache/Sessions: Redis
- Authentication: JWT (golang-jwt/jwt)
- Password Hashing: Argon2
- Validation: go-playground/validator
- Logging: Zap
- Metrics: Prometheus
- Testing: Testify
- Deployment: Docker + Kubernetes
- Go 1.22+
- Docker & Docker Compose
- Minikube (for K8s development)
- PostgreSQL 15+
- Redis 7+
# Clone the repository (if not already done)
git clone <repository-url>
cd pyairtable-auth-service-go
# Run the setup script
./scripts/local-setup.sh
# Start development environment
make dev-start
# Start all services
docker-compose up -d
# Check logs
docker-compose logs -f auth-service
# Stop services
docker-compose down
# Setup and deploy to Minikube
make local-full
# Or step by step:
make minikube-setup
make minikube-deploy
make minikube-port-forward
Copy .env.example
to .env
and update the values:
cp .env.example .env
Key configurations:
JWT_SECRET
: Strong secret for JWT signing- OAuth credentials for social login
- Database and Redis connection strings
# Development
make build # Build the application
make test # Run tests
make run # Run locally
make dev-start # Start full dev environment
# Docker
make docker-build # Build Docker image
make docker-run # Run in Docker
# Kubernetes
make k8s-deploy # Deploy to K8s
make k8s-logs # View logs
make k8s-status # Check status
# Quality
make lint # Run linter
make test-coverage # Test with coverage
make security # Security scan
# See all commands
make help
# Run all tests
make test
# Run with coverage
make test-coverage
# Run benchmarks
make benchmark
# Run with race detection
make test-race
POST /api/v1/auth/register
- User registrationPOST /api/v1/auth/login
- User loginPOST /api/v1/auth/logout
- User logoutPOST /api/v1/auth/refresh
- Refresh access tokenPOST /api/v1/auth/verify-email
- Verify email addressPOST /api/v1/auth/forgot-password
- Request password resetPOST /api/v1/auth/reset-password
- Reset password
POST /api/v1/auth/2fa/setup
- Setup 2FAPOST /api/v1/auth/2fa/verify
- Verify 2FA codePOST /api/v1/auth/2fa/disable
- Disable 2FA
GET /api/v1/oauth/google
- Google OAuth loginGET /api/v1/oauth/google/callback
- Google OAuth callbackGET /api/v1/oauth/github
- GitHub OAuth loginGET /api/v1/oauth/github/callback
- GitHub OAuth callbackGET /api/v1/oauth/microsoft
- Microsoft OAuth loginGET /api/v1/oauth/microsoft/callback
- Microsoft OAuth callback
GET /api/v1/auth/me
- Get current userGET /api/v1/auth/permissions
- Get user permissions
GET /api/v1/admin/users
- List usersGET /api/v1/admin/users/:id
- Get user by IDPUT /api/v1/admin/users/:id/roles
- Update user rolesDELETE /api/v1/admin/users/:id
- Delete userGET /api/v1/admin/audit-logs
- Get audit logs
GET /health
- Health checkGET /metrics
- Prometheus metrics
- Argon2 hashing with configurable parameters
- Strength requirements (length, character types)
- Common password detection
- Password history (planned)
- Failed login attempt tracking
- Progressive delays
- Account lockout after threshold
- IP-based rate limiting
- JWT with short expiration (15 minutes default)
- Refresh token rotation
- Token revocation support
- Secure token storage
- All authentication events
- Admin actions
- Failed access attempts
- IP and user agent tracking
This service integrates with the broader PyAirtable infrastructure:
- Works with API Gateway for routing
- Registers with service mesh (Istio)
- Exposes health checks for load balancers
- Uses
pyairtable-go-shared
library - Common models and utilities
- Shared middleware and configurations
- PostgreSQL with connection pooling
- Automatic migrations
- Read replicas support (planned)
- Redis for session storage
- Permission caching
- Rate limit storage
- Request/response metrics
- Authentication success/failure rates
- JWT token generation/validation
- Database query performance
- Structured JSON logging
- Request tracing with correlation IDs
- Error logging with stack traces
- Audit trail for security events
- Database connectivity
- Redis connectivity
- Service readiness
- External service dependencies
# Build image
docker build -t pyairtable/auth-service:latest .
# Run container
docker run -p 8080:8080 --env-file .env pyairtable/auth-service:latest
# Deploy to namespace
kubectl apply -k deployments/k8s/
# Check status
kubectl get pods -n pyairtable-auth
- Local: Minikube with single replica
- Development: Multi-replica with debug logging
- Staging: Production-like with monitoring
- Production: High availability with security hardening
- Repository layer tests
- Service layer tests
- Handler tests with mocked dependencies
- Utility function tests
- Database integration
- Redis integration
- HTTP endpoint tests
- OAuth flow tests
- Authentication throughput
- Concurrent user sessions
- Rate limiting effectiveness
- Database connection pooling
fiber/v3
- Web frameworkgorm
- ORM for PostgreSQLredis/go-redis/v9
- Redis clientgolang-jwt/jwt/v5
- JWT implementationgolang.org/x/crypto
- Cryptographic functions
testify
- Testing frameworkgolangci-lint
- Code lintingswaggo/swag
- API documentationprometheus/client_golang
- Metrics
- Follow Go best practices and project conventions
- Write comprehensive tests for new features
- Update API documentation for endpoint changes
- Ensure security best practices are followed
- Add monitoring and logging for new features
This project is part of the PyAirtable ecosystem. See LICENSE file for details.
For support and questions:
- Create an issue in the repository
- Check existing documentation
- Review the API documentation at
/swagger/
Built with β€οΈ for high-performance authentication at scale