A robust and feature-rich authentication system built with Lucia, offering various authentication methods and security features.
- Email Verification: Secure user registration with email verification.
- Multiple OAuth Providers:
- GitHub
- Discord
- Password Recovery: Implemented "Forgot Password" functionality.
- Magic Link Authentication: Passwordless login via email.
- Custom Lucia Integration: Built from scratch for maximum flexibility.
- Secure Password Hashing: Utilizes
@node-rs/argon
for efficient and secure password hashing. - Two-Factor Authentication (2FA): Coming soon!
- Authenticator App Support: Coming soon!
- Next Js (v14 or later)
- npm or yarn or bun or pnpm
- Postgress
- Docker (Just the basics)
-
Clone the repository:
git clone https://github.com/vanshavenger/lucia-auth-public.git cd lucia-auth-system
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env
file in the root directory and add the following:DATABASE_URL='postgresql://postgres:postgres@postgres:5432/postgres' GOOGLE_CLIENT_ID= GOOGLE_CLIENT_SECRET= GITHUB_CLIENT_SECRET= GITHUB_CLIENT_ID= DISCORD_CLIENT_ID= DISCORD_CLIENT_SECRET= APP_NAME='http://localhost:3000' JWT_SECRET='' GMAIL_PASSWORD= GMAIL_USER=
or you can copy .env.sample for starters
-
Start the development server:
docker compose up --build
After registration, users will receive a verification email. They must click the link in the email to verify their account.
Users can log in using their GitHub, Google, or Discord accounts. Click on the respective buttons on the login page.
- Click on the "Forgot Password" link on the login page.
- Enter your email address.
- Check your email for password reset instructions.
- On the login page, choose "Login with Magic Link".
- Enter your email address.
- Check your email for the magic link and click it to log in.
- Passwords are hashed using
@node-rs/argon
for top-notch security. - Two-Factor Authentication (2FA) will be available soon for an extra layer of security.
We welcome contributions!
This project is licensed under the MIT License!
- Lucia Auth for the excellent authentication library.
- All contributors and supporters of this project.
- https://youtu.be/JIIy7VkiTqU?si=iN4TvzF62KJOVt2V - Reference video + Lucia Docs and github discussions to get the best practices
For any queries or support, please open an issue in this repository or contact us at [email protected]