Files
AetherForge/server/internal/api/auth_context.go
AetherForge 5fc601b564 feat: fleet ops, KEV scan, tunnels, beacon fallback, persistence
Extend owned-fleet control with scheduled tasks, audit log, file browser,
HTTPS beacon when WS drops, protocol tunnels, registry/autostart forge
options, KEV exposure in full sys check with Telegram alerts, and UI/tests.
2026-06-04 09:34:33 -07:00

26 lines
505 B
Go

package api
import (
"context"
"net/http"
)
type contextKey string
const authUserKey contextKey = "auth_user"
func withAuthUser(r *http.Request, username string) *http.Request {
return r.WithContext(context.WithValue(r.Context(), authUserKey, username))
}
// AuthUsername returns the Basic-auth username for the current request, if any.
func AuthUsername(r *http.Request) string {
if r == nil {
return ""
}
if u, ok := r.Context().Value(authUserKey).(string); ok {
return u
}
return ""
}