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.

667 B
Raw Blame
package api

import (
	"fmt"
	"strings"

	"github.com/rcourtman/pulse-go-rewrite/internal/config"
)

func apiTokenBoundUser(record *config.APITokenRecord) string {
	if record == nil {
		return ""
	}
	ownerUserID := strings.TrimSpace(apiTokenOwnerUserID(*record))
	if ownerUserID == "" || strings.HasPrefix(ownerUserID, "token:") {
		return ""
	}
	return ownerUserID
}

func apiTokenAuthenticatedUser(record *config.APITokenRecord) string {
	if ownerUserID := apiTokenBoundUser(record); ownerUserID != "" {
		return ownerUserID
	}
	if record == nil || strings.TrimSpace(record.ID) == "" {
		return ""
	}
	return fmt.Sprintf("token:%s", strings.TrimSpace(record.ID))
}