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.
- Features
- Project Structure
- Getting Started
- Real-Time Features
- Security
- Architecture
- Development
- Contributing
- License
- 🔒 AES-encrypted file uploads and downloads with robust encryption
- 🧑💻 User-based attribute system for granular access control
- 🔐 Simulated ABE access control using JSON policies
- 🎛️ Admin dashboard for managing users, attributes, and file policies
- 💡 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)
- 🔄 Live synchronization across all admin sessions using WebSocket
- 📱 Toast notifications for user feedback
- 🌐 Auto-reconnection and connection status indicators
- 📝 Live audit logs for all system activities
- ⚡ Bulk operations with real-time updates
- 🔐 AES-256 encryption for all file operations
- 🛡️ Attribute-based access control with flexible policies
- 👥 User authentication with session management
- 🔍 Audit logging for all administrative actions
- 🚫 CSRF protection and input validation
kosh/
├── app/
│ ├── app.py # Main Flask application
│ ├── __init__.py # Package initialization
│ ├── attribute_management.py # Attribute management logic
│ ├── crypto/
│ │ ├── aes.py # AES encryption/decryption
│ │ └── abe_simulator.py # JSON-based ABE simulation
│ ├── static/
│ │ ├── admin/ # Admin dashboard assets
│ │ │ ├── admin.css
│ │ │ ├── admin-dashboard.js
│ │ │ └── tailwind.config.js
│ │ ├── dashboard/ # User dashboard assets
│ │ │ ├── dashboard.css
│ │ │ ├── dashboard.js
│ │ │ └── dashboard-tailwind.config.js
│ │ ├── shared/ # Shared components and utilities
│ │ │ ├── components/
│ │ │ │ ├── modal.js
│ │ │ │ ├── notification-manager.js
│ │ │ │ └── toast.js
│ │ │ ├── modules/
│ │ │ │ ├── attribute-manager.js
│ │ │ │ ├── audit-manager.js
│ │ │ │ ├── dashboard-file-manager.js
│ │ │ │ ├── file-manager.js
│ │ │ │ ├── password-manager.js
│ │ │ │ ├── policy-manager.js
│ │ │ │ ├── realtime-manager.js
│ │ │ │ ├── upload-manager.js
│ │ │ │ └── user-manager.js
│ │ │ └── utils/
│ │ │ ├── admin-links.js
│ │ │ └── ui-helpers.js
│ │ └── common/ # Common assets (icons, favicons)
│ ├── templates/
│ │ ├── index.html # Login page
│ │ ├── dashboard.html # User dashboard
│ │ └── admin.html # Admin dashboard
│ ├── uploads/ # Encrypted file storage
│ └── user_keys/ # User key files
├── data/
│ ├── aes_encryption.key # AES encryption key
│ ├── aes_hmac.key # HMAC key for integrity
│ ├── attributes.json # Global attribute pool
│ ├── audit_logs.jsonl # System audit logs
│ ├── policies.json # File access policies
│ └── users.json # User accounts and attributes
├── .github/ # GitHub templates and workflows
│ └── ISSUE_TEMPLATE/
│ ├── bug_report.md
│ └── feature_request.md
├── requirements.txt # Python dependencies
└── 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.txtpython -m app.appThe application will start 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
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 encryption for all uploaded files
- HMAC verification for data integrity
- Secure key management with separate key files
- Attribute-Based Encryption (ABE) simulation using JSON policies
- Role-based permissions (admin vs regular users)
- Session-based authentication with Flask sessions
- All user inputs are validated and sanitized
- File uploads are encrypted before storage
- Admin operations require proper authentication
- WebSocket connections validate user sessions
All users have a consistent password structure:
- Default password:
passfor all users - Backward compatibility with legacy user formats
- Secure password change functionality
The system automatically converts legacy user formats to the new dictionary format:
{
"username": {
"attributes": ["attr1", "attr2"],
"password": "pass"
}
}Please report security vulnerabilities by creating an issue with the "security" label. We support the following 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:
- app.py: Main application with routes and WebSocket handlers
- crypto/: Encryption and ABE simulation modules
- attribute_management.py: Centralized attribute operations
- Modular Components: Reusable UI components (modals, notifications)
- Feature Modules: Specialized modules for file management, uploads, etc.
- Real-time Manager: WebSocket connection and event handling
- JSON-based storage: Simple file-based data persistence
- Structured policies: Metadata-rich file access policies
- Audit logging: Comprehensive activity tracking
The dashboard has been completely restructured for better maintainability:
- Separated concerns: CSS, JavaScript, and HTML in separate files
- Component-based structure: Reusable components and modules
- Performance optimizations: Better caching and loading strategies
- Modular architecture: Independent module development
app/static/
├── css/
│ └── dashboard.css # All dashboard styles
├── js/
│ ├── dashboard.js # Main dashboard controller
│ ├── config/
│ │ └── dashboard-tailwind.config.js # Tailwind configuration
│ ├── components/
│ │ └── notification-manager.js # Notification system
│ └── modules/
│ ├── dashboard-file-manager.js # File display and management
│ ├── upload-manager.js # File upload functionality
│ └── password-manager.js # Password change modal
- ✅ Maintainability: Easier 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
- 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
socketio.emit('custom_event', data, room='admin_updates')// Listen for events and update UI
socket.on('custom_event', function(data) {
updateUIElement(data);
});- 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
With the new modular structure, future improvements are easier:
- ✅ Unit testing individual modules
- ✅ Adding new file management features
- ✅ Implementing additional upload options
- ✅ Enhanced accessibility features
- ✅ Performance optimizations
- ✅ Theme customization
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 for educational and internal LAN use only.
Kosh is designed for educational purposes and internal network use. It should not be exposed to the public internet without proper security hardening.
Thank you to all contributors who have helped make Kosh better:
- Contributors to the real-time features implementation
- Dashboard restructuring and modular architecture improvements
- Security enhancements and bug fixes
- Documentation improvements and issue templates
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
Planned enhancements for future versions:
- Real-time file upload progress indicators
- Live user activity indicators
- Real-time system health monitoring
- Push notifications for critical events
- Advanced filtering with real-time updates
- Enhanced mobile responsiveness
- Multi-language support
- Advanced audit reporting
- API endpoints for external integrations
- Enhanced encryption options
Happy file sharing with Kosh! 🔐📁