mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-28 16:58:31 +01:00
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
23 lines
687 B
Go
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
|
|
}
|
|
}
|