Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Fix OIDC token refresh bypass and guard AISettingsHandler nil path

rcourtman89577fe533e7
diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.go
index e0b0972caa..bca6436c34 100644
--- a/internal/api/ai_handlers.go
+++ b/internal/api/ai_handlers.go
@@ -160,6 +160,9 @@ func (h *AISettingsHandler) GetAIService(ctx context.Context) *ai.Service {
}
// Create new service for this tenant
+ if h.mtPersistence == nil {
+ return h.ensureLegacyAIService()
+ }
persistence, err := h.mtPersistence.GetPersistence(orgID)
if err != nil {
log.Warn().Str("orgID", orgID).Err(err).Msg("Failed to get persistence for AI service")
diff --git a/internal/api/auth.go b/internal/api/auth.go
index bdf2d658e1..fcfb0db413 100644
--- a/internal/api/auth.go
+++ b/internal/api/auth.go
@@ -889,6 +889,13 @@ func extractAndStoreAuthContext(cfg *config.Config, mtm *monitoring.MultiTenantM
if cookie, err := r.Cookie("pulse_session"); err == nil && cookie.Value != "" {
if ValidateSession(cookie.Value) {
if username := GetSessionUsername(cookie.Value); username != "" {
+ // Trigger token refresh if access token is near expiry
+ session := GetSessionStore().GetSession(cookie.Value)
+ if session != nil && session.OIDCRefreshToken != "" {
+ if time.Now().Add(5 * time.Minute).After(session.OIDCAccessTokenExp) {
+ go refreshOIDCSessionTokens(cfg, cookie.Value, session)
+ }
+ }
return attachUserContext(r, username)
}
}