Skip to content

aby-jo/Secure-File-Share

Repository files navigation

🔐 Secure File Sharing System

A secure, token-based file sharing system built with Spring Boot, JWT authentication, AES encryption, and role-based access control. Users can upload, download, and share files using one-time access tokens.


🚀 Features

  • ✅ Secure file upload & download
  • 🔑 JWT-based authentication
  • 🔐 AES encryption for file storage
  • 🧑 Role-based access control (USER / ADMIN)
  • 🔗 One-time share token generation
  • 🧪 JUnit + Mockito unit tests
  • 🐳 Dockerized for easy deployment

🛠 Tech Stack

  • Java 17 + Spring Boot 3
  • Spring Security 6
  • JWT (JSON Web Tokens)
  • AES (Advanced Encryption Standard)
  • JPA PostgreSQL
  • Maven
  • Docker & Docker Compose

⚙️ Getting Started

🔧 Prerequisites

  • Java 17+
  • Maven
  • Docker (optional)
  • Git

🧪 Clone & Run Locally

git clone "your-repo"
cd "your-repo"
./mvnw spring-boot:run

📦 Run with Docker

# Start the app
docker compose -f docker-compose.yml up -d
# Stop it
docker compose -f docker-compose.yml down

📝 Ensure .env is present with your SECRET_KEY and other configs.

🔑 Authentication

All secured endpoints require a JWT in the Authorization header.

🔐 Endpoints

Method Endpoint Access Description
POST /api/auth/register Public Register new user
POST /api/auth/login Public Login and receive JWT
GET /api/users/protected Admin only Admin-protected sample endpoint

📁 File Management

Method Endpoint Access Description
POST /api/files/upload Authenticated Upload a file
GET /api/files/my Authenticated List user's uploaded files
GET /api/files/download/{id} Authenticated Download user's own file

🔗 Share Token System

Method Endpoint Access Description
POST /api/token/generate Authenticated Generate one-time token for own file
GET /api/token/download/{token} Public Download shared file using token

🧪 Testing

Run all unit tests with:

./mvnw test
  • Tested using JUnit 5, Mockito, and MockMvc

  • Includes controller and service tests

  • Mocked JWT and Authentication behavior

📁 .env Configuration

Create a .env file in your project root with:

SECRET_KEY=your-super-secret-key

Loaded with dotenv-java

📄 License

MIT – Feel free to use, modify, and share.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published