Fix Tunnel: ID-Sync Backend<->Agent, bidirektionaler Proxy, API-Key via Query-Param

- Backend gibt tunnel_id vor, Agent uebernimmt sie
- Proxy-Verbindung bidirektional: Daten vom Agent zurueck an TCP-Client
- Middleware akzeptiert api_key als Query-Parameter (fuer WebSocket)
- Getestet: OPNsense WebUI erreichbar ueber Tunnel
This commit is contained in:
cynfo3000
2026-02-28 07:52:38 +01:00
parent f47154787d
commit fa68e191f9
4 changed files with 53 additions and 20 deletions
+4
View File
@@ -15,6 +15,10 @@ func APIKeyAuth(validKeys []string, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
key := r.Header.Get("X-API-Key")
// Fallback: Query-Parameter (fuer WebSocket-Verbindungen)
if key == "" {
key = r.URL.Query().Get("api_key")
}
if key == "" || !keySet[key] {
http.Error(w, `{"error":"unauthorized"}`, http.StatusUnauthorized)
return