https://github.com/kartikmehta8/rust-node-auth-service
This project is a robust authentication service combining Rust and Node.js with MongoDB for secure user management, password hashing, JWT authentication, and protected routes via Neon bindings and Express.js.
https://github.com/kartikmehta8/rust-node-auth-service
authentication expressjs neon-bindings rust
Last synced: about 2 months ago
JSON representation
This project is a robust authentication service combining Rust and Node.js with MongoDB for secure user management, password hashing, JWT authentication, and protected routes via Neon bindings and Express.js.
- Host: GitHub
- URL: https://github.com/kartikmehta8/rust-node-auth-service
- Owner: kartikmehta8
- Created: 2024-12-11T09:55:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-11T09:55:43.000Z (over 1 year ago)
- Last Synced: 2025-07-03T16:14:30.088Z (12 months ago)
- Topics: authentication, expressjs, neon-bindings, rust
- Language: Rust
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rust-Node Authentication Service
## Overview
This project is a robust authentication service that integrates a **Rust backend** (compiled as a Node.js native module using Neon bindings) with an **Express.js server**. It uses **MongoDB** for storing user information and **JWT tokens** for secure authentication.
### Key Features
- User Registration with password hashing (using `bcrypt`).
- Secure Login with JWT generation.
- Protected routes using JWT verification middleware.
- MongoDB integration for persistent user data storage.
## Endpoints
### 1. **User Registration**
- **URL**: `/signup`
- **Method**: `POST`
- **Request Body**:
```json
{
"name": "John Doe",
"email": "john.doe@example.com",
"username": "johndoe",
"password": "securepassword"
}
```
- **Response**:
- **Success** (201):
```json
{
"message": "User registered successfully."
}
```
- **Failure** (400 or 422):
```json
{
"error": "Validation failed: ."
}
```
### 2. **User Login**
- **URL**: `/login`
- **Method**: `POST`
- **Request Body**:
```json
{
"username": "johndoe",
"password": "securepassword"
}
```
- **Response**:
- **Success** (200):
```json
{
"token": ""
}
```
- **Failure** (401):
```json
{
"error": "Invalid username or password."
}
```
### 3. **Protected Route**
- **URL**: `/protected`
- **Method**: `GET`
- **Headers**:
```json
{
"Authorization": "Bearer "
}
```
- **Response**:
- **Success** (200):
```json
{
"message": "Access granted."
}
```
- **Failure** (401):
```json
{
"error": "Unauthorized."
}
```
## Environment Variables
| Variable | Description | Default Value |
|----------------|---------------------------------------|---------------------------|
| `MONGO_URI` | MongoDB connection string | `mongodb://localhost:27017`|
| `DATABASE_NAME`| Database name for the project | `auth_service` |