Skip to content

lmousom/passless-auth

Repository files navigation

Passless Auth

A Go-based passwordless authentication system using OTP (One-Time Password) with enterprise-grade security features.

Go Report Card License: MIT GoDoc

πŸ“‹ Table of Contents

✨ Features

Core Features

  • πŸ” OTP Generation and Verification
  • πŸ”‘ JWT-based Authentication
  • πŸ“± Session Management
  • πŸ”„ Refresh Token Support
  • πŸ›‘οΈ Rate Limiting
  • 🚦 Security Headers
  • πŸ“ Request Logging
  • βš™οΈ Configurable Security Settings

Enterprise Features

  • πŸ“Š Prometheus Metrics Collection
  • πŸ” Distributed Tracing with OpenTelemetry
  • ⚑ Circuit Breaker for External Services
  • πŸ₯ Health Checks and Service Status
  • βš™οΈ Configuration Management with Viper
  • πŸ›‘ Graceful Shutdown
  • πŸ“ˆ Metrics Dashboard Integration
  • πŸ“ Advanced Logging with Correlation IDs
  • πŸ”„ Service Discovery Ready
  • πŸ₯ Container Health Probes

πŸ—οΈ Architecture

Project Structure

β”œβ”€β”€ cmd/
β”‚   β”œβ”€β”€ server/          # Application entry point
β”‚   └── encrypt/         # Configuration encryption utility
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ handlers/    # Request handlers
β”‚   β”‚   └── routes/      # Router setup
β”‚   β”œβ”€β”€ auth/            # Authentication logic
β”‚   β”œβ”€β”€ config/          # Configuration
β”‚   β”œβ”€β”€ middleware/      # Security middleware
β”‚   β”œβ”€β”€ services/        # External services (SMS, etc.)
β”‚   └── models/          # Data models
β”œβ”€β”€ pkg/                 # Public packages
└── README.md

Component Overview

  • API Layer: HTTP handlers and route definitions
  • Authentication: OTP and JWT management
  • Services: External service integrations
  • Middleware: Security and logging middleware
  • Configuration: App configuration and encryption
  • Storage: Data persistence layer

πŸš€ Getting Started

Prerequisites

  • Go 1.24 or later
  • Docker and Docker Compose
  • Redis (for session management)
  • Twilio account (for SMS)

Quick Start

  1. Clone the repository:
git clone https://github.com/lmousom/passless-auth.git
cd passless-auth
  1. Install dependencies:
go mod tidy
  1. Set up encryption:
# Generate encryption key
./scripts/manage-keys.sh generate

# Set the encryption key
export PASSLESS_ENCRYPTION_KEY='your-generated-key'
  1. Start the services:
docker-compose up --build

βš™οΈ Configuration

Environment Variables

export PASSLESS_SERVER_PORT=8080
export PASSLESS_JWT_SECRET=your-secret
export PASSLESS_SMS_ACCOUNT_SID=your-sid
export PASSLESS_ENCRYPTION_KEY=your-encryption-key

Configuration File

See config/config.yaml for detailed configuration options.

πŸ”’ Security

Key Features

  • AES-GCM encryption for sensitive values
  • Rate limiting (20 requests/minute)
  • Secure headers (HSTS, CSP, XSS)
  • JWT-based session management
  • Secure OTP generation
  • Encrypted configuration
  • SMS-based OTP delivery

Best Practices

  1. Never commit encryption keys
  2. Use different keys per environment
  3. Regular key rotation
  4. Monitor access attempts
  5. Keep dependencies updated

πŸ“š API Documentation

Endpoints

  • POST /api/v1/sendOtp - Send OTP
  • POST /api/v1/verifyOtp - Verify OTP
  • POST /api/v1/2fa/enable - Enable 2FA
  • POST /api/v1/2fa/verify - Verify 2FA
  • GET /api/v1/login - Check auth status
  • POST /api/v1/refreshToken - Refresh token
  • POST /api/v1/logout - Logout

Postman Collection

Import passless-auth.postman_collection.json for API testing.

πŸ’» Development

Local Development

  1. Start dependencies:
docker-compose up -d redis prometheus otel-collector
  1. Run the application:
go run cmd/server/main.go

🚒 Deployment

Docker Deployment

docker-compose up --build

πŸ“„ License

MIT License - See LICENSE for details


Golang API

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors