๐Ÿ“ฆ haasal / fileserver

โ˜… 0 stars โ‘‚ 0 forks ๐Ÿ‘ 0 watching
๐Ÿ“ฅ Clone https://github.com/haasal/fileserver.git
HTTPS git clone https://github.com/haasal/fileserver.git
SSH git clone git@github.com:haasal/fileserver.git
CLI gh repo clone haasal/fileserver
Alexander Haas Alexander Haas Create README.md 7a3ede0 2 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ src
๐Ÿ“„ .gitignore
๐Ÿ“„ Cargo.lock
๐Ÿ“„ Cargo.toml
๐Ÿ“„ README.md
๐Ÿ“„ README.md

Actix File Server with API Key Authentication

This is a simple, yet powerful Actix file server written in Rust, which provides file access through a secure API key authentication mechanism. It serves files from a local directory while ensuring that only trusted web services can access them.

Features

  • Actix Web framework for efficient and fast web server
  • API key authentication for secure file access
  • Customizable local directory for serving files
  • Path sanitization to prevent directory traversal attacks
  • Environment variable-based configuration

Setup

  • Clone the repository to your local machine.
  • Set the required environment variables:
  • APIKEY: The API key to be used for authentication.
  • SOCKET: The address and port the server should bind to (e.g., 127.0.0.1:8080).
  • Run the server using cargo run.

Usage

To access a file from the server, send a GET request to the server with the desired file path and include the x-api-key header with the correct API key.

Example:

GET /path/to/file.txt
x-api-key: yourapikey

If the provided API key is correct and the file exists, the server will return the file. Otherwise, it will return an error with the appropriate status code.