mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-29 17:21:13 +01:00
Revalidate the admitted token before every websocket data frame, queued flush and idle ping. Share the current-tenant snapshot validator without mutating a returned HTTP request. Keep session, origin, licensing and wanted monitoring reads unchanged; exercise real token deletion, client cleanup and independent subscribers. Change-source: pulse-maintainer
21 lines
516 B
Go
21 lines
516 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()))
|
|
if revalidate == nil {
|
|
return nil
|
|
}
|
|
return func() bool {
|
|
_, ok := revalidate()
|
|
return ok
|
|
}
|
|
}
|