/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
internal/entity/auth_client_data.go
80 строк
2 KB
Michael Mayer
Cluster: Declare per-node group config via instance env/flags
12 июн 2026, 21:52
12 июн 2026, 21:52
d594edd
Код
Авторство
О чём код?
package entity import ( "encoding/json" ) // ClientDatabase captures DB metadata provisioned for a node. type ClientDatabase struct { Name string `json:"name,omitempty"` User string `json:"user,omitempty"` Driver string `json:"driver,omitempty"` RotatedAt string `json:"rotatedAt,omitempty"` } // ClientData represents instance/service-specific metadata for cluster clients. type ClientData struct { Labels map[string]string `json:"labels,omitempty"` Database *ClientDatabase `json:"database,omitempty"` Theme string `json:"theme,omitempty"` RotatedAt string `json:"rotatedAt,omitempty"` SiteURL string `json:"siteUrl,omitempty"` ClusterUUID string `json:"clusterUUID,omitempty"` ServiceKind string `json:"serviceKind,omitempty"` ServiceFeatures []string `json:"serviceFeatures,omitempty"` AllowGroups []string `json:"allowGroups,omitempty"` AllowGroupRoles map[string]string `json:"allowGroupRoles,omitempty"` GroupsFullView bool `json:"groupsFullView,omitempty"` GroupsSrc string `json:"groupsSrc,omitempty"` RedirectURIs []string `json:"redirectUris,omitempty"` } // Recognized ClientData.GroupsSrc provenance values. An admin-pinned config // (manual) is never replaced by an instance-declared one (node); an empty // value marks unmanaged group config. const ( ClientGroupsSrcNode = "node" ClientGroupsSrcManual = "manual" ) // NewClientData creates a new client data struct and returns a pointer to it. func NewClientData() *ClientData { return &ClientData{} } // GetData returns the data that belong to this session. func (m *Client) GetData() (data *ClientData) { if m.data != nil { return m.data } data = NewClientData() if len(m.DataJSON) == 0 { return data } else if err := json.Unmarshal(m.DataJSON, data); err != nil { log.Errorf("auth: failed to read client data (%s)", err) } else { m.data = data } return data } // SetData updates the data that belong to this session. func (m *Client) SetData(data *ClientData) *Client { if data == nil { log.Debugf("auth: nil cannot be set as client data (%s)", m.ClientUID) return m } if j, err := json.Marshal(data); err != nil { log.Debugf("auth: failed to set client data (%s)", err) } else { m.DataJSON = j } m.data = data return m }