|
| 1 | +# Auth.js-CustomBackend Project |
| 2 | + |
| 3 | +A versatile authentication solution using Auth.js with a FastAPI backend and Next.js frontend. |
| 4 | + |
| 5 | +Use any Frontend/FullStack Framework with Auth.js and bring your custom Auth or use FastAPI Microservice. |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +This project provides a flexible, scalable authentication setup using a decoupled architecture. It integrates seamlessly with any front-end or full-stack framework, allowing developers to use the included custom backend or bring their own backend services. It supports traditional password-based login and Google authentication, providing a robust solution for various authentication needs. |
| 10 | + |
| 11 | +### Tech Stack: |
| 12 | +- **Backend**: FastAPI |
| 13 | +- **Frontend**: Next.js with Auth.js (supports Next.js 14 and above) |
| 14 | +- **Authentication:** Auth.js for managing authentication across multiple front-end or full-stack frameworks. |
| 15 | + |
| 16 | +## Setup Instructions |
| 17 | + |
| 18 | +### Prerequisites |
| 19 | + |
| 20 | +- **Docker**: Ensure you have Docker installed for containerized backend setup. |
| 21 | +- **pnpm**: Make sure pnpm is installed for managing frontend dependencies. |
| 22 | + |
| 23 | +### Cloning the Repository |
| 24 | + |
| 25 | +1. Clone the repository to your local machine: |
| 26 | + |
| 27 | + ```bash |
| 28 | + git clone ... |
| 29 | + cd auth.js-custombackend |
| 30 | + ``` |
| 31 | + |
| 32 | +### Starting the Backend |
| 33 | + |
| 34 | +2. Rename .env.example in both folders. Start the FastAPI backend using Docker Compose: |
| 35 | + |
| 36 | + ```bash |
| 37 | + docker-compose up |
| 38 | + ``` |
| 39 | + |
| 40 | + This command will start the FastAPI service in a Docker container. |
| 41 | + |
| 42 | +### Starting the Frontend |
| 43 | + |
| 44 | +3. Navigate to the frontend directory and install the dependencies using pnpm: |
| 45 | + |
| 46 | + ```bash |
| 47 | + cd nextjs-auth.js |
| 48 | + pnpm install |
| 49 | + ``` |
| 50 | + |
| 51 | +4. Start the Next.js frontend development server: |
| 52 | + |
| 53 | + ```bash |
| 54 | + pnpm dev |
| 55 | + ``` |
| 56 | + |
| 57 | + The frontend will be running at `http://localhost:3000`. |
| 58 | + |
| 59 | +## Key Features |
| 60 | + |
| 61 | +- **Decoupled Architecture**: Easily integrate with any front-end or full-stack framework. |
| 62 | +- **Custom Backend Flexibility**: Use the included FastAPI backend or integrate your own service. |
| 63 | +- **Scalability and Security**: Designed to handle growing user bases while ensuring robust authentication. |
| 64 | +- **Password-based Authentication**: Secure login and signup using traditional username and password. |
| 65 | +- **Google Authentication**: Easily enable users to log in with their Google accounts. |
| 66 | +- **Auth.js Integration**: Use Auth.js to manage authentication flows seamlessly within the frontend and backend. |
| 67 | + |
| 68 | +## API Endpoints Overview |
| 69 | + |
| 70 | +- **Login Access Token**: `/api/v1/login/access-token` - Obtain an OAuth2-compatible access token. |
| 71 | +- **Test Token**: `/api/v1/login/test-token` - Validate the current access token. |
| 72 | +- **Google Auth Access Token**: `/api/v1/google-auth/access-token` - Login using Google credentials. |
| 73 | +- **Register User**: `/api/v1/users/signup` - Create a new user account. |
| 74 | +- **Password Recovery**: `/api/v1/password-recovery/{email}` - Initiate password recovery process. |
| 75 | +- **Reset Password**: `/api/v1/reset-password/` - Reset user password using a token. |
| 76 | + |
| 77 | +## Getting Involved |
| 78 | + |
| 79 | +Contributions are welcome! If you have suggestions, features, or improvements, feel free to submit a pull request or open an issue on GitHub. |
| 80 | + |
| 81 | +## License |
| 82 | + |
| 83 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 84 | + |
| 85 | +## Contact |
| 86 | + |
| 87 | +For questions or support, please contact us at [mr.junaidshaukat@gmail.com](mailto:mr.junaidshaukat@gmail.com). |
0 commit comments