Skip to content

Latest commit

Β 

History

History
124 lines (88 loc) Β· 3.76 KB

README.md

File metadata and controls

124 lines (88 loc) Β· 3.76 KB

πŸ“ Secure File Sharing System

This repository contains a secure file-sharing REST API built using FastAPI. It supports role-based access control, JWT authentication, and secure one-time download links, ensuring safe delivery of files between operation users and clients.


πŸ›  Tech Stack

  • Language: Python 3
  • Framework: FastAPI
  • Authentication: JWT (OAuth2), Role-based (Ops, Client)
  • Encryption: Fernet (used for secure email verification tokens)
  • Data Storage: In-memory (Python dictionaries for simplicity)
  • API Testing: Postman (collection included)
  • Package Management: pip (requirements.txt)

πŸ“ Project Structure

secure_file_sharing/
β”œβ”€β”€ main.py                              # Main application file
β”œβ”€β”€ .env                                 # Environment configuration
β”œβ”€β”€ requirements.txt                     # Python dependencies
β”œβ”€β”€ SecureFileSharingAPI.postman_collection.json  # Postman collection
└── README.md                            # Project documentation

βœ… Features

  • πŸ” User registration with role selection (client, ops)
  • πŸ“§ Email verification using a secure Fernet token
  • πŸ”‘ JWT-based login and token-based authorization
  • πŸ“€ Upload capability for operations team only
  • πŸ“‚ File listing and downloading for verified clients
  • πŸ”— Secure one-time download links for files
  • πŸ“Š Simulated download tracking per client

πŸš€ Getting Started

1. Clone the Repository

git clone https://github.com/pinnu1/file_sharing.git
cd secure_file_sharing

2. Install Dependencies

pip install -r requirements.txt

3. Set Up Environment Variables

Create a .env file in the project root with the following keys:

SECRET_KEY=your_jwt_secret_key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
FERNET_KEY=your_fernet_key_here

Generate a Fernet key using:

from cryptography.fernet import Fernet
print(Fernet.generate_key().decode())

4. Run the Application

uvicorn main:app --reload

Access the API at:
πŸ“Ž http://127.0.0.1:8000/docs


πŸ“‘ API Endpoints

Method Endpoint Access Role Description
POST /signup Public Register a new user
GET /verify-email/{token} Public Verify user's email
POST /login Public User login and receive JWT token
POST /upload Ops only Upload files
GET /list-files Client only View list of uploaded files
GET /download-file/{file_id} Client only Generate a secure file download link
GET /secure-download/{token} Client only One-time download using token
GET /download-history Client only View download history (simulated)

πŸ§ͺ API Testing with Postman

  1. Open Postman and import the collection:
    SecureFileSharingAPI.postman_collection.json

  2. Test the API by following this flow:

    • βž• Sign Up using /signup
    • πŸ“§ Verify Email using /verify-email/{token}
    • πŸ” Login via /login and capture the access_token
    • πŸ“€ Upload Files as an ops user
    • πŸ“₯ List & Download Files as a client user

πŸ“¬ Contact

Created and maintained by Prashant Garg
πŸ“§ Email: aprashant703@gmail.com
πŸ’Ό GitHub: https://github.com/pinnu1