Skip to content

vansh-commits/Auth-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” Auth Template

A full-stack authentication template with Go backend (Fiber) and Next.js 15 frontend (NextAuth v5).

✨ Features

  • Google OAuth Integration - Seamless sign-in with Google
  • JWT Authentication - Secure session management with refresh tokens
  • User Management - CRUD operations and user directory
  • CORS Protection - Environment-aware configuration
  • PostgreSQL Database - Robust data persistence with GORM

πŸš€ Quick Start

Backend Setup

cd backend
go mod download
# Set up .env with DATABASE_URL, JWT_SECRET, INTERNAL_SYNC_TOKEN
go run main.go

Frontend Setup

cd frontend
npm install
# Set up .env.local with Google OAuth credentials
npm run dev

πŸ—οΈ Architecture

  • Backend: Go + Fiber + PostgreSQL + GORM
  • Frontend: Next.js 15 + NextAuth v5 + TypeScript + Tailwind CSS
  • Authentication: JWT + HTTP-only cookies + Google OAuth

πŸ“‘ API Endpoints

  • POST /auth/internal/sso-sync - SSO synchronization
  • GET /users/bulk - Get all users (authenticated)
  • GET /users/:id - Get specific user (authenticated)

πŸ” Security Features

  • JWT validation and revocation
  • Environment-specific CORS
  • Secure headers

πŸ“ Environment Variables

Backend

DATABASE_URL=postgresql://user:pass@localhost:5432/db
JWT_SECRET=your-secret
INTERNAL_SYNC_TOKEN=your-token
ENV=development

Frontend

GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-secret
NEXTAUTH_SECRET=your-secret
API_BASE=http://localhost:8080

πŸš€ Deployment

  • Set ENV=production
  • Configure FRONTEND_PROD_URL
  • Environment-specific database configs

Built with Go, Fiber, Next.js, and NextAuth

About

Simple template to get dtarted with Auth.js and Oauth in goLang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published