kosh

Kosh - LAN-Based Secure File Sharing with Simulated ABE

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.

🌟 Table of Contents

🌐 Features

Core Features

Real-Time Features

Security Features

πŸ“ Project Structure

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

πŸš€ Getting Started

Prerequisites

1. Clone the Repository

git clone https://github.com/neelshha/kosh.git
cd kosh

2. Set Up Virtual Environment

python -m venv venv
source venv/bin/activate        # On macOS/Linux
# or
venv\Scripts\activate           # On Windows
pip install -r requirements.txt

3. Run the Application

python -m app.app

The application will start on http://localhost:7130. You can access it from any device on the same local network.

4. Default Login Credentials

5. Admin Dashboard Access

πŸ”„ Real-Time Features

Kosh includes comprehensive real-time synchronization using WebSocket technology (Socket.IO):

Live Updates

WebSocket Events

Testing Real-Time Features

Open multiple browser tabs as admin to see live synchronization:

  1. Login as admin in multiple tabs
  2. Perform operations in one tab
  3. Observe instant updates in all other tabs

Technical Implementation

Backend (Flask-SocketIO)

# 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')

Frontend (JavaScript + Socket.IO)

// 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');
});

Configuration

For production environments, configure specific CORS origins:

socketio = SocketIO(app, cors_allowed_origins=["https://yourdomain.com"])

Browser Compatibility

Real-time features work in all modern browsers supporting WebSocket:

πŸ”’ Security

Encryption

Access Control

Security Features

Default Password Implementation

All users have a consistent password structure:

The system automatically converts legacy user formats to the new dictionary format:

{
  "username": {
    "attributes": ["attr1", "attr2"],
    "password": "pass"
  }
}

Reporting Security Vulnerabilities

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:

πŸ—οΈ Architecture

Modular Design

Kosh follows a modular architecture with clear separation of concerns:

Backend (Flask)

Frontend (JavaScript)

Data Layer

Dashboard Restructuring

The dashboard has been completely restructured for better maintainability:

Key Improvements

File Organization

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

Benefits Achieved

πŸ’» Development

Code Style Guidelines

Adding New Features

Backend Real-Time Events

# Emit events after data changes
socketio.emit('custom_event', data, room='admin_updates')

Frontend Event Handling

// Listen for events and update UI
socket.on('custom_event', function(data) {
    updateUIElement(data);
});

Event Naming Convention

UI Update Best Practices

Performance Considerations

Future Enhancement Opportunities

With the new modular structure, future improvements are easier:

🀝 Contributing

We welcome contributions from the community! Whether it’s fixing a bug, improving documentation, or adding a new feature, all contributions are welcome.

Getting Started

  1. Fork the Repository: Click the Fork button in the top-right corner
  2. Clone your fork locally:
    git clone https://github.com/<your-username>/kosh.git
    cd kosh
    
  3. Set upstream remote (recommended):
    git remote add upstream https://github.com/neelshha/kosh.git
    
  4. Create a feature branch:
    git checkout -b feature/<short-description>
    

Contribution Guidelines

Commit Message Format

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

Code Requirements

Types of Contributions

Issue Templates

Use our GitHub issue templates for:

Bug Reports

Feature Requests

Pull Request Process

  1. Ensure code quality: Make sure your code is tested and follows our guidelines
  2. Update documentation: Include relevant documentation updates
  3. Test thoroughly: Verify your changes work across different scenarios
  4. Push your branch:
    git push origin feature/<branch-name>
    
  5. Open a Pull Request: Provide a clear title and description, link related issues

Development Setup

  1. Set up virtual environment as described in Getting Started
  2. Install development dependencies if any
  3. Run the application locally to test changes
  4. Use multiple browser tabs to test real-time features

πŸ“‹ License

This project is licensed for educational and internal LAN use only.

Disclaimer

Kosh is designed for educational purposes and internal network use. It should not be exposed to the public internet without proper security hardening.


πŸ™ Acknowledgments

Thank you to all contributors who have helped make Kosh better:

πŸ“ž Support

For questions, bug reports, or feature requests:

πŸš€ Future Roadmap

Planned enhancements for future versions:


Happy file sharing with Kosh! πŸ”πŸ“