Thanks to visit codestin.com
Credit goes to github.com

Skip to content

af03448/authkit

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AuthKit - Production-Ready Authentication

AuthKit

Production-ready authentication microservice powered by WorkOS

Explore the docs β†—

πŸš€ Quick Start

This is a production-ready authentication microservice with clean, professional URLs and enterprise-grade security features.

Authentication Flow

  • / - Landing page with sign-in
  • /auth/signin - Redirects to WorkOS hosted UI
  • /auth/callback - Handles OAuth return and creates session
  • /auth/signout - Clears session and signs out
  • /dashboard - Protected user dashboard

API Endpoints

  • /api/health - System health check
  • /api/metrics - Performance metrics (requires authentication)

πŸ”§ Setup

1. Prerequisites

2. Environment Configuration

# Copy environment template
cp .env.example .env.local

# Generate JWT secret
openssl rand -base64 32

Edit .env.local with your WorkOS credentials:

WORKOS_CLIENT_ID=client_XXXXXXXXXX
WORKOS_API_KEY=sk_XXXXXXXXXX
JWT_SECRET_KEY=your_base64_encoded_secret_key_here
NEXT_PUBLIC_APP_URL=http://localhost:3000

3. WorkOS Dashboard Setup

  1. Navigate to Redirects in your WorkOS dashboard
  2. Add callback URL: http://localhost:3000/auth/callback

4. Run the Application

npm install
npm run dev

Visit http://localhost:3000 and click "Sign In" to test authentication!

🌐 Production Deployment

Environment Variables

# Use production WorkOS credentials
WORKOS_CLIENT_ID=client_prod_XXXXXXXXXX
WORKOS_API_KEY=sk_prod_XXXXXXXXXX
JWT_SECRET_KEY=your_base64_encoded_secret_key_here

# Production configuration
NODE_ENV=production
NEXT_PUBLIC_APP_URL=https://your-domain.com
SECURE_HEADERS_ENABLED=true
RATE_LIMIT_ENABLED=true

Deploy

npm run build
npm run start:production

Register Production Callback

In WorkOS dashboard, add: https://your-domain.com/auth/callback

πŸ” Security Features

βœ… JWT Session Management - Secure, stateless sessions
βœ… Rate Limiting - Prevents abuse and brute force attacks
βœ… Security Headers - HSTS, CSP, X-Frame-Options protection
βœ… Input Validation - All inputs sanitized and validated
βœ… Error Handling - Production-safe error messages
βœ… Audit Logging - Comprehensive authentication logs
βœ… Environment Validation - Startup configuration checks
βœ… Health Monitoring - Built-in health check endpoints

πŸ“Š Monitoring

  • Health Check: GET /api/health - System status
  • Metrics: GET /api/metrics - Performance data (authenticated)
  • Logs: Structured logging with Winston
  • Error Tracking: Comprehensive error handling

πŸ› οΈ Customization

Add Protected Routes

Edit src/middleware.ts:

export const config = {
  matcher: [
    '/dashboard/:path*',
    '/admin/:path*',        // Add your protected routes
    '/api/metrics',
  ],
};

Custom Branding

  • Edit src/app/page.tsx for landing page
  • Edit src/app/dashboard/page.tsx for dashboard
  • All styled with Tailwind CSS

πŸ“š Documentation

  • SIMPLIFIED_PRODUCTION_GUIDE.md - Quick setup guide
  • PRODUCTION_GUIDE.md - Comprehensive deployment guide
  • CLEAN_PRODUCTION_SUMMARY.md - Feature overview

🎯 Architecture

Built with:

  • Next.js 14 - React framework with App Router
  • WorkOS - Enterprise authentication platform
  • TypeScript - Type safety throughout
  • Tailwind CSS - Utility-first styling
  • Winston - Production logging
  • Zod - Runtime validation

🚨 Support

  • WorkOS Issues: WorkOS Support
  • Application Issues: Check logs and health endpoints

πŸŽ‰ Your authentication microservice is production-ready!

About

The world's best login box powered by WorkOS and Radix.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 90.0%
  • CSS 5.7%
  • JavaScript 4.3%