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.

feat: Add kiosk mode support with read-only dashboard tokens

rcourtmanf29badbd1f30
diff --git a/frontend-modern/src/App.tsx b/frontend-modern/src/App.tsx
index 9ecf116bf0..1ae39f413a 100644
--- a/frontend-modern/src/App.tsx
+++ b/frontend-modern/src/App.tsx
@@ -858,6 +858,7 @@ function App() {
proxyAuthInfo={proxyAuthInfo}
handleLogout={handleLogout}
state={state}
+ tokenScopes={() => securityStatus()?.tokenScopes}
>
{props.children}
</AppLayout>
@@ -997,6 +998,7 @@ function AppLayout(props: {
proxyAuthInfo: () => { username?: string; logoutURL?: string } | null;
handleLogout: () => void;
state: () => State;
+ tokenScopes: () => string[] | undefined;
children?: JSX.Element;
}) {
const navigate = useNavigate();
@@ -1162,7 +1164,15 @@ function AppLayout(props: {
{ warning: 0, critical: 0 },
);
const activeAlertCount = breakdown.warning + breakdown.critical;
- return [
+
+ // Check if settings should be shown based on token scopes
+ // If no scopes (session auth), show settings
+ // If scopes include '*' (wildcard) or 'settings:read', show settings
+ const scopes = props.tokenScopes();
+ const hasSettingsAccess = !scopes || scopes.length === 0 ||
+ scopes.includes('*') || scopes.includes('settings:read');
+
+ const tabs = [
{
id: 'alerts' as const,
label: 'Alerts',
@@ -1173,7 +1183,11 @@ function AppLayout(props: {
breakdown,
icon: <BellIcon class="w-4 h-4 shrink-0" />,
},
- {
+ ];
+
+ // Only show settings tab if user has access
+ if (hasSettingsAccess) {
+ tabs.push({
id: 'settings' as const,
label: 'Settings',
route: '/settings',
@@ -1182,8 +1196,10 @@ function AppLayout(props: {
count: undefined,
breakdown: undefined,
icon: <SettingsIcon class="w-4 h-4 shrink-0" />,
- },
- ];
+ });
+ }
+
+ return tabs;
});
const handlePlatformClick = (platform: ReturnType<typeof platformTabs>[number]) => {
diff --git a/frontend-modern/src/components/Settings/APITokenManager.tsx b/frontend-modern/src/components/Settings/APITokenManager.tsx
index 95babb4453..6e67023490 100644
--- a/frontend-modern/src/components/Settings/APITokenManager.tsx
+++ b/frontend-modern/src/components/Settings/APITokenManager.tsx
@@ -15,6 +15,7 @@ import {
DOCKER_MANAGE_SCOPE,
DOCKER_REPORT_SCOPE,
HOST_AGENT_SCOPE,
+ MONITORING_READ_SCOPE,
SETTINGS_READ_SCOPE,
SETTINGS_WRITE_SCOPE,
} from '@/constants/apiScopes';
@@ -118,6 +119,11 @@ export const APITokenManager: Component<APITokenManagerProps> = (props) => {
selectedScopes().length === 0 || selectedScopes().includes(WILDCARD_SCOPE);
const scopePresets: { label: string; scopes: string[]; description: string }[] = [
+ {
+ label: 'Kiosk / Dashboard',
+ scopes: [MONITORING_READ_SCOPE],
+ description: 'Read-only dashboard access for kiosk displays. Use with ?token=xxx in the URL.',
+ },
{
label: 'Host agent',
scopes: [HOST_AGENT_SCOPE],
diff --git a/frontend-modern/src/types/config.ts b/frontend-modern/src/types/config.ts
index a0063bf462..666c6fd614 100644
--- a/frontend-modern/src/types/config.ts
+++ b/frontend-modern/src/types/config.ts
@@ -136,6 +136,8 @@ export interface SecurityStatus {
oidcIssuer?: string;
oidcClientId?: string;
oidcEnvOverrides?: Record<string, boolean>;
+ // Token auth scopes (for kiosk/limited-access mode)
+ tokenScopes?: string[];
}
/**
diff --git a/internal/api/router.go b/internal/api/router.go
index 347f6b8794..493e64a573 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -58,6 +58,7 @@ type Router struct {
systemSettingsHandler *SystemSettingsHandler
aiSettingsHandler *AISettingsHandler
resourceHandlers *ResourceHandlers
+ configProfileHandler *ConfigProfileHandler
licenseHandlers *LicenseHandlers
agentExecServer *agentexec.Server
wsHub *websocket.Hub
@@ -195,6 +196,7 @@ func (r *Router) setupRoutes() {
r.hostAgentHandlers = NewHostAgentHandlers(r.monitor, r.wsHub)
r.temperatureProxyHandlers = NewTemperatureProxyHandlers(r.config, r.persistence, r.reloadFunc)
r.resourceHandlers = NewResourceHandlers()
+ r.configProfileHandler = NewConfigProfileHandler(r.persistence)
r.licenseHandlers = NewLicenseHandlers(r.config.DataPath)
// API routes
@@ -455,6 +457,12 @@ func (r *Router) setupRoutes() {
}
})
+ // Config Profile Routes - Protected by Admin Auth and Pro License
+ // r.configProfileHandler.ServeHTTP implements http.Handler, so we wrap it
+ r.mux.Handle("/api/admin/profiles/", RequireAdmin(r.config, RequireLicenseFeature(r.licenseHandlers.Service(), license.FeatureAgentProfiles, func(w http.ResponseWriter, req *http.Request) {
+ http.StripPrefix("/api/admin/profiles", r.configProfileHandler).ServeHTTP(w, req)
+ })))
+
// System settings routes
r.mux.HandleFunc("/api/config/system", func(w http.ResponseWriter, req *http.Request) {
switch req.Method {
@@ -563,12 +571,21 @@ func (r *Router) setupRoutes() {
isTrustedNetwork := isTrustedNetwork(clientIP, trustedNetworks)
// Determine whether the caller is authenticated before exposing sensitive fields
+ // Also track token scopes for kiosk/limited-access scenarios
isAuthenticated := false
+ var tokenScopes []string
if cookie, err := req.Cookie("pulse_session"); err == nil && cookie.Value != "" && ValidateSession(cookie.Value) {
isAuthenticated = true
} else if token := strings.TrimSpace(req.Header.Get("X-API-Token")); token != "" {
- if _, ok := r.config.ValidateAPIToken(token); ok {
+ if record, ok := r.config.ValidateAPIToken(token); ok {
+ isAuthenticated = true
+ tokenScopes = record.Scopes
+ }
+ } else if token := req.URL.Query().Get("token"); token != "" {
+ // Also check URL query param (used for kiosk mode)
+ if record, ok := r.config.ValidateAPIToken(token); ok {
isAuthenticated = true
+ tokenScopes = record.Scopes
}
}
@@ -640,6 +657,11 @@ func (r *Router) setupRoutes() {
status["authLastModified"] = authLastModified
}
+ // Include token scopes when authenticated via API token (for kiosk mode UI)
+ if len(tokenScopes) > 0 {
+ status["tokenScopes"] = tokenScopes
+ }
+
if oidcCfg != nil {
status["oidcEnabled"] = oidcCfg.Enabled
status["oidcIssuer"] = oidcCfg.IssuerURL