Skip to content

feat(auth): Implement Secure Authentication System with JWT and OAuth#20

Merged
TKanX merged 67 commits intomainfrom
feature/19-implement-authentication-system
Feb 1, 2026
Merged

feat(auth): Implement Secure Authentication System with JWT and OAuth#20
TKanX merged 67 commits intomainfrom
feature/19-implement-authentication-system

Conversation

@TKanX
Copy link
Copy Markdown
Member

@TKanX TKanX commented Feb 1, 2026

Summary:

Implemented a robust authentication system for the admin dashboard, supporting both email/password login and Google OAuth. The system utilizes a dual-token strategy (Access + Refresh tokens) secured via HttpOnly cookies and implemented using the jose library for edge compatibility. This foundational work enables secure access control for future admin features.

Changes:

  • Implemented Authentication Logic (src/lib/auth/):

    • JWT Management: Created jwt.ts to sign and verify Access (15 min) and Refresh (7 days) tokens using HS256.
    • Cookie Security: Implemented cookies.ts to handle secure, HttpOnly cookie storage and retrieval.
    • Session Handling: Developed session.ts to manage high-level auth flows (login, logout, refresh, getCurrentUser).
    • OAuth: Added google.ts to handle the Google OAuth 2.0 authorization code flow.
    • Password Security: Integrated bcryptjs in password.ts for secure password hashing and verification.
  • Created Auth API Routes (src/app/api/auth/):

    • POST /login: Validates credentials and sets auth cookies.
    • POST /logout: Clears auth cookies.
    • GET /me: Returns the currently authenticated user.
    • GET /google & /google/callback: Handles the OAuth handshake and user verification.
  • Built Login UI (src/app/admin/login/page.tsx):

    • Designed a responsive login page featuring the Beckman Institute background.
    • Implemented a form for email/password login with error handling and loading states.
    • Added a "Continue with Google" button for OAuth integration.
  • Set up Admin Dashboard Skeleton (src/app/admin/(authenticated)/):

    • Created a protected layout that redirects unauthenticated users to login.
    • Added a placeholder dashboard showing user role and a logout button.
  • Configuration Updates:

    • Added JWT_SECRET, GOOGLE_CLIENT_ID, and GOOGLE_CLIENT_SECRET to environment validation (src/config/env.ts).
    • Updated prisma/seed.ts to hash the default admin password using bcrypt.
    • Updated next.config.mjs image domains.
  • Dependencies:

    • Added jose for JWT operations, bcryptjs for hashing, and @types/bcryptjs.
    • Added @radix-ui/react-label for accessible form inputs.

TKanX added 30 commits January 30, 2026 20:01
TKanX added 24 commits January 31, 2026 18:08
…neration, token exchange, and user info retrieval
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 32 out of 37 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/auth/constants.ts
Comment thread src/config/site.ts
Comment thread src/config/env.ts
Comment thread src/middleware.ts Outdated
Comment thread src/app/admin/login/page.tsx
Comment thread src/app/api/auth/login/route.ts
Comment thread src/app/api/auth/login/route.ts
@TKanX TKanX merged commit 6bb4b0f into main Feb 1, 2026
2 checks passed
@TKanX TKanX deleted the feature/19-implement-authentication-system branch February 1, 2026 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Authentication System

2 participants