This project provides a secure authentication service using Google OAuth, allowing users to manage their profiles
List the key features of your application. Use bullet points for readability.
- Google OAuth 2.0 Integration
- User session management
- Secure sign-in and sign-out
- User profile retrieval (name, email, avatar)
- CORS support for frontend integration
This project leverages a modern tech stack to provide a fast and secure experience:
- Backend: Rust (Axum framework)
- Frontend: Next.js (React)
- Authentication: Google OAuth 2.0
- Session Management:
DashMap
(in-memory for demonstration purposes) - Dependency Management: Cargo (Rust), npm/yarn (Node.js)
Provide clear, step-by-step instructions on how to get your project up and running locally.
- Rust & Cargo
- Node.js & npm/yarn (for the frontend)
- Google Cloud Project with OAuth 2.0 credentials (Client ID, Client Secret)
- Clone the repository:
git clone https://github.com/RafaelPil/axum-nextjs-auth.git cd your-repo/backend-directory # Adjust if your backend is in a subfolder
- Create a
.env
file:ReplaceGOOGLE_CLIENT_ID=YOUR_GOOGLE_CLIENT_ID GOOGLE_CLIENT_SECRET=YOUR_GOOGLE_CLIENT_SECRET REDIRECT_URL=http://localhost:8080/auth/google/callback
YOUR_GOOGLE_CLIENT_ID
andYOUR_GOOGLE_CLIENT_SECRET
with your actual Google OAuth credentials. - Run the backend:
The backend server will start on
cargo run
http://localhost:8080
.
- Navigate to the frontend directory:
cd ../frontend-directory # Adjust path as necessary
- Install dependencies:
npm install # or yarn install
- Run the frontend:
The frontend application will typically run on
npm run dev # or yarn dev
http://localhost:3000
.
- backend/.env
GOOGLE_CLIENT_ID=ClientIDHere.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=SecretKeyHere
AUTH_URL=http://localhost:3000/auth/google
TOKEN_URL=http://localhost:3000/auth/google/callback
# PORT=3000 //example port for the backend server
JWT_SECRET=SecretKey
Route | Method | Description |
---|---|---|
/auth/google |
GET |
Initiates the Google OAuth authentication flow. |
/auth/google/callback |
GET |
Handles the OAuth callback from Google, setting the user session. |
/auth/signout |
GET |
Destroys the current user session and logs out. |
/api/user |
GET |
Retrieves information about the currently authenticated user (requires a valid session). |
- Persistent Sessions: Implement database integration (e.g., PostgreSQL, Redis) for durable user sessions instead of in-memory
DashMap
. - User Profile Editing: Add endpoints and frontend functionality for users to update their skills, bio, etc.
- Error Handling: Enhance error handling and provide more specific error messages to the client.
- Live Chat Integration: Implement real-time chat functionality for user communication or support.
- Testing: Add unit and integration tests for both backend and frontend.
Instructions on how others can contribute to your project.
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature
). - Commit your changes (
git commit -m 'Add some AmazingFeature'
). - Push to the branch (
git push origin feature/AmazingFeature
). - Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.