Implement secubox-master-link (backend) and luci-app-master-link (LuCI frontend) for secure node onboarding into the SecuBox mesh via HMAC-SHA256 join tokens, blockchain-backed peer trust, and gigogne (nested) hierarchy with depth limiting. Backend provides: token management, join/approve/reject protocol, IPK bundle serving, CGI API endpoints, and a dark-themed landing page for new nodes. Frontend provides a 3-tab LuCI view (overview, join requests, mesh tree) with RPCD integration. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
43 lines
945 B
Bash
43 lines
945 B
Bash
#!/bin/sh
|
|
# Master-Link API - Generate join token
|
|
# POST /api/master-link/token
|
|
# Auth: Local only (127.0.0.1 or LuCI session)
|
|
|
|
echo "Content-Type: application/json"
|
|
echo "Access-Control-Allow-Origin: *"
|
|
echo "Access-Control-Allow-Methods: POST, OPTIONS"
|
|
echo "Access-Control-Allow-Headers: Content-Type"
|
|
echo ""
|
|
|
|
# Handle CORS preflight
|
|
if [ "$REQUEST_METHOD" = "OPTIONS" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
# Load library
|
|
. /usr/lib/secubox/master-link.sh 2>/dev/null
|
|
|
|
# Auth check - local only
|
|
if ! ml_check_local_auth; then
|
|
echo '{"error":"unauthorized","message":"Token generation requires local access"}'
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$REQUEST_METHOD" != "POST" ]; then
|
|
echo '{"error":"method_not_allowed"}'
|
|
exit 0
|
|
fi
|
|
|
|
# Check role
|
|
local_role=$(uci -q get master-link.main.role)
|
|
case "$local_role" in
|
|
master|sub-master)
|
|
;;
|
|
*)
|
|
echo '{"error":"not_master","message":"Only master or sub-master nodes can generate tokens"}'
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
ml_token_generate
|