A modern OpenID Connect (OIDC) authentication system built with Next.js 14, featuring secure authentication and a sleek glassmorphic UI design.
Built by Izaias Cavalcanti
- 🔐 OpenID Connect (OIDC) implementation
- 🌐 Google OAuth 2.0 provider integration
- 🎨 Modern glassmorphic UI design
- 🔄 Server-side rendering with Next.js 14
- 📱 Fully responsive design
- 🚀 Fast and optimized performance
- 🛡️ Type-safe with TypeScript
- Framework: Next.js 14
- Authentication: NextAuth.js (Auth.js)
- Styling: Tailwind CSS
- Language: TypeScript
- Deployment: Vercel
- Node.js (version 18 or higher)
- A Google Cloud Console account
- A Vercel account (for deployment)
Create a .env
file with the following variables:
NEXTAUTH_URL=https://your-domain.vercel.app
NEXTAUTH_SECRET=your_generated_secret
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google OAuth2 API
- Configure the OAuth consent screen
- Create OAuth 2.0 credentials (OAuth client ID)
- Add authorized redirect URIs:
- Development: http://localhost:3000/api/auth/callback/google
- Production: https://your-domain.vercel.app/api/auth/callback/google
- Push your code to GitHub
- Connect your repository to Vercel
- Add environment variables in Vercel project settings
- Deploy!
├── app/
│ ├── api/
│ │ └── auth/
│ │ └── [...nextauth]/
│ │ └── route.ts
│ ├── auth/
│ │ └── signout/
│ │ └── page.tsx
│ ├── dashboard/
│ │ └── page.tsx
│ ├── auth.ts
│ ├── layout.tsx
│ └── page.tsx
├── public/
│ └── bg-abstract.jpg
└── ... (config files)
# Install dependencies
npm install
# Run development server
npm run dev
# Build for production
npm run build
# Start production server
npm start
- OIDC protocol implementation
- JWT-based session management
- Secure environment variable handling
- Protected API routes
- Type-safe authentication
- CSRF protection
- Secure cookie handling
- Glassmorphic design
- Responsive layouts
- Loading states
- Error handling
- Smooth transitions
- Modern components
This system implements the Authorization Code Flow with PKCE:
- User initiates login
- System redirects to Google's OIDC provider
- User authenticates with Google
- Google returns an authorization code
- System exchanges code for tokens
- System verifies tokens and creates session
- User is authenticated and can access protected routes
Izaias Cavalcanti
- GitHub: @iziuqo
MIT
For support, please raise an issue in the GitHub repository.