Kosh is a modern Flask application for secure file sharing over a local network using AES encryption and simulated Attribute-Based Encryption (ABE). It features a beautiful Tailwind-based UI, an admin dashboard for user and policy management, real-time synchronization, and improved file structure for scalability.
- Quick Setup
- Features
- Project Structure
- Getting Started
- Real-Time Features
- Security
- Architecture
- Development
- Contributing
- License
pip install -r requirements.txtpython3 -m app.appOpen your browser: http://localhost:7130
Default Login:
- Username:
admin - Password:
pass
The application is now running. You can:
- Upload encrypted files
- Set access policies based on user attributes
- Manage users and their attributes
- View audit logs
Note: All files stored in data/ and app/uploads/. Simple JSON-based storage (no database needed). Real-time updates using WebSockets. AES encryption for all files.
Kosh uses minimal, well-maintained dependencies:
- Flask 3.1.2 - Web framework
- flask-socketio 5.5.1 - WebSocket support for real-time features
- flask-cors 6.0.1 - CORS handling
- cryptography 45.0.7 - Encryption library (AES, HMAC)
- werkzeug 3.1.3 - WSGI utilities and password hashing
All dependencies are specified in requirements.txt and can be installed with:
pip install -r requirements.txtKosh uses a centralized configuration system (app/config.py) with environment variable support.
Create a .env file from the template:
cp .env.example .envAvailable configuration options:
| Variable | Default | Description |
|---|---|---|
KOSH_SECRET_KEY |
kosh-secret-key-change-in-production |
Flask secret key for sessions |
KOSH_DEBUG |
True |
Enable debug mode |
KOSH_HOST |
0.0.0.0 |
Host to bind to (0.0.0.0 = all interfaces) |
KOSH_PORT |
7130 |
Port to run on |
KOSH_AUDIT_RETENTION_DAYS |
60 |
Days to keep audit logs |
Configured in app/config.py:
MAX_FILE_SIZE = 5 * 1024 * 1024 * 1024 # 5GB
ALLOWED_EXTENSIONS = {
'txt', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'csv',
'jpg', 'jpeg', 'png', 'gif', 'zip', 'rar', 'py', 'js', 'json',
'mp4', 'mov', 'avi', 'mkv'
}IV_SIZE = 16 # AES block size (bytes)
CHUNK_SIZE = 65536 # 64KB chunks for stream processing
TAG_SIZE = 32 # HMAC-SHA256 output size (bytes)Automatically created on first run:
data/- Data files (users, policies, attributes, audit logs, keys)app/uploads/- Encrypted file storage
- π AES-256-CTR encryption with HMAC-SHA256 for authenticated file encryption
- π§βπ» User-based attribute system for granular access control
- π Simulated ABE access control using JSON-based policies
- ποΈ Comprehensive admin dashboard for managing users, attributes, and file policies
- οΏ½ Role-based access control with role_manager permissions for delegated administration
- οΏ½π‘ Modern Tailwind CSS UI for all pages with responsive design
- π No cloud dependency β works entirely on LAN
- π File policies with metadata (policy, key, uploader, timestamp)
- ποΈ Automatic audit log cleanup with configurable retention period
- π₯ Audit log export functionality for compliance and analysis
- π Live synchronization across all admin sessions using Flask-SocketIO
- π± Toast notifications for user feedback and operation status
- π Auto-reconnection and connection status indicators
- π Live audit logs streamed to admin dashboard
- β‘ Bulk operations with real-time updates (users, policies, attributes)
- π Instant notifications for user additions, deletions, policy changes
- π Real-time dashboard updates when files are uploaded or deleted
- π AES-256-CTR encryption for all file operations
- π HMAC-SHA256 for data integrity verification
- π‘οΈ Attribute-based access control with flexible policy definitions
- π₯ Session-based authentication with secure password hashing (Werkzeug)
- π Comprehensive audit logging for all administrative and user actions
- π« Input validation and sanitization to prevent injection attacks
- π Secure key storage with auto-generated encryption keys
- β° Configurable audit log retention for compliance requirements
kosh/
βββ app/
β βββ __init__.py # Package initialization
β βββ app.py # Main Flask application with routes and WebSocket handlers
β βββ attribute_management.py # Attribute CRUD operations and role-based management
β βββ config.py # Centralized configuration and environment settings
β βββ utils.py # Shared utility functions for the application
β βββ crypto/
β β βββ __init__.py
β β βββ aes.py # AES-256 encryption/decryption with HMAC
β β βββ abe_simulator.py # JSON-based ABE access control simulation
β βββ static/
β β βββ admin/ # Admin dashboard specific assets
β β β βββ admin.css
β β β βββ admin-dashboard.js
β β β βββ tailwind.config.js
β β βββ dashboard/ # User dashboard specific assets
β β β βββ dashboard.css
β β β βββ dashboard.js
β β β βββ dashboard-tailwind.config.js
β β βββ shared/ # Shared components and utilities
β β β βββ components/ # Reusable UI components
β β β β βββ modal.js
β β β β βββ notification-manager.js
β β β β βββ toast.js
β β β βββ modules/ # Feature-specific modules
β β β β βββ attribute-manager.js
β β β β βββ audit-manager.js
β β β β βββ dashboard-file-manager.js
β β β β βββ file-manager.js
β β β β βββ password-manager.js
β β β β βββ policy-manager.js
β β β β βββ realtime-manager.js
β β β β βββ role-manager.js
β β β β βββ role-manager-attribute.js
β β β β βββ upload-manager.js
β β β β βββ user-manager.js
β β β βββ utils/ # UI helper utilities
β β β βββ admin-links.js
β β β βββ ui-helpers.js
β β βββ common/ # Common assets (favicons, icons, PWA manifest)
β β βββ android-chrome-192x192.png
β β βββ android-chrome-512x512.png
β β βββ apple-touch-icon.png
β β βββ favicon-16x16.png
β β βββ favicon-32x32.png
β β βββ favicon.ico
β β βββ site.webmanifest
β βββ templates/
β β βββ index.html # Login page
β β βββ dashboard.html # User dashboard
β β βββ admin.html # Admin dashboard
β βββ uploads/ # Encrypted file storage (auto-created)
βββ data/
β βββ aes_encryption.key # AES encryption key (auto-generated)
β βββ aes_hmac.key # HMAC key for integrity (auto-generated)
β βββ attributes.json # Global attribute pool
β βββ audit_logs.jsonl # System audit logs (JSONL format)
β βββ policies.json # File access policies
β βββ users.json # User accounts and attributes
βββ .github/ # GitHub templates and workflows
β βββ ISSUE_TEMPLATE/
β βββ bug_report.md
β βββ feature_request.md
βββ .env.example # Environment configuration template
βββ .gitignore # Git ignore patterns
βββ requirements.txt # Python dependencies
βββ LICENSE # License information
βββ README.md # This file
- Python 3.8 or higher
- pip (Python package installer)
- Modern web browser with WebSocket support
git clone https://github.com/neelshha/kosh.git
cd koshpython -m venv venv
source venv/bin/activate # On macOS/Linux
# or
venv\Scripts\activate # On Windows
pip install -r requirements.txtThe application works with default settings, but you can customize it:
cp .env.example .env
# Edit .env file to customize settingsAvailable environment variables:
KOSH_SECRET_KEY: Flask secret key (change in production)KOSH_DEBUG: Enable debug mode (default: True)KOSH_HOST: Host to bind to (default: 0.0.0.0)KOSH_PORT: Port to run on (default: 7130)KOSH_AUDIT_RETENTION_DAYS: Days to keep audit logs (default: 60)
python -m app.appThe application will:
- Auto-create necessary directories (
data/,app/uploads/) - Generate encryption keys if they don't exist
- Initialize default data files
- Start audit log cleanup background task
- Launch the server on
http://localhost:7130
You can access it from any device on the same local network.
- Admin User:
admin/pass - Regular Users: Default password is
passfor all users
- Navigate to
http://localhost:7130/adminafter logging in as admin - Manage users, attributes, and file policies
- View real-time audit logs and system activity
- Export audit logs for compliance
Kosh includes comprehensive real-time synchronization using WebSocket technology (Socket.IO):
- User Management: Add, edit, delete users with instant UI updates
- Policy Management: Create, modify, remove file access policies
- Attribute Management: Add/remove attributes from the global pool
- Bulk Operations: Mass user/policy operations with live feedback
- Audit Logs: Live audit trail of all system activities
user_added,user_updated,user_deletedpolicy_added,policy_updated,policy_deletedattribute_added,attribute_removedaudit_log_addedfor system activity tracking
Open multiple browser tabs as admin to see live synchronization:
- Login as admin in multiple tabs
- Perform operations in one tab
- Observe instant updates in all other tabs
# Admin room management
@socketio.on('join_admin')
def handle_join_admin():
user_id = session.get('user_id')
if user_id == 'admin':
join_room('admin_updates')
emit('joined_admin', {'message': 'Joined admin updates'})
# Real-time event emission
socketio.emit('user_added', {
'user': user_id,
'attributes': attributes,
'timestamp': datetime.now().strftime('%Y-%m-%d %H:%M:%S')
}, room='admin_updates')// Initialize connection
const socket = io();
socket.emit('join_admin');
// Listen for real-time events
socket.on('user_added', function(data) {
addUserToTable(data.user, data.attributes);
showToast(`User "${data.user}" added`, 'success');
});For production environments, configure specific CORS origins:
socketio = SocketIO(app, cors_allowed_origins=["https://yourdomain.com"])Real-time features work in all modern browsers supporting WebSocket:
- Chrome 16+, Firefox 11+, Safari 7+, Edge (all versions)
- Mobile browsers with WebSocket support
AES-256-CTR with HMAC-SHA256
All files are encrypted using industry-standard AES-256 in CTR mode with HMAC authentication:
- Encryption: AES-256-CTR mode for file content
- Integrity: HMAC-SHA256 for tamper detection
- Key Management: Auto-generated 256-bit keys stored securely
- IV Handling: Random 16-byte IV for each file
- Stream Processing: 64KB chunks for memory efficiency
Encryption Format:
[16-byte IV][Encrypted File Data][32-byte HMAC Tag]
Key Files:
data/aes_encryption.key- AES encryption key (auto-generated)data/aes_hmac.key- HMAC authentication key (auto-generated)
Attribute-Based Access Control (ABE Simulation)
- Files protected by attribute-based policies
- Users assigned multiple attributes
- Access granted only if user has ALL required attributes
- Policies stored as JSON for flexibility and transparency
Role-Based Permissions
- Admin: Full system access, user management, policy management
- Role Manager: Can assign attributes to users
- Regular Users: File upload/download based on attributes
- Password Hashing: Werkzeug's secure password hashing (PBKDF2)
- Session-Based Auth: Flask sessions with secure secret key
- Default Password:
passfor all users (change in production) - Password Change: Users can change their own passwords
- File upload validation (size, type, content)
- Attribute format validation (alphanumeric, underscore, dash only)
- Policy validation before file access
- HTML escaping to prevent XSS
- JSON schema validation for API requests
- Comprehensive Logging: All actions logged with user, timestamp, IP, and details
- JSONL Format: Efficient append-only audit log
- Auto-Cleanup: Configurable retention period (default: 60 days)
- Export Capability: Download audit logs for compliance
- Real-Time Streaming: Live audit logs in admin dashboard
All users have a consistent password structure:
- Default password:
passfor all users - Backward compatibility with legacy user formats
- Secure password change functionality available
The system automatically converts legacy user formats to the new dictionary format:
{
"username": {
"attributes": ["attr1", "attr2"],
"password": "hashed_password"
}
}For Production Deployment:
- Change Secret Key: Set
KOSH_SECRET_KEYenvironment variable - Change Default Passwords: Update all user passwords
- Disable Debug Mode: Set
KOSH_DEBUG=False - Use HTTPS: Deploy behind reverse proxy with SSL/TLS
- Restrict CORS: Configure specific origins in production
- Network Isolation: Use on trusted local network only
- File Permissions: Ensure proper permissions on
data/directory - Regular Backups: Backup
data/directory regularly - Monitor Audit Logs: Review logs for suspicious activity
- Update Dependencies: Keep Python packages up to date
- Not for Public Internet: Designed for LAN use only
- JSON Storage: Not suitable for large-scale deployments
- ABE Simulation: Uses policy-based access, not cryptographic ABE
- File Size: Large files may impact performance (default max: 5GB)
Please report security vulnerabilities by creating an issue with the "security" label.
Supported Versions:
| Version | Supported |
|---|---|
| 5.1.x | β |
| 5.0.x | β |
| 4.0.x | β |
| < 4.0 | β |
Include in your report:
- Clear description of the vulnerability
- Steps to reproduce
- Potential impact assessment
- Suggested mitigation if known
Kosh follows a modular architecture with clear separation of concerns:
Core Application (app.py)
- Flask routes for authentication, file operations, and admin functions
- WebSocket event handlers for real-time features
- 30+ endpoints for complete application functionality
- Background audit log cleanup thread
Configuration Module (config.py)
Centralizes all application settings:
- Directory paths (uploads, data, templates, static)
- File paths (users, policies, attributes, audit logs, encryption keys)
- Application settings (secret key, debug mode, host, port)
- Security settings (audit retention, default password)
- File upload settings (max size, allowed extensions)
- Encryption settings (IV size, chunk size, tag size)
Utility Module (utils.py)
Shared helper functions:
safe_load_json(): Safe JSON file loading with error handlingparse_and_validate_attrs(): Attribute input normalization and validationlog_audit(): Comprehensive audit logging with WebSocket emissionhas_role(): Role-based permission checkinginitialize_data_files(): Bootstrap default data filesvalidate_file_upload(): File upload validationget_user_files(): User-accessible file listing with ABE filteringnormalize_user_data(): Legacy/current user format normalizationemit_socketio_event(): Centralized WebSocket event emissiondelete_file_and_policy(): File deletion with policy cleanup
Attribute Management Module (attribute_management.py)
Dedicated blueprint for attribute operations:
/admin/add_attribute: Add global attributes (admin/role_manager)/admin/remove_attribute: Remove attributes with validation/role_manager/assign_attributes: Delegated attribute assignment- Real-time WebSocket events for all operations
- Comprehensive audit logging
Crypto Module
-
aes.py: AES-256-CTR encryption with HMAC-SHA256 authenticationencrypt(): Stream-based file encryptiondecrypt(): Stream-based file decryption with integrity verification- Auto-generates encryption keys on first run
-
abe_simulator.py: Policy-based access controlget_user_attributes(): Retrieves user attributes from users.jsoncheck_access(): Validates if user satisfies policy requirements- Supports legacy and current user data formats
Modular JavaScript Structure
The frontend follows a component-based architecture with three layers:
1. Components (static/shared/components/)
Reusable UI components:
modal.js: Generic modal dialog systemtoast.js: Toast notification componentnotification-manager.js: Centralized notification system
2. Modules (static/shared/modules/)
Feature-specific functionality:
realtime-manager.js: WebSocket connection and event handlinguser-manager.js: User CRUD operationsattribute-manager.js: Global attribute managementpolicy-manager.js: File access policy managementfile-manager.js: Admin file managementdashboard-file-manager.js: User file listing and operationsupload-manager.js: File upload with policy definitionpassword-manager.js: Password change functionalityaudit-manager.js: Audit log viewing and filteringrole-manager.js: Role assignment interfacerole-manager-attribute.js: Delegated attribute assignment
3. Utilities (static/shared/utils/)
Helper functions:
ui-helpers.js: Common UI manipulation functionsadmin-links.js: Admin navigation helpers
Dashboard-Specific Assets
admin/: Admin dashboard CSS, JS, and Tailwind configdashboard/: User dashboard CSS, JS, and Tailwind configcommon/: Favicons, PWA manifest, icons
JSON-Based Storage
Simple, file-based data persistence:
users.json - User accounts with attributes and passwords
{
"username": {
"attributes": ["attr1", "attr2"],
"password": "hashed_password"
}
}attributes.json - Global attribute pool
["finance", "engineering", "hr", "executive"]policies.json - File access policies
{
"encrypted_filename.enc": {
"policy": ["finance", "executive"],
"key": "encrypted_file_key",
"uploader": "admin",
"timestamp": "2025-11-07 10:30:45"
}
}audit_logs.jsonl - Activity logs (JSON Lines format)
{"user": "admin", "action": "add_user", "details": "Added user: john", "time": "2025-11-07 10:30:45", "ip": "127.0.0.1"}File Upload Flow:
- User selects file and defines access policy
- Frontend validates file and sends to
/uploadendpoint - Backend encrypts file with AES-256-CTR
- Generates encrypted file key with policy
- Stores encrypted file in
app/uploads/ - Saves policy metadata to
policies.json - Logs action to audit log
- Emits WebSocket event to update all connected clients
File Download Flow:
- User requests file via
/download/<filename> - Backend loads policy from
policies.json - ABE simulator checks if user has required attributes
- If authorized, decrypts file in memory
- Streams decrypted file to user
- Logs download action to audit log
Real-Time Update Flow:
- Admin performs action (add user, update policy, etc.)
- Backend processes request and updates data files
- Logs action to
audit_logs.jsonl - Emits WebSocket event with update data
- All connected admin clients receive event
- Frontend modules update UI reactively
- Toast notification confirms action
Attribute-Based Access Control:
- Users assigned attributes (e.g., "finance", "engineering")
- Files protected by policies requiring specific attributes
- Access granted only if user has ALL required attributes
- Supports comma-separated attribute lists
- ABE simulation provides granular access control without cryptographic ABE
Role-Based Administration:
- Admin: Full system access
- Role Manager: Can manage user attributes
- Regular Users: Upload/download files based on attributes
- Role delegation enables distributed administration
Audit Trail:
- All actions logged with user, timestamp, IP, and details
- JSONL format for efficient append and stream processing
- Auto-cleanup after configurable retention period (default: 60 days)
- Export functionality for compliance reporting
- Real-time log streaming to admin dashboard
The application features a well-structured dashboard system with separated concerns:
Located at /admin, provides comprehensive administrative functionality:
Features:
- User management (add, edit, delete, bulk operations)
- Attribute management (global attribute pool)
- Policy management (file access control)
- Role assignment (role_manager permissions)
- File management (view all files, delete)
- Audit log viewing and export
- Real-time updates via WebSocket
Structure:
app/static/admin/
βββ admin.css # Admin-specific styles
βββ admin-dashboard.js # Main admin controller
βββ tailwind.config.js # Tailwind configuration
Located at /dashboard, provides user-facing functionality:
Features:
- View accessible files based on attributes
- Upload files with policy definition
- Download authorized files
- Delete own uploaded files
- Change password
- Real-time file list updates
Structure:
app/static/dashboard/
βββ dashboard.css # User dashboard styles
βββ dashboard.js # Main dashboard controller
βββ dashboard-tailwind.config.js # Tailwind configuration
Reusable components and modules used across both dashboards:
app/static/shared/
βββ components/ # UI components
β βββ modal.js # Generic modal system
β βββ toast.js # Toast notifications
β βββ notification-manager.js
βββ modules/ # Feature modules
β βββ realtime-manager.js # WebSocket handling
β βββ user-manager.js # User CRUD
β βββ attribute-manager.js
β βββ policy-manager.js
β βββ file-manager.js
β βββ upload-manager.js
β βββ password-manager.js
β βββ audit-manager.js
β βββ role-manager.js
β βββ role-manager-attribute.js
β βββ dashboard-file-manager.js
βββ utils/ # Helper utilities
βββ ui-helpers.js
βββ admin-links.js
- β Separation of Concerns: CSS, JavaScript, and HTML in separate files
- β Reusability: Shared components across admin and user dashboards
- β Maintainability: Easy to locate and modify specific functionality
- β Performance: Better caching and reduced inline scripts
- β Scalability: Easy to add new features and components
- β Developer Experience: Better code readability and debugging
GET /- Login pagePOST /login- User authenticationGET /logout- End user session
GET /dashboard- Main user dashboard (shows accessible files)GET /api/files- Get list of files user can access (JSON)POST /change_password- Change user passwordPOST /upload- Upload and encrypt file with policyGET /download/<filename>- Download and decrypt filePOST /delete_file- Delete user's uploaded file
GET /admin- Admin dashboardPOST /admin/add_user- Create new userPOST /admin/edit_user/<user_id>- Update user informationGET /admin/delete_user/<user_id>- Delete single user (legacy)POST /admin/delete_user- Delete user with audit logPOST /admin/bulk_delete_users- Delete multiple usersPOST /admin/update_user_roles- Assign roles to usersPOST /admin/bulk_set_attrs- Bulk assign attributes to users
POST /admin/add_policy- Create file access policyPOST /admin/edit_policy/<file>- Update file policyGET /admin/delete_policy/<file>- Delete single policy (legacy)POST /admin/delete_policy- Delete policy with audit logPOST /admin/bulk_delete_policies- Delete multiple policiesPOST /admin/delete_file- Admin delete file with policy
POST /admin/add_attribute- Add global attributePOST /admin/remove_attribute- Remove global attributePOST /role_manager/assign_attributes- Role manager attribute assignment
GET /admin/download_audit_logs- Export audit logs (JSON)
Connection Events:
connect- Client connection establisheddisconnect- Client disconnectedjoin_admin- Join admin updates roomleave_admin- Leave admin updates roomjoin_dashboard- Join dashboard updates roomleave_dashboard- Leave dashboard updates room
Server-Emitted Events:
user_added- New user createduser_updated- User information changeduser_deleted- User removedusers_bulk_deleted- Multiple users deleteduser_attributes_updated- User attributes changedpolicy_added- New file policy createdpolicy_updated- Policy modifiedpolicy_deleted- Policy removedpolicies_bulk_deleted- Multiple policies deletedattribute_added- Global attribute addedattribute_removed- Global attribute removedaudit_log_added- New audit log entryfile_deleted- File removed
- Python: Follow PEP8 standards
- JavaScript: Use ES6+ features, modular architecture
- CSS: Use Tailwind classes, organized structure
- HTML: Semantic HTML5 elements with proper ARIA attributes
# Emit events after data changes
from flask import current_app
socketio = current_app.extensions.get('socketio')
utils.emit_socketio_event(socketio, 'custom_event', data, room='admin_updates')// Listen for events and update UI
socket.on('custom_event', function(data) {
updateUIElement(data);
showToast('Action completed', 'success');
});- Use descriptive names:
user_addednotua - Include entity type:
policy_updatednotupdated - Use past tense:
file_deletednotfile_delete
- Always escape HTML to prevent XSS
- Use smooth animations for better UX
- Show loading states during operations
- Provide user feedback via toast notifications
- Event Batching: Efficient handling of rapid changes
- Memory Management: Limited audit log retention in UI
- Connection Pooling: Optimized WebSocket connections
- Selective Updates: Only affected UI elements are updated
- Stream Processing: Large files encrypted/decrypted in chunks (64KB)
Testing Real-Time Features:
Open multiple browser tabs as admin to see live synchronization:
- Login as admin in multiple tabs
- Perform operations in one tab
- Observe instant updates in all other tabs
Testing File Access Control:
- Create users with different attributes
- Upload files with varying policy requirements
- Login as different users to verify access control
- Check audit logs for all operations
We welcome contributions from the community! Whether it's fixing a bug, improving documentation, or adding a new feature, all contributions are welcome.
- Fork the Repository: Click the Fork button in the top-right corner
- Clone your fork locally:
git clone https://github.com/<your-username>/kosh.git cd kosh
- Set upstream remote (recommended):
git remote add upstream https://github.com/neelshha/kosh.git
- Create a feature branch:
git checkout -b feature/<short-description>
Follow Conventional Commits:
<type>: <short description>
feat: add real-time file upload progress
fix: resolve WebSocket connection issues
docs: update installation instructions
refactor: restructure dashboard components
style: formatting changes, no code logic updates
test: adding or updating tests
- Follow existing code style and patterns
- Use Bootstrap/Tailwind classes instead of inline CSS
- Keep code modular and reusable
- Avoid committing secrets, API keys, or passwords
- Include comments for complex logic
- Test your changes across different browsers
- π Bug fixes: Help us squash bugs
- β¨ New features: Add exciting new functionality
- π Documentation: Improve our docs
- π¨ UI/UX: Enhance the user interface
- β‘ Performance: Optimize existing code
- π§ͺ Testing: Add or improve tests
Use our GitHub issue templates for:
- Clear description of the bug
- Steps to reproduce the behavior
- Expected vs actual behavior
- Screenshots if applicable
- Environment details (OS, browser, version)
- Problem description or motivation
- Proposed solution
- Alternative solutions considered
- Additional context or mockups
- Ensure code quality: Make sure your code is tested and follows our guidelines
- Update documentation: Include relevant documentation updates
- Test thoroughly: Verify your changes work across different scenarios
- Push your branch:
git push origin feature/<branch-name>
- Open a Pull Request: Provide a clear title and description, link related issues
- Set up virtual environment as described in Getting Started
- Install development dependencies if any
- Run the application locally to test changes
- Use multiple browser tabs to test real-time features
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2025 Kavish Shah
Kosh is designed for educational purposes and internal LAN use. It should not be exposed to the public internet without proper security hardening, including:
- HTTPS/TLS encryption
- Reverse proxy configuration
- Network firewall rules
- Regular security audits
- Strong authentication mechanisms
The authors are not responsible for any data loss, security breaches, or other issues arising from the use of this software.
Special thanks to all contributors who have helped make Kosh better:
- Real-time features implementation: WebSocket integration for live updates
- Modular architecture: Dashboard restructuring and component-based design
- Security enhancements: Encryption implementation and audit logging
- Documentation improvements: Comprehensive README and issue templates
- Bug fixes and testing: Community feedback and contributions
- Flask: Web framework foundation
- Flask-SocketIO: Real-time WebSocket communication
- cryptography: Robust encryption library
- Tailwind CSS: Modern, responsive UI design
- Socket.IO: Client-side WebSocket library
Kosh was created as a capstone project to demonstrate:
- Secure file sharing without cloud dependency
- Attribute-based access control concepts
- Real-time web application architecture
- Modern web development practices
For questions, bug reports, or feature requests:
- Create an issue on GitHub using our templates
- Check existing issues for similar problems
- Join discussions in existing issues
Scenario: Share financial reports only with finance and executive teams
- Create attributes:
finance,executive - Create users:
- John (finance department): attributes =
finance - Sarah (CEO): attributes =
executive, finance
- John (finance department): attributes =
- Upload report with policy:
finance, executive - Result: Both John and Sarah can access the file
Scenario: Share project files with team members
- Create attributes:
project_alpha,engineering,design - Upload design files with policy:
project_alpha, design - Upload code files with policy:
project_alpha, engineering - Only users with both project_alpha AND the respective attribute can access
Scenario: HR manager needs to assign attributes to employees
- Admin assigns
role_managerrole to HR user - HR user can now assign attributes to other users
- HR user cannot add/remove global attributes (admin only)
- All changes logged in audit trail
Problem: ModuleNotFoundError or import errors
Solution:
# Ensure you're in the virtual environment
source venv/bin/activate # On macOS/Linux
venv\Scripts\activate # On Windows
# Reinstall dependencies
pip install -r requirements.txtProblem: Application only accessible from localhost
Solution:
- Ensure
KOSH_HOST=0.0.0.0(binds to all interfaces) - Check firewall settings allow port 7130
- Connect from device on same network:
http://<server-ip>:7130
Problem: Large file uploads fail or timeout
Solution:
- Check file size is under limit (default: 5GB)
- Ensure sufficient disk space in
app/uploads/ - Check file extension is in
ALLOWED_EXTENSIONS
Problem: Real-time updates stop working
Solution:
- Check browser console for WebSocket errors
- Refresh the page to reconnect
- Verify network stability
- Check if reverse proxy is configured for WebSocket support
Problem: audit_logs.jsonl consuming too much disk space
Solution:
- Adjust
KOSH_AUDIT_RETENTION_DAYSto shorter period - Wait for automatic cleanup (runs every 24 hours)
- Manually delete old entries (backup first)
Problem: Forgot admin password
Solution:
- Edit
data/users.json - Change admin password to default:
{ "admin": { "attributes": [], "password": "pass" } } - Restart application
- Login with
admin/pass - Change password immediately
Problem: Can't create files in data/ or app/uploads/
Solution:
# Fix directory permissions
chmod 755 data/
chmod 755 app/uploads/Problem: Admin dashboard doesn't update in real-time
Solution:
- Open browser developer tools, check for JavaScript errors
- Verify WebSocket connection in Network tab
- Clear browser cache and reload
- Check if browser supports WebSocket (all modern browsers do)
Planned enhancements for future versions:
- Real-time file upload progress indicators with percentage
- Live user activity indicators (who's online, what they're doing)
- Real-time system health monitoring (disk space, memory usage)
- Push notifications for critical events
- File download progress tracking
- Real-time file preview for supported formats
- Two-factor authentication (2FA) support
- Cryptographic ABE implementation (replacing simulation)
- End-to-end encryption for file keys
- Password strength requirements and validation
- Session timeout and automatic logout
- IP-based access control
- Rate limiting for API endpoints
- Advanced RBAC with custom roles
- Advanced filtering with real-time updates
- Search functionality for files and users
- File tagging and categorization
- Favorites/starred files
- File sharing links with expiration
- Drag-and-drop file upload
- Batch file operations
- File versioning and history
- User groups for easier attribute management
- Policy templates for common access patterns
- Scheduled policy expiration
- User import/export (CSV, JSON)
- Advanced audit reporting with charts
- Email notifications for admin events
- Backup and restore functionality
- Multi-admin support with granular permissions
- Database backend option (SQLite, PostgreSQL)
- Docker containerization
- Kubernetes deployment support
- RESTful API with OpenAPI documentation
- GraphQL API for flexible queries
- CLI tool for administration
- Unit and integration tests
- Performance benchmarking
- Enhanced mobile responsiveness
- Progressive Web App (PWA) features
- Native mobile app (iOS/Android)
- Offline support for file listing
- Accessibility improvements (WCAG 2.1 AA compliance)
- Dark mode theme
- Multi-language support (i18n)
- File preview for images, PDFs, documents
- Thumbnail generation for images/videos
- File compression before encryption
- Deduplication to save storage
- Automatic file expiration
- File size quotas per user
- Advanced MIME type detection
- LDAP/Active Directory integration
- OAuth2/SAML authentication
- Webhook support for external integrations
- Plugin system for custom features
- External storage backends (S3, Azure Blob)
- Virus scanning integration (ClamAV)
- Analytics and reporting dashboard
- Comprehensive API documentation
- SDK for Python, JavaScript, Go
- Terraform provider for infrastructure as code
- Developer documentation and examples
- Contribution guidelines and templates
- Automated deployment scripts
Contributions welcome! If you'd like to work on any of these features, please create an issue or submit a pull request.
Happy file sharing with Kosh! ππ