A secure HTTP server with authentication and file management
Project description
Secure HTTP Server
A lightweight, secure HTTP server with authentication and comprehensive file management capabilities.
Features
- 🔐 HTTP Basic Authentication with user management
- 📁 Full CRUD Operations: GET, POST, PUT, DELETE
- 🛡️ Security Features: Path traversal prevention, password hashing
- 👥 Multi-user Support with role-based access
- 📂 Directory Browsing with HTML interface
- 🔧 Command-line Management for users
- 📝 Comprehensive Logging with debug mode
- 🚀 Zero External Dependencies for core functionality
- 📦 Easy Installation via pip or Debian package (Not supporeted for now!!)
Table of Contents
- Installation
- Quick Start
- Usage
- Configuration
- Security
- Development
- Testing
- Documentation
- Contributing
- License
Installation
From PyPI
pip3 install secure-http-server
From Source
git clone https://github.com/moncef007/secure-http-server.git
cd secure-http-server
pip3 install -r requirements.txt
make all
Debian Package
TODO
Quick Start
-
Start the server (default port 9000):
secure-http-server
-
Access the server:
http://localhost:9000Default credentials:
admin/admin123 -
Change the default password:
secure-http-server --manage-users
Usage
Starting the Server
# Basic usage (serves current directory)
secure-http-server
# Specify host and port
secure-http-server --host 0.0.0.0 --port 8080
# Serve a specific directory
secure-http-server --directory /path/to/share
# Use custom users file
secure-http-server --users-file /etc/secure-server/users.json
# Enable debug mode
secure-http-server --debug
# Show help
secure-http-server --help
User Management
Interactive Management
secure-http-server --manage-users
Command-line Management
# List all users
secure-http-server --list-users
# Add a new user
secure-http-server --add-user username password role
# Remove a user
secure-http-server --remove-user username
API Examples
Upload a File
curl -u username:password -X PUT \
--data-binary @local-file.txt \
http://localhost:9000/uploaded-file.txt
Download a File
curl -u username:password \
http://localhost:9000/uploaded-file.txt \
-o downloaded-file.txt
List Directory
curl -u username:password http://localhost:9000/
Append to File
echo "New log entry" | curl -u username:password -X POST \
--data-binary @- \
http://localhost:9000/logfile.txt
Delete a File
curl -u username:password -X DELETE \
http://localhost:9000/unwanted-file.txt
Configuration
Server Options
| Option | Default | Description |
|---|---|---|
--host |
localhost |
Server bind address |
--port |
9000 |
Server port |
--directory |
. |
Directory to serve |
--users-file |
users.json |
Path to users database |
--debug |
False |
Enable debug logging |
--no-banner |
False |
Disable startup banner |
Users File Format
The users file is a JSON file with the following structure:
{
"username": {
"password_hash": "sha256_hash_of_password",
"role": "user|admin"
}
}
Security
Features
- Authentication: HTTP Basic Authentication required for all operations
- Password Security: SHA-256 hashed passwords (never stored in plain text)
- Path Traversal Prevention: All paths are sanitized and restricted to the server root
- No Directory Traversal: Requests containing
..are rejected
Documentation
Available Documentation
- API Documentation: docs/API.md
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Commit your changes (
git commit -am 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Create a Pull Request
Development Guidelines
- Follow PEP 8 style guide
- Update documentation as needed
- Keep commits atomic and well-described
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built with Python's built-in
http.servermodule - Thanks to all contributors and testers
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file secure_http_server-0.0.1.tar.gz.
File metadata
- Download URL: secure_http_server-0.0.1.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5972282ab0df10383817b456d208d21c021c78f6cfe58fffb7075e453e29f90
|
|
| MD5 |
0ccb9326a069371afe2275d3f2f467c7
|
|
| BLAKE2b-256 |
afe9abc77d14a1e3283ea9246eb4f23498e442258042a91738e7b15a2ced58df
|
File details
Details for the file secure_http_server-0.0.1-py3-none-any.whl.
File metadata
- Download URL: secure_http_server-0.0.1-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcdbb266f600a359c8573873b12b87d25e97edf29f8ac5bda6db5812d0f6fb22
|
|
| MD5 |
5679b6a1b902a81bb3ab45b87390c31a
|
|
| BLAKE2b-256 |
ae993e39e331bafc5443a944a3d9837f4a6977365533668dfa18c87deefb36e1
|