UAuthX is a user authentication system built with Node.js and MongoDB. It provides a secure and efficient way to manage user authentication for web applications.
- User registration with email and password
- User login with email and password
- Token-based authentication using JWT (JSON Web Tokens)
- Centralized management of user authentication
- Scalable architecture
-
Clone the repository:
git clone https://github.com/modularminds/uauthx.git
-
Install dependencies:
cd uauthx npm install
-
Set up environment variables: Create a
.env
file in the root directory and define the following variables:MONGO_URI=mongodb://localhost:27017/uauthx SECRET_KEY=your_secret_key UAUTHX_ADMIN=your_username UAUTHX_PASSWORD=your_password
-
Build the application:
npm run build
-
Start the server:
npm start
-
Build the Docker image:
docker build -t uauthx .
-
Run the Docker container:
docker run -p 5000:5000 \ -e MONGO_URI=mongodb://localhost:27017/uauthx \ -e SECRET_KEY=your_secret_key \ -e UAUTHX_ADMIN=your_username \ -e UAUTHX_PASSWORD=your_password \ -d uauthx
-
Pull the Docker image:
docker pull modularminds/uauthx:latest
-
Run the Docker container:
docker run -p 5000:5000 \ -e MONGO_URI=mongodb://localhost:27017/uauthx \ -e SECRET_KEY=your_secret_key \ -e UAUTHX_ADMIN=your_username \ -e UAUTHX_PASSWORD=your_password \ -d modularminds/uauthx:latest
Endpoint | Request Type | Request Body / Headers | Success Response | Error Response |
---|---|---|---|---|
Register a User | POST /auth/sign-up |
json { "email": "user@example.com", "password": "password123" } |
json { "isSuccess": true, "authToken": "your_jwt_token" } |
json { "isSuccess": false, "error": "Error message" } |
Login | POST /auth/sign-in |
json { "email": "user@example.com", "password": "password123" } |
json { "isSuccess": true, "authToken": "your_jwt_token" } |
json { "isSuccess": false, "error": "Error message" } |
Verify User Token | GET /auth/verify-user |
Header: Authorization: Bearer your_jwt_token | json { "isSuccess": true, "userId": "user_id_string" } |
json { "isSuccess": false, "error": "Error message" } |
To access protected routes, include the JWT token in the Authorization header of your requests:
Authorization: Bearer your_jwt_token
To access admin routes, use Basic Authentication with your admin username and password.
Authorization: Basic base64_encode(username:password)