Files
Pulse/internal/api/websocket_auth.go
pulse-triage[bot] 939dc161b5 Preserve valid authentication when organization access ends
Separate organization denial from credential expiry in pending HTTP replies and monitoring sockets. Keep selected History and background reads in their original organization; retain explicit reload recovery after a deliberate regrant.

Contract-Neutral: Repairs existing least-privilege and saved-state guarantees; no alert detector, notification obligation, agent lifecycle, storage recovery, paid grant or scalability contract changes. API and security transport semantics are documented and directly tested.
Change-source: pulse-maintainer
2026-11-07 08:04:39 +00:00

23 lines
687 B
Go

package api
import (
"net/http"
"github.com/rcourtman/pulse-go-rewrite/internal/config"
)
func monitoringWebSocketAuthorization(cfg *config.Config, req *http.Request) func() bool {
// The socket writer outlives this HTTP request. Give it an immutable
// request copy, not one its returning middleware may still be observing.
revalidate := monitoringTokenSnapshotRevalidator(cfg, req.Clone(req.Context()))
// Organization access is checked separately by the writer, so valid
// authentication does not turn membership withdrawal into a login failure.
if revalidate == nil {
return sessionReadRevalidator(req)
}
return func() bool {
_, ok := revalidate()
return ok
}
}