Skip to content

πŸ“‚ Self-hostable Managed File Transfer solution built with Go, featuring API keys, comprehensive audit logging, and real-time WebSocket notifications for secure file exchange.

License

Notifications You must be signed in to change notification settings

JIPrettyCool/LunaTransfer

Folders and files

NameName
Last commit message
Last commit date
Mar 22, 2025
Mar 13, 2025
Mar 17, 2025
Mar 22, 2025
Mar 16, 2025
Mar 17, 2025
Mar 16, 2025
Mar 11, 2025
Mar 17, 2025
Mar 11, 2025
Mar 13, 2025
Mar 13, 2025
Mar 22, 2025
Mar 13, 2025

Repository files navigation

LunaTransfer

Self Hostable Managed File Transfer app

Configuration

LunaTransfer can be configured by editing the config file before startup. The following settings can be customized:

  • Port number
  • Storage path
  • Log directory
  • JWT secret and expiration time
  • Rate limiting settings

API Usage Examples

Initial Setup and Authentication

Initial Setup (Admin signup)

curl -X POST http://localhost:8080/setup \
  -H "Content-Type: application/json" \
  -d '{
    "username": "admin",
    "password": "AdminPassword123!",
    "email": "[email protected]"
  }'

Signup

curl -X POST http://localhost:8080/signup \
  -H "Content-Type: application/json" \
  -d '{"username":"test1","password":"Test1Password123","email":"[email protected]","role":"user"}'

Login (Get JWT Token)

curl -X POST http://localhost:8080/login \
  -H "Content-Type: application/json" \
  -d '{"username":"test1","password":"Test1Password123"}'

Logout

curl -X POST http://localhost:8080/logout \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Refresh Token

curl -X POST http://localhost:8080/api/refresh \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

File Operations

Upload File

curl -X POST http://localhost:8080/api/upload \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -F "file=@/path/to/your/file.txt" \
  -F "path=photos/vacation2023"

List Files

curl -X GET "http://localhost:8080/api/files?path=photos/vacation2023" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Search Files

curl -X GET "http://localhost:8080/api/search?term=project" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

  # Search in specific directory
curl -X GET "http://localhost:8080/api/search?term=report&path=documents" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

# Search by file type (extension)
curl -X GET "http://localhost:8080/api/search?term=data&type=csv" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

# Search by file size (in bytes)
curl -X GET "http://localhost:8080/api/search?term=video&minSize=1000000&maxSize=5000000" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

# Search by date modified
curl -X GET "http://localhost:8080/api/search?term=report&after=2005-08-08&before=2005-08-08" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

# Combining multiple filters
curl -X GET "http://localhost:8080/api/search?term=presentation&path=work&type=pptx&minSize=500000" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Download File

curl -X GET http://localhost:8080/api/download/file.txt \
  -H "Authorization: Bearer YOUR_JWT_KEY" \
  --output downloaded_file.txt

Delete File

curl -X DELETE http://localhost:8080/api/delete/file.txt \
  -H "Authorization: Bearer YOUR_JWT_KEY"

Create Directory

curl -X POST http://localhost:8080/api/directory \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"path":"photos", "name":"vacation2023"}'

Admin Operations

List Users (Admin Only)

curl -X GET http://localhost:8080/api/admin/users \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN"

Delete User (Admin Only)

curl -X DELETE http://localhost:8080/api/admin/users/username \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN"

System Stats (Admin Only)

curl -X GET http://localhost:8080/api/admin/system/stats \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN"

Groups

Create Group (Admin Only)

curl -X POST http://localhost:8080/api/admin/groups \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Marketing Team",
    "description": "Group for marketing department files"
  }'

List Groups (Admin Only)

curl -X GET http://localhost:8080/api/admin/groups \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN"

Add User to Group (Admin Only)

curl -X POST "http://localhost:8080/api/admin/groups/YOUR_GROUP_ID/members" \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "user1",
    "role": "member"
  }'

Remove User from Group (Admin Only)

curl -X DELETE "http://localhost:8080/api/admin/groups/YOUR_GROUP_ID/members/username" \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN"

List Group Members (Admin Only)

curl -X GET "http://localhost:8080/api/admin/groups/YOUR_GROUP_ID/members" \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN"

Upload File to Group Directory (Group Members Only)

curl -X POST http://localhost:8080/api/upload/group \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -F "file=@/path/to/your/file.txt" \
  -F "groupId=YOUR_GROUP_ID" \
  -F "path=reports/monthly"

Download File from Group Directory (Group Members Only)

curl -X GET http://localhost:8080/api/download/groups/YOUR_GROUP_ID/path/to/file.txt \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  --output downloaded_file.txt

List Files in Group Directory (Group Members Only)

curl -X GET "http://localhost:8080/api/files?path=groups/YOUR_GROUP_ID/reports" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Add User to Group with Specific Role (Admin Only)

curl -X POST "http://localhost:8080/api/admin/groups/YOUR_GROUP_ID/members" \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "user1",
    "role": "contributor"
  }'
Group Role Permissions

LunaTransfer supports three levels of group roles:

  • admin: Can manage group members and has full access to all group files
  • contributor: Can upload, modify, and download files but cannot manage members
  • reader: Can only view and download files

Share a File with Another Group

curl -X POST http://localhost:8080/api/share \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "file_path": "path/to/file.txt",
    "source_group": "SOURCE_GROUP_ID",
    "target_group": "TARGET_GROUP_ID",
    "permission": "read"
  }'

List Files Shared with a Group

curl -X GET "http://localhost:8080/api/shared?groupId=YOUR_GROUP_ID" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Remove File Sharing

curl -X DELETE http://localhost:8080/api/share/SHARE_ID \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Misc

Get User Dashboard

curl -X GET http://localhost:8080/api/dashboard \
  -H "Authorization: Bearer YOUR_JWT_KEY"

WebSocket Connection (for real-time notifications)

# Using a WebSocket client like wscat
wscat -c "ws://localhost:8080/ws" -H "Authorization: Bearer YOUR_JWT_KEY"
Notification Types
  • CONNECTED: Sent when a WebSocket connection is established
  • FILE_UPLOADED: Sent when a new file is uploaded
  • FILE_DELETED: Sent when a file is deleted
  • SHARE_CREATED: Sent when a file is shared with a group
  • SHARE_REMOVED: Sent when a file share is removed

TODO

View my Notion page

About

πŸ“‚ Self-hostable Managed File Transfer solution built with Go, featuring API keys, comprehensive audit logging, and real-time WebSocket notifications for secure file exchange.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages