Built for scalability, security, and seamless integration with modern Go backends
Secure access and refresh token flow with configurable expiration times
TOTP-based 2FA with QR code generation for enhanced security
Ready-to-use social logins with popular providers
Secure admin functionality for support and debugging
Optimized Go implementation with Redis caching
Enterprise security with HashiCorp Vault integration
Comprehensive metrics and logging for observability
Docker-ready with Kubernetes manifests included
Leveraging the best tools and libraries for backend development
Built following Go best practices with clean architecture principles for maintainability and testability
graph TD %% Styling definitions classDef external fill:#e1f5fe,stroke:#0277bd,stroke-width:2px,color:#000 classDef handler fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px,color:#000 classDef service fill:#e8f5e8,stroke:#388e3c,stroke-width:2px,color:#000 classDef repository fill:#fff3e0,stroke:#f57c00,stroke-width:2px,color:#000 classDef client fill:#fce4ec,stroke:#c2185b,stroke-width:2px,color:#000 classDef database fill:#f1f8e9,stroke:#689f38,stroke-width:2px,color:#000 classDef cache fill:#ffebee,stroke:#d32f2f,stroke-width:2px,color:#000 classDef vault fill:#f9fbe7,stroke:#827717,stroke-width:2px,color:#000 classDef main fill:#e3f2fd,stroke:#1976d2,stroke-width:3px,color:#000 classDef microservice fill:#f8bbd9,stroke:#e91e63,stroke-width:2px,color:#000 %% External Layer subgraph EXT ["🌐 External World"] direction TB Frontend["📱 Frontend/Mobile App
• Login/logout interface
• Token management
• Session handling"] OtherServices["🔗 Other Microservices
• Service-to-service auth
• Token validation
• User impersonation"] end %% Main Application Entry Point subgraph MAIN ["🔐 prism-auth-service"] direction TB MainGo["📋 main.go
• Server initialization
• Configuration loading
• Dependency injection
• Graceful shutdown"] %% Handler Layer subgraph HANDLER ["🎯 Handler Layer"] direction LR HTTPHandlers["🌐 HTTP Handlers
internal/handler
• REST endpoints
• Login/logout/refresh
• Request validation
• Response formatting"] GRPCServer["⚡ gRPC Server
internal/grpc_server
• Service authentication
• Token validation
• User verification
• Interceptors"] end %% Service Layer subgraph SERVICE ["🧠 Service Layer (Business Logic)"] direction TB AuthService["🔑 Auth Service
internal/service
• JWT token generation
• Password validation
• Session management
• Authentication logic
• Token refresh
• User authorization"] end %% Repository Layer subgraph REPO ["💾 Repository Layer (Data Access)"] direction TB Repositories["📊 Repositories
internal/repository
• User credential storage
• Session persistence
• Token blacklisting
• Audit logging
• Database transactions"] end %% Client Layer subgraph CLIENT ["🔌 Client Layer (External Communication)"] direction TB ServiceClients["📡 Service Clients
internal/client
• HTTP client wrapper
• gRPC client connections
• Circuit breaker pattern
• Retry mechanisms
• Request/response logging"] end end %% Dependencies & External Services subgraph DEPS ["🔧 Dependencies"] direction TB PostgresDB["🐘 PostgreSQL DB
• User credentials
• Session storage
• Audit trails
• ACID compliance"] RedisCache["🔴 Redis Cache
• Session storage
• Token blacklist
• Rate limiting
• Temporary data"] UserServiceExt["👤 prism-user-service
• User profile data
• User validation
• Account management"] NotificationServiceExt["📢 prism-notification-service
• Login notifications
• Security alerts
• Authentication events"] VaultService["🔐 HashiCorp Vault
• JWT signing keys
• Database credentials
• API secrets
• Encryption keys"] end %% Connections with labels Frontend -- "🌐 REST API
Login/Logout
Token Management" --> HTTPHandlers OtherServices -- "⚡ gRPC Calls
Token Validation
User Authentication" --> GRPCServer MainGo --> HTTPHandlers MainGo --> GRPCServer MainGo -- "🔑 Load Secrets
JWT Keys
DB Credentials" --> VaultService HTTPHandlers --> AuthService GRPCServer --> AuthService AuthService --> Repositories AuthService --> ServiceClients Repositories --> PostgresDB Repositories --> RedisCache ServiceClients -- "👤 HTTP/gRPC Out
User Validation
Profile Data" --> UserServiceExt ServiceClients -- "📢 HTTP/gRPC Out
Security Notifications
Login Alerts" --> NotificationServiceExt %% Apply styles class Frontend,OtherServices external class HTTPHandlers,GRPCServer handler class AuthService service class Repositories repository class ServiceClients client class PostgresDB database class RedisCache cache class VaultService vault class MainGo main class UserServiceExt,NotificationServiceExt microservice
Layered architecture with clear separation of concerns
Built for distributed systems and service mesh
Full observability stack for production monitoring
Get up and running in minutes with Docker
Download the source code and dependencies
Set up database and environment variables
Launch with Docker Compose
# Clone the repository
git clone https://github.com/Lumina-Enterprise-Solutions/prism-auth-service.git
cd prism-auth-service
# Copy environment configuration
cp .env.example .env
# Start all services with Docker Compose
docker-compose up -d
# Check service health
curl http://localhost:8080/health
// Example: Using the auth service client in your Go application
package main
import (
"context"
"log"
authpb "github.com/Lumina-Enterprise-Solutions/prism-auth-service/proto"
"google.golang.org/grpc"
)
func main() {
// Connect to auth service
conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure())
if err != nil {
log.Fatal(err)
}
defer conn.Close()
// Create auth client
client := authpb.NewAuthServiceClient(conn)
// Validate token
resp, err := client.ValidateToken(context.Background(), &authpb.ValidateTokenRequest{
Token: "your-jwt-token-here",
})
if err != nil {
log.Fatal(err)
}
log.Printf("Token valid: %v, User ID: %s", resp.Valid, resp.UserId)
}
Comprehensive REST and gRPC API documentation
/api/v1/auth/login
Authenticate user with email/password
/api/v1/auth/refresh
Refresh access token using refresh token
/api/v1/auth/me
Get current user information
/api/v1/auth/2fa/enable
Enable two-factor authentication
/api/v1/oauth/google
Authenticate with Google OAuth
ValidateToken
Validate JWT token and return user claims
GenerateImpersonationToken
Generate impersonation token for admin users
InvalidateSession
Invalidate user session and tokens
GetUserPermissions
Retrieve user permissions and roles
HealthCheck
Service health status and metrics
Built with security-first mindset for enterprise applications
Optimized for high-throughput enterprise workloads
Join our growing community of Go developers