Skip to content

feat(auth): Add Google OAuth with NextAuth and secure dashboard route #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Ad1th
Copy link

@Ad1th Ad1th commented Jun 17, 2025

Features

  • Integrated Google OAuth using next-auth.
  • Added middleware to protect /dashboard and future admin routes.
  • Created a simple /login page with a "Login with Google" button.
  • Ensured dashboard is only accessible after login.
  • All credentials are loaded from .env.local.

Security

  • Routes under /dashboard and /admin are protected by session-based auth.
  • Redirects to /login if the user is unauthenticated.

Setup

Make sure to add the following to .env.local:

GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
NEXTAUTH_SECRET=your-generated-secret
NEXTAUTH_URL=http://localhost:3000

Generate the NEXTAUTH_SECRET via:

openssl rand -base64 32

Video reference:
https://github.com/user-attachments/assets/3bee3ed7-db59-4f30-8e5c-46fcf05ab4b2

Images:

image image image image image

@Ad1th Ad1th changed the title Adith/oauth feat(auth): Add Google OAuth with NextAuth and secure dashboard route Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant