types

package
v0.75.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: BSD-3-Clause, AGPL-3.0 Imports: 45 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DefaultPeerLoginExpiration      = 24 * time.Hour
	DefaultPeerInactivityExpiration = 10 * time.Minute

	PublicCategory  = "public"
	PrivateCategory = "private"
	UnknownCategory = "unknown"
)
View Source
const (
	ComponentResourceHost   = sharedtypes.ComponentResourceHost
	ComponentResourceSubnet = sharedtypes.ComponentResourceSubnet
	ComponentResourceDomain = sharedtypes.ComponentResourceDomain
)
View Source
const (
	FirewallRuleDirectionIN  = sharedtypes.FirewallRuleDirectionIN
	FirewallRuleDirectionOUT = sharedtypes.FirewallRuleDirectionOUT
)
View Source
const (
	ResourceTypePeer   = sharedtypes.ResourceTypePeer
	ResourceTypeDomain = sharedtypes.ResourceTypeDomain
	ResourceTypeHost   = sharedtypes.ResourceTypeHost
	ResourceTypeSubnet = sharedtypes.ResourceTypeSubnet
)
View Source
const (
	PolicyTrafficActionAccept = sharedtypes.PolicyTrafficActionAccept
	PolicyTrafficActionDrop   = sharedtypes.PolicyTrafficActionDrop
)
View Source
const (
	PolicyRuleProtocolALL        = sharedtypes.PolicyRuleProtocolALL
	PolicyRuleProtocolTCP        = sharedtypes.PolicyRuleProtocolTCP
	PolicyRuleProtocolUDP        = sharedtypes.PolicyRuleProtocolUDP
	PolicyRuleProtocolICMP       = sharedtypes.PolicyRuleProtocolICMP
	PolicyRuleProtocolNetbirdSSH = sharedtypes.PolicyRuleProtocolNetbirdSSH
)
View Source
const (
	PolicyRuleFlowDirect   = sharedtypes.PolicyRuleFlowDirect
	PolicyRuleFlowBidirect = sharedtypes.PolicyRuleFlowBidirect
)
View Source
const (
	DefaultRuleName          = sharedtypes.DefaultRuleName
	DefaultRuleDescription   = sharedtypes.DefaultRuleDescription
	DefaultPolicyName        = sharedtypes.DefaultPolicyName
	DefaultPolicyDescription = sharedtypes.DefaultPolicyDescription
)
View Source
const (
	GroupIssuedAPI         = "api"
	GroupIssuedJWT         = "jwt"
	GroupIssuedIntegration = "integration"
)
View Source
const (
	// PATPrefix is the globally used, 4 char prefix for personal access tokens
	PATPrefix = "nbp_"
	// PATSecretLength number of characters used for the secret inside the token
	PATSecretLength = 30
	// PATChecksumLength number of characters used for the encoded checksum of the secret inside the token
	PATChecksumLength = 6
	// PATLength total number of characters used for the token
	PATLength = 40
)
View Source
const (
	// ProxyTokenPrefix is the globally used prefix for proxy access tokens
	ProxyTokenPrefix = "nbx_"
	// ProxyTokenSecretLength is the number of characters used for the secret
	ProxyTokenSecretLength = 30
	// ProxyTokenChecksumLength is the number of characters used for the encoded checksum
	ProxyTokenChecksumLength = 6
	// ProxyTokenLength is the total number of characters used for the token
	ProxyTokenLength = 40
)
View Source
const (
	// SetupKeyReusable is a multi-use key (can be used for multiple machines)
	SetupKeyReusable SetupKeyType = "reusable"
	// SetupKeyOneOff is a single use key (can be used only once)
	SetupKeyOneOff SetupKeyType = "one-off"
	// DefaultSetupKeyDuration = 1 month
	DefaultSetupKeyDuration = 24 * 30 * time.Hour
	// DefaultSetupKeyName is a default name of the default setup key
	DefaultSetupKeyName = "Default key"
	// SetupKeyUnlimitedUsage indicates an unlimited usage of a setup key
	SetupKeyUnlimitedUsage = 0
)
View Source
const (
	UserRoleOwner        UserRole = "owner"
	UserRoleAdmin        UserRole = "admin"
	UserRoleUser         UserRole = "user"
	UserRoleUnknown      UserRole = "unknown"
	UserRoleBillingAdmin UserRole = "billing_admin"
	UserRoleAuditor      UserRole = "auditor"
	UserRoleNetworkAdmin UserRole = "network_admin"

	UserStatusActive   UserStatus = "active"
	UserStatusDisabled UserStatus = "disabled"
	UserStatusInvited  UserStatus = "invited"

	UserIssuedAPI         = "api"
	UserIssuedIntegration = "integration"
)
View Source
const (
	// InviteTokenPrefix is the prefix for invite tokens
	InviteTokenPrefix = "nbi_"
	// InviteTokenSecretLength is the length of the random secret part
	InviteTokenSecretLength = 30
	// InviteTokenChecksumLength is the length of the encoded checksum
	InviteTokenChecksumLength = 6
	// InviteTokenLength is the total length of the token (4 + 30 + 6 = 40)
	InviteTokenLength = 40
	// DefaultInviteExpirationSeconds is the default expiration time for invites (72 hours)
	DefaultInviteExpirationSeconds = 259200
	// MinInviteExpirationSeconds is the minimum expiration time for invites (1 hour)
	MinInviteExpirationSeconds = 3600
)
View Source
const GroupAllName = sharedtypes.GroupAllName
View Source
const (
	// MaxJobReasonLength is the maximum length allowed for job failure reasons
	MaxJobReasonLength = 4096
)
View Source
const ProxyCallbackEndpoint = "/reverse-proxy/callback"

ProxyCallbackEndpoint holds the proxy callback endpoint

View Source
const ProxyCallbackEndpointFull = "/api" + ProxyCallbackEndpoint

ProxyCallbackEndpointFull holds the proxy callback endpoint with api suffix

Variables

View Source
var (
	ErrIdentityProviderNameRequired      = errors.New("identity provider name is required")
	ErrIdentityProviderTypeRequired      = errors.New("identity provider type is required")
	ErrIdentityProviderTypeUnsupported   = errors.New("unsupported identity provider type")
	ErrIdentityProviderIssuerRequired    = errors.New("identity provider issuer is required")
	ErrIdentityProviderIssuerInvalid     = errors.New("identity provider issuer must be a valid URL")
	ErrIdentityProviderIssuerUnreachable = errors.New("identity provider issuer is unreachable")
	ErrIdentityProviderIssuerMismatch    = errors.New("identity provider issuer does not match the issuer returned by the provider")
	ErrIdentityProviderClientIDRequired  = errors.New("identity provider client ID is required")
)

Identity provider validation errors

View Source
var EmptyNetworkMapComponents = sharedtypes.EmptyNetworkMapComponents

Functions

func AddPeerLabelsToAccount

func AddPeerLabelsToAccount(ctx context.Context, account *Account, peerLabels LookupMap)

func AllocateIPv6Subnet added in v0.71.0

func AllocateIPv6Subnet(r *rand.Rand) net.IPNet

func AllocatePeerIP

func AllocatePeerIP(prefix netip.Prefix, takenIps []netip.Addr) (netip.Addr, error)

func AllocateRandomPeerIP added in v0.50.0

func AllocateRandomPeerIP(prefix netip.Prefix) (netip.Addr, error)

func AllocateRandomPeerIPv6 added in v0.71.0

func AllocateRandomPeerIPv6(prefix netip.Prefix) (netip.Addr, error)

func GenerateInviteToken added in v0.64.2

func GenerateInviteToken() (hashedToken string, plainToken string, err error)

GenerateInviteToken creates a new invite token with the format: nbi_<secret><checksum> Returns the hashed token (for storage) and the plain token (to give to the user)

func GetPeerHostLabel

func GetPeerHostLabel(name string, peerLabels LookupMap) (string, error)

func GroupsToComponent added in v0.75.0

func GroupsToComponent(groups map[string]*Group) map[string]*ComponentGroup

GroupsToComponent converts an id-keyed group map to its components representation, preserving nil entries.

func HashInviteToken added in v0.64.2

func HashInviteToken(token string) string

HashInviteToken creates a SHA-256 hash of the token (base64 encoded)

func HiddenKey

func HiddenKey(key string, length int) string

HiddenKey returns the Key value hidden with "*" and a 5 character prefix. E.g., "831F6*******************************"

func NewInviteID added in v0.64.2

func NewInviteID() string

NewInviteID generates a new invite ID using xid

func ParseRuleString added in v0.59.0

func ParseRuleString(rule string) (PolicyRuleProtocolType, RulePortRange, error)

func PeerSSHEnabledFromPolicies added in v0.73.0

func PeerSSHEnabledFromPolicies(policies []*Policy, peerID string, peerGroupIDs map[string]struct{}, peerSSHEnabled bool) bool

PeerSSHEnabledFromPolicies is the network-map-free equivalent of the sshEnabled determination in GetPeerConnectionResources / CalculateNetworkMapFromComponents.

func PolicyRuleImpliesLegacySSH added in v0.75.0

func PolicyRuleImpliesLegacySSH(rule *PolicyRule) bool

func ValidateInviteToken added in v0.64.2

func ValidateInviteToken(token string) error

ValidateInviteToken validates the token format and checksum. Returns an error if the token is invalid.

Types

type Account

type Account struct {
	// we have to name column to aid as it collides with Network.Id when work with associations
	Id string `gorm:"primaryKey"`

	// User.Id it was created by
	CreatedBy              string
	CreatedAt              time.Time
	Domain                 string `gorm:"index"`
	DomainCategory         string
	IsDomainPrimaryAccount bool
	SetupKeys              map[string]*SetupKey              `gorm:"-"`
	SetupKeysG             []SetupKey                        `json:"-" gorm:"foreignKey:AccountID;references:id"`
	Network                *Network                          `gorm:"embedded;embeddedPrefix:network_"`
	Peers                  map[string]*nbpeer.Peer           `gorm:"-"`
	PeersG                 []nbpeer.Peer                     `json:"-" gorm:"foreignKey:AccountID;references:id"`
	Users                  map[string]*User                  `gorm:"-"`
	UsersG                 []User                            `json:"-" gorm:"foreignKey:AccountID;references:id"`
	Groups                 map[string]*Group                 `gorm:"-"`
	GroupsG                []*Group                          `json:"-" gorm:"foreignKey:AccountID;references:id"`
	Policies               []*Policy                         `gorm:"foreignKey:AccountID;references:id"`
	Routes                 map[route.ID]*route.Route         `gorm:"-"`
	RoutesG                []route.Route                     `json:"-" gorm:"foreignKey:AccountID;references:id"`
	NameServerGroups       map[string]*nbdns.NameServerGroup `gorm:"-"`
	NameServerGroupsG      []nbdns.NameServerGroup           `json:"-" gorm:"foreignKey:AccountID;references:id"`
	DNSSettings            DNSSettings                       `gorm:"embedded;embeddedPrefix:dns_settings_"`
	PostureChecks          []*posture.Checks                 `gorm:"foreignKey:AccountID;references:id"`
	Services               []*service.Service                `gorm:"foreignKey:AccountID;references:id"`
	Domains                []*proxydomain.Domain             `gorm:"foreignKey:AccountID;references:id"`
	// Settings is a dictionary of Account settings
	Settings         *Settings                        `gorm:"embedded;embeddedPrefix:settings_"`
	Networks         []*networkTypes.Network          `gorm:"foreignKey:AccountID;references:id"`
	NetworkRouters   []*routerTypes.NetworkRouter     `gorm:"foreignKey:AccountID;references:id"`
	NetworkResources []*resourceTypes.NetworkResource `gorm:"foreignKey:AccountID;references:id"`
	Onboarding       AccountOnboarding                `gorm:"foreignKey:AccountID;references:id;constraint:OnDelete:CASCADE"`

	ReverseProxyFreeDomainNonce string
}

Account represents a unique account of the system

func (*Account) AddAllGroup added in v0.37.1

func (a *Account) AddAllGroup(disableDefaultPolicy bool) error

AddAllGroup to account object if it doesn't exist

func (*Account) Copy

func (a *Account) Copy() *Account

func (*Account) DeletePeer

func (a *Account) DeletePeer(peerID string)

DeletePeer deletes peer from the account cleaning up all the references

func (*Account) DeleteResource

func (a *Account) DeleteResource(resourceID string)

func (*Account) FindGroupByName

func (a *Account) FindGroupByName(groupName string) (*Group, error)

FindGroupByName looks for a given group in the Account by name or returns error if the group wasn't found.

func (*Account) FindPeerByPubKey

func (a *Account) FindPeerByPubKey(peerPubKey string) (*nbpeer.Peer, error)

FindPeerByPubKey looks for a Peer by provided WireGuard public key in the Account or returns error if it wasn't found. It will return an object copy of the peer.

func (*Account) FindSetupKey

func (a *Account) FindSetupKey(setupKey string) (*SetupKey, error)

FindSetupKey looks for a given SetupKey in the Account or returns error if it wasn't found.

func (*Account) FindUser

func (a *Account) FindUser(userID string) (*User, error)

FindUser looks for a given user in the Account or returns error if user wasn't found.

func (*Account) FindUserPeers

func (a *Account) FindUserPeers(userID string) ([]*nbpeer.Peer, error)

FindUserPeers returns a list of peers that user owns (created)

func (*Account) GetActiveGroupUsers added in v0.61.0

func (a *Account) GetActiveGroupUsers() map[string][]string

func (*Account) GetExpiredPeers

func (a *Account) GetExpiredPeers() []*nbpeer.Peer

GetExpiredPeers returns peers that have been expired

func (*Account) GetGroup

func (a *Account) GetGroup(groupID string) *Group

GetGroup returns a group by ID if exists, nil otherwise

func (*Account) GetGroupAll

func (a *Account) GetGroupAll() (*Group, error)

func (*Account) GetInactivePeers

func (a *Account) GetInactivePeers() []*nbpeer.Peer

GetInactivePeers returns peers that have been expired by inactivity

func (*Account) GetMeta added in v0.42.0

func (a *Account) GetMeta() *AccountMeta

func (*Account) GetNextInactivePeerExpiration

func (a *Account) GetNextInactivePeerExpiration() (time.Duration, bool)

GetNextInactivePeerExpiration returns the minimum duration in which the next peer of the account will expire if it was found. If there is no peer that expires this function returns false and a duration of 0. This function only considers peers that haven't been expired yet and that are not connected.

func (*Account) GetNextPeerExpiration

func (a *Account) GetNextPeerExpiration() (time.Duration, bool)

GetNextPeerExpiration returns the minimum duration in which the next peer of the account will expire if it was found. If there is no peer that expires this function returns false and a duration of 0. This function only considers peers that haven't been expired yet and that are connected.

func (*Account) GetPeer

func (a *Account) GetPeer(peerID string) *nbpeer.Peer

GetPeer looks up a Peer by ID

func (*Account) GetPeerConnectionResources

func (a *Account) GetPeerConnectionResources(ctx context.Context, peer *nbpeer.Peer, validatedPeersMap map[string]struct{}, groupIDToUserIDs map[string][]string) ([]*nbpeer.Peer, []*FirewallRule, map[string]map[string]struct{}, bool)

GetPeerConnectionResources for a given peer

This function returns the list of peers and firewall rules that are applicable to a given peer.

func (*Account) GetPeerDNSLabels

func (a *Account) GetPeerDNSLabels() LookupMap

func (*Account) GetPeerGroups

func (a *Account) GetPeerGroups(peerID string) LookupMap

func (*Account) GetPeerGroupsList

func (a *Account) GetPeerGroupsList(peerID string) []string

GetPeerGroupsList return with the list of groups ID.

func (*Account) GetPeerNetworkMapComponents added in v0.66.0

func (a *Account) GetPeerNetworkMapComponents(
	ctx context.Context,
	peerID string,
	peersCustomZone nbdns.CustomZone,
	accountZones []*zones.Zone,
	validatedPeersMap map[string]struct{},
	resourcePolicies map[string][]*Policy,
	routers map[string]map[string]*routerTypes.NetworkRouter,
	groupIDToUserIDs map[string][]string,
) *NetworkMapComponents

func (*Account) GetPeerNetworkMapFromComponents added in v0.66.0

func (a *Account) GetPeerNetworkMapFromComponents(
	ctx context.Context,
	peerID string,
	peersCustomZone nbdns.CustomZone,
	accountZones []*zones.Zone,
	validatedPeersMap map[string]struct{},
	resourcePolicies map[string][]*Policy,
	routers map[string]map[string]*routerTypes.NetworkRouter,
	metrics *telemetry.AccountManagerMetrics,
	groupIDToUserIDs map[string][]string,
) *NetworkMap

func (*Account) GetPeerNetworkMapResult added in v0.75.0

func (a *Account) GetPeerNetworkMapResult(
	ctx context.Context,
	peerID string,
	componentsDisabled bool,
	peersCustomZone nbdns.CustomZone,
	accountZones []*zones.Zone,
	validatedPeersMap map[string]struct{},
	resourcePolicies map[string][]*Policy,
	routers map[string]map[string]*routerTypes.NetworkRouter,
	metrics *telemetry.AccountManagerMetrics,
	groupIDToUserIDs map[string][]string,
) PeerNetworkMapResult

GetPeerNetworkMapResult dispatches to either the legacy-NetworkMap path or the components path based on the peer's capability and the kill switch. Capable peers (PeerCapabilityComponentNetworkMap) get the raw components shape — the server skips Calculate() entirely for them, saving CPU proportional to the number of capable peers in the account. Legacy peers (or any peer when componentsDisabled is true) get the fully-expanded NetworkMap as before.

func (*Account) GetPeerNetworkResourceFirewallRules

func (a *Account) GetPeerNetworkResourceFirewallRules(ctx context.Context, peer *nbpeer.Peer, validatedPeersMap map[string]struct{}, routes []*route.Route, resourcePolicies map[string][]*Policy) []*RouteFirewallRule

GetPeerNetworkResourceFirewallRules gets the network resources firewall rules associated with a routing peer ID for the account.

func (*Account) GetPeers

func (a *Account) GetPeers() []*nbpeer.Peer

GetPeers returns a list of all Account peers

func (*Account) GetPeersCustomZone

func (a *Account) GetPeersCustomZone(ctx context.Context, dnsDomain string) nbdns.CustomZone

func (*Account) GetPeersWithExpiration

func (a *Account) GetPeersWithExpiration() []*nbpeer.Peer

GetPeersWithExpiration returns a list of peers that have Peer.LoginExpirationEnabled set to true and that were added by a user

func (*Account) GetPeersWithInactivity

func (a *Account) GetPeersWithInactivity() []*nbpeer.Peer

GetPeersWithInactivity eturns a list of peers that have Peer.InactivityExpirationEnabled set to true and that were added by a user

func (*Account) GetPoliciesAppliedInNetwork

func (a *Account) GetPoliciesAppliedInNetwork(networkID string) []string

func (*Account) GetPoliciesForNetworkResource

func (a *Account) GetPoliciesForNetworkResource(resourceId string) []*Policy

GetPoliciesForNetworkResource retrieves the list of policies that apply to a specific network resource. A policy is deemed applicable if its destination groups include any of the given network resource groups or if its destination resource explicitly matches the provided resource.

func (*Account) GetPostureChecks

func (a *Account) GetPostureChecks(postureChecksID string) *posture.Checks

func (*Account) GetProxyPeers added in v0.65.0

func (a *Account) GetProxyPeers() map[string][]*nbpeer.Peer

func (*Account) GetResourcePoliciesMap

func (a *Account) GetResourcePoliciesMap() map[string][]*Policy

GetResourcePoliciesMap returns a map of networks resource IDs and their associated policies.

func (*Account) GetResourceRoutersMap

func (a *Account) GetResourceRoutersMap() map[string]map[string]*routerTypes.NetworkRouter

func (*Account) GetRoutesByPrefixOrDomains

func (a *Account) GetRoutesByPrefixOrDomains(prefix netip.Prefix, domains domain.List) []*route.Route

GetRoutesByPrefixOrDomains return list of routes by account and route prefix

func (*Account) GetTakenIPs

func (a *Account) GetTakenIPs() []netip.Addr

GetTakenIPs returns all peer IP addresses currently allocated in the account.

func (*Account) InjectProxyPolicies added in v0.65.0

func (a *Account) InjectProxyPolicies(ctx context.Context)

func (*Account) PeerIPv6Allowed added in v0.71.0

func (a *Account) PeerIPv6Allowed(peerID string) bool

PeerIPv6Allowed reports whether the given peer participates in the IPv6 overlay. Returns false if IPv6 is disabled or no groups are configured.

func (*Account) SynthesizePrivateServiceZones added in v0.72.0

func (a *Account) SynthesizePrivateServiceZones(peerID string) []nbdns.CustomZone

SynthesizePrivateServiceZones returns in-memory CustomZones with A records pointing each enabled private service the peer can reach at the cluster's proxy-peer IPs. One zone per cluster (multiple services share); records gated by AccessGroups.

func (*Account) UpdatePeer

func (a *Account) UpdatePeer(update *nbpeer.Peer)

UpdatePeer saves new or replaces existing peer

func (*Account) UpdateSettings

func (a *Account) UpdateSettings(update *Settings) *Account

UpdateSettings saves new account settings

func (*Account) UserGroupsAddToPeers

func (a *Account) UserGroupsAddToPeers(userID string, groups ...string) map[string][]string

UserGroupsAddToPeers adds groups to all peers of user

func (*Account) UserGroupsRemoveFromPeers

func (a *Account) UserGroupsRemoveFromPeers(userID string, groups ...string) map[string][]string

UserGroupsRemoveFromPeers removes groups from all peers of user

type AccountDNSSettings

type AccountDNSSettings struct {
	DNSSettings DNSSettings `gorm:"embedded;embeddedPrefix:dns_settings_"`
}

AccountDNSSettings used in gorm to only load dns settings and not whole account

type AccountMeta added in v0.42.0

type AccountMeta struct {
	// AccountId is the unique identifier of the account
	AccountID      string `gorm:"column:id"`
	CreatedAt      time.Time
	CreatedBy      string
	Domain         string
	DomainCategory string
}

AccountMeta is a struct that contains a stripped down version of the Account object. It doesn't carry any peers, groups, policies, or routes, etc. Just some metadata (e.g. ID, created by, created at, etc).

type AccountNetwork

type AccountNetwork struct {
	Network *Network `gorm:"embedded;embeddedPrefix:network_"`
}

Subclass used in gorm to only load network and not whole account

type AccountOnboarding added in v0.50.0

type AccountOnboarding struct {
	AccountID             string `gorm:"primaryKey"`
	OnboardingFlowPending bool
	SignupFormPending     bool
	CreatedAt             time.Time
	UpdatedAt             time.Time
}

func (AccountOnboarding) IsEqual added in v0.50.0

func (o AccountOnboarding) IsEqual(onboarding AccountOnboarding) bool

IsEqual compares two AccountOnboarding objects and returns true if they are equal

type AccountSettings

type AccountSettings struct {
	Settings *Settings `gorm:"embedded;embeddedPrefix:settings_"`
}

Subclass used in gorm to only load settings and not whole account

type AccountSettingsInfo added in v0.66.0

type AccountSettingsInfo = sharedtypes.AccountSettingsInfo

type ComponentGroup added in v0.75.0

type ComponentGroup = sharedtypes.ComponentGroup

type ComponentPeer added in v0.75.0

type ComponentPeer = sharedtypes.ComponentPeer

type ComponentResource added in v0.75.0

type ComponentResource = sharedtypes.ComponentResource

type ComponentResourceType added in v0.75.0

type ComponentResourceType = sharedtypes.ComponentResourceType

type ComponentRouter added in v0.75.0

type ComponentRouter = sharedtypes.ComponentRouter

type DNSSettings

type DNSSettings = sharedtypes.DNSSettings

type DashboardFeatures added in v0.75.0

type DashboardFeatures struct {
	// AgentNetwork, when set, forces the Agent Network menu shown (true) or
	// hidden (false) regardless of the deployment feature flag.
	AgentNetwork *bool `json:"agent_network,omitempty"`
}

DashboardFeatures holds per-account dashboard section visibility overrides. Nil fields are unset and follow the default dashboard behavior; an explicit value forces that section shown or hidden for the account.

func (*DashboardFeatures) Copy added in v0.75.0

Copy returns a deep copy of the DashboardFeatures struct.

type Engine added in v0.39.2

type Engine string
const (
	PostgresStoreEngine Engine = "postgres"
	FileStoreEngine     Engine = "jsonfile"
	SqliteStoreEngine   Engine = "sqlite"
	MysqlStoreEngine    Engine = "mysql"
)

type ExtraSettings added in v0.39.0

type ExtraSettings struct {
	// PeerApprovalEnabled enables or disables the need for peers bo be approved by an administrator
	PeerApprovalEnabled bool

	// UserApprovalRequired enables or disables the need for users joining via domain matching to be approved by an administrator
	UserApprovalRequired bool

	// IntegratedValidator is the string enum for the integrated validator type
	IntegratedValidator string
	// IntegratedValidatorGroups list of group IDs to be used with integrated approval configurations
	IntegratedValidatorGroups []string `gorm:"serializer:json"`

	FlowEnabled              bool     `gorm:"-"`
	FlowGroups               []string `gorm:"-"`
	FlowPacketCounterEnabled bool     `gorm:"-"`
	FlowENCollectionEnabled  bool     `gorm:"-"`
	FlowDnsCollectionEnabled bool     `gorm:"-"`
}

func (*ExtraSettings) Copy added in v0.39.0

func (e *ExtraSettings) Copy() *ExtraSettings

Copy copies the ExtraSettings struct

type FirewallRule

type FirewallRule = sharedtypes.FirewallRule

func AppendIPv6FirewallRule added in v0.75.0

func AppendIPv6FirewallRule(rules []*FirewallRule, rulesExists map[string]struct{}, peer, targetPeer *ComponentPeer, rule *PolicyRule, rc FirewallRuleContext) []*FirewallRule

func ExpandPortsAndRanges added in v0.75.0

func ExpandPortsAndRanges(base FirewallRule, rule *PolicyRule, peer *ComponentPeer) []*FirewallRule

type FirewallRuleContext added in v0.75.0

type FirewallRuleContext = sharedtypes.FirewallRuleContext

type ForwardingRule added in v0.38.0

type ForwardingRule = sharedtypes.ForwardingRule

type Group

type Group struct {
	// ID of the group
	ID string `gorm:"primaryKey"`

	// AccountID is a reference to Account that this object belongs
	AccountID string `json:"-" gorm:"index"`

	PublicID string `json:"-"`

	// Name visible in the UI
	Name string

	// Issued defines how this group was created (enum of "api", "integration" or "jwt")
	Issued string

	// Peers list of the group
	Peers      []string    `gorm:"-"` // Peers and GroupPeers list will be ignored when writing to the DB. Use AddPeerToGroup and RemovePeerFromGroup methods to modify group membership
	GroupPeers []GroupPeer `gorm:"foreignKey:GroupID;references:id;constraint:OnDelete:CASCADE;"`

	// Resources contains a list of resources in that group
	Resources []Resource `gorm:"serializer:json"`

	IntegrationReference integration_reference.IntegrationReference `gorm:"embedded;embeddedPrefix:integration_ref_"`
}

Group of the peers for ACL

func (*Group) AddPeer

func (g *Group) AddPeer(peerID string) bool

AddPeer adds peerID to Peers if not present, returning true if added.

func (*Group) AddResource

func (g *Group) AddResource(resource Resource) bool

AddResource adds resource to Resources if not present, returning true if added.

func (*Group) Copy

func (g *Group) Copy() *Group

func (*Group) EventMeta

func (g *Group) EventMeta() map[string]any

EventMeta returns activity event meta related to the group

func (*Group) HasPeers

func (g *Group) HasPeers() bool

HasPeers checks if the group has any peers.

func (*Group) HasResources

func (g *Group) HasResources() bool

HasResources checks if the group has any resources.

func (*Group) IsGroupAll

func (g *Group) IsGroupAll() bool

IsGroupAll checks if the group is a default "All" group.

func (*Group) LoadGroupPeers added in v0.53.0

func (g *Group) LoadGroupPeers()

func (*Group) RemovePeer

func (g *Group) RemovePeer(peerID string) bool

RemovePeer removes peerID from Peers if present, returning true if removed.

func (*Group) RemoveResource

func (g *Group) RemoveResource(resource Resource) bool

RemoveResource removes resource from Resources if present, returning true if removed.

func (*Group) StoreGroupPeers added in v0.53.0

func (g *Group) StoreGroupPeers()

func (*Group) ToComponent added in v0.75.0

func (g *Group) ToComponent() *ComponentGroup

ToComponent converts the group to its self-contained components representation. The Peers slice is shared, not copied — components are treated as immutable snapshots. Returns nil for a nil group.

type GroupCompact added in v0.66.0

type GroupCompact = sharedtypes.GroupCompact

type GroupPeer added in v0.53.0

type GroupPeer struct {
	AccountID string `gorm:"index"`
	GroupID   string `gorm:"primaryKey"`
	PeerID    string `gorm:"primaryKey"`
}

type HashedProxyToken added in v0.65.0

type HashedProxyToken string

HashedProxyToken is a SHA-256 hash of a plain proxy token, base64-encoded.

type IdentityProvider added in v0.62.0

type IdentityProvider struct {
	// ID is the unique identifier of the identity provider
	ID string `gorm:"primaryKey"`
	// AccountID is a reference to Account that this object belongs
	AccountID string `json:"-" gorm:"index"`
	// Type is the type of identity provider
	Type IdentityProviderType
	// Name is a human-readable name for the identity provider
	Name string
	// Issuer is the OIDC issuer URL
	Issuer string
	// ClientID is the OAuth2 client ID
	ClientID string
	// ClientSecret is the OAuth2 client secret
	ClientSecret string
}

IdentityProvider represents an identity provider configuration

func (*IdentityProvider) Copy added in v0.62.0

func (idp *IdentityProvider) Copy() *IdentityProvider

Copy returns a copy of the IdentityProvider

func (*IdentityProvider) EventMeta added in v0.62.0

func (idp *IdentityProvider) EventMeta() map[string]any

EventMeta returns a map of metadata for activity events

func (*IdentityProvider) Validate added in v0.62.0

func (idp *IdentityProvider) Validate() error

Validate validates the identity provider configuration

type IdentityProviderType added in v0.62.0

type IdentityProviderType string

IdentityProviderType is the type of identity provider

const (
	// IdentityProviderTypeOIDC is a generic OIDC identity provider
	IdentityProviderTypeOIDC IdentityProviderType = "oidc"
	// IdentityProviderTypeZitadel is the Zitadel identity provider
	IdentityProviderTypeZitadel IdentityProviderType = "zitadel"
	// IdentityProviderTypeEntra is the Microsoft Entra (Azure AD) identity provider
	IdentityProviderTypeEntra IdentityProviderType = "entra"
	// IdentityProviderTypeGoogle is the Google identity provider
	IdentityProviderTypeGoogle IdentityProviderType = "google"
	// IdentityProviderTypeOkta is the Okta identity provider
	IdentityProviderTypeOkta IdentityProviderType = "okta"
	// IdentityProviderTypePocketID is the PocketID identity provider
	IdentityProviderTypePocketID IdentityProviderType = "pocketid"
	// IdentityProviderTypeMicrosoft is the Microsoft identity provider
	IdentityProviderTypeMicrosoft IdentityProviderType = "microsoft"
	// IdentityProviderTypeAuthentik is the Authentik identity provider
	IdentityProviderTypeAuthentik IdentityProviderType = "authentik"
	// IdentityProviderTypeKeycloak is the Keycloak identity provider
	IdentityProviderTypeKeycloak IdentityProviderType = "keycloak"
	// IdentityProviderTypeADFS is the Microsoft AD FS identity provider
	IdentityProviderTypeADFS IdentityProviderType = "adfs"
)

func (IdentityProviderType) HasBuiltInIssuer added in v0.62.0

func (t IdentityProviderType) HasBuiltInIssuer() bool

HasBuiltInIssuer returns true for types that don't require an issuer URL

func (IdentityProviderType) IsValid added in v0.62.0

func (t IdentityProviderType) IsValid() bool

IsValid checks if the given type is a supported identity provider type

type Job added in v0.64.0

type Job struct {
	// ID is the primary identifier
	ID string `gorm:"primaryKey"`

	// CreatedAt when job was created (UTC)
	CreatedAt time.Time `gorm:"autoCreateTime"`

	// CompletedAt when job finished, null if still running
	CompletedAt *time.Time

	// TriggeredBy user that triggered this job
	TriggeredBy string `gorm:"index"`

	PeerID string `gorm:"index"`

	AccountID string `gorm:"index"`

	// Status of the job: pending, succeeded, failed
	Status JobStatus `gorm:"index;type:varchar(50)"`

	// FailedReason describes why the job failed (if failed)
	FailedReason string

	Workload Workload `gorm:"embedded;embeddedPrefix:workload_"`
}

func NewJob added in v0.64.0

func NewJob(triggeredBy, accountID, peerID string, req *api.JobRequest) (*Job, error)

NewJob creates a new job with default fields and validation

func (*Job) ApplyResponse added in v0.64.0

func (j *Job) ApplyResponse(resp *proto.JobResponse) error

ApplyResponse validates and maps a proto.JobResponse into the Job fields.

func (*Job) BuildWorkloadResponse added in v0.64.0

func (j *Job) BuildWorkloadResponse() (*api.WorkloadResponse, error)

func (*Job) ToStreamJobRequest added in v0.64.0

func (j *Job) ToStreamJobRequest() (*proto.JobRequest, error)

type JobStatus added in v0.64.0

type JobStatus string
const (
	JobStatusPending   JobStatus = "pending"
	JobStatusSucceeded JobStatus = "succeeded"
	JobStatusFailed    JobStatus = "failed"
)

type JobType added in v0.64.0

type JobType string
const (
	JobTypeBundle JobType = "bundle"
)

type LookupMap

type LookupMap = sharedtypes.LookupMap

type Network

type Network = sharedtypes.Network

func NewNetwork

func NewNetwork() *Network

type NetworkMap

type NetworkMap = sharedtypes.NetworkMap

func CalculateNetworkMapFromComponents added in v0.66.0

func CalculateNetworkMapFromComponents(ctx context.Context, components *NetworkMapComponents) *NetworkMap

type NetworkMapComponents added in v0.66.0

type NetworkMapComponents = sharedtypes.NetworkMapComponents

type NetworkMapComponentsCompact added in v0.66.0

type NetworkMapComponentsCompact = sharedtypes.NetworkMapComponentsCompact

type PeerLogin added in v0.39.0

type PeerLogin struct {
	// WireGuardPubKey is a peers WireGuard public key
	WireGuardPubKey string
	// SSHKey is a peer's ssh key. Can be empty (e.g., old version do not provide it, or this feature is disabled)
	SSHKey string
	// Meta is the system information passed by peer, must be always present.
	Meta nbpeer.PeerSystemMeta
	// UserID indicates that JWT was used to log in, and it was valid. Can be empty when SetupKey is used or auth is not required.
	UserID string
	// SetupKey references to a server.SetupKey to log in. Can be empty when UserID is used or auth is not required.
	SetupKey string
	// ConnectionIP is the real IP of the peer
	ConnectionIP net.IP

	// ExtraDNSLabels is a list of extra DNS labels that the peer wants to use
	ExtraDNSLabels []string
}

PeerLogin used as a data object between the gRPC API and Manager on Login request.

type PeerNetworkMapResult added in v0.75.0

type PeerNetworkMapResult struct {
	NetworkMap *NetworkMap
	Components *NetworkMapComponents
}

PeerNetworkMapResult is what the network_map controller produces for a single peer. Exactly one of NetworkMap or Components is populated depending on the peer's capability:

  • Components-capable peers (PeerCapabilityComponentNetworkMap) get Components: the raw types.NetworkMapComponents the client decodes and runs Calculate() on locally. NetworkMap stays nil — the server skips the expansion entirely.
  • Legacy peers (or any peer when the kill switch is set) get NetworkMap: the fully-expanded view the legacy gRPC path consumes.

The gRPC layer (ToSyncResponseForPeer) dispatches by which field is non-nil; callers must not rely on both being set.

func (PeerNetworkMapResult) IsComponents added in v0.75.0

func (r PeerNetworkMapResult) IsComponents() bool

IsComponents reports whether the result carries the components shape. Use this in preference to direct nil checks on the fields.

type PeerSync added in v0.39.0

type PeerSync struct {
	// WireGuardPubKey is a peers WireGuard public key
	WireGuardPubKey string
	// Meta is the system information passed by peer, must be always present
	Meta nbpeer.PeerSystemMeta
	// RealIP is the peer's connection IP, used to refresh its geo location.
	// May be nil when the request has no associated connection IP.
	RealIP net.IP
	// UpdateAccountPeers indicate updating account peers,
	// which occurs when the peer's metadata is updated
	UpdateAccountPeers bool
}

PeerSync used as a data object between the gRPC API and Manager on Sync request.

type PersonalAccessToken

type PersonalAccessToken struct {
	ID string `gorm:"primaryKey"`
	// User is a reference to Account that this object belongs
	UserID         string `gorm:"index"`
	Name           string
	HashedToken    string
	ExpirationDate *time.Time
	// scope could be added in future
	CreatedBy string
	CreatedAt time.Time
	LastUsed  *time.Time
}

PersonalAccessToken holds all information about a PAT including a hashed version of it for verification

func (*PersonalAccessToken) Copy

func (*PersonalAccessToken) GetExpirationDate added in v0.36.0

func (t *PersonalAccessToken) GetExpirationDate() time.Time

GetExpirationDate returns the expiration time of the token.

func (*PersonalAccessToken) GetLastUsed added in v0.36.0

func (t *PersonalAccessToken) GetLastUsed() time.Time

GetLastUsed returns the last time the token was used.

type PersonalAccessTokenGenerated

type PersonalAccessTokenGenerated struct {
	PlainToken string
	PersonalAccessToken
}

PersonalAccessTokenGenerated holds the new PersonalAccessToken and the plain text version of it

func CreateNewPAT

func CreateNewPAT(name string, expirationInDays int, targetID, createdBy string) (*PersonalAccessTokenGenerated, error)

CreateNewPAT will generate a new PersonalAccessToken that can be assigned to a User. Additionally, it will return the token in plain text once, to give to the user and only save a hashed version

type PlainProxyToken added in v0.65.0

type PlainProxyToken string

PlainProxyToken is the raw token string displayed once at creation time.

func (PlainProxyToken) Hash added in v0.65.0

Hash returns the SHA-256 hash of the plain token, base64-encoded.

func (PlainProxyToken) Validate added in v0.65.0

func (t PlainProxyToken) Validate() error

Validate checks the format of a proxy token without checking the database.

type Policy

type Policy = sharedtypes.Policy

func GetAllRoutePoliciesFromGroups

func GetAllRoutePoliciesFromGroups(account *Account, accessControlGroups []string) []*Policy

GetAllRoutePoliciesFromGroups retrieves route policies associated with the specified access control groups and returns a list of policies that have rules with destinations matching the specified groups.

type PolicyRule

type PolicyRule = sharedtypes.PolicyRule

type PolicyRuleDirection

type PolicyRuleDirection = sharedtypes.PolicyRuleDirection

type PolicyRuleProtocolType

type PolicyRuleProtocolType = sharedtypes.PolicyRuleProtocolType

type PolicyTrafficActionType

type PolicyTrafficActionType = sharedtypes.PolicyTrafficActionType

type PolicyUpdateOperation

type PolicyUpdateOperation = sharedtypes.PolicyUpdateOperation

type PolicyUpdateOperationType

type PolicyUpdateOperationType = sharedtypes.PolicyUpdateOperationType

type PrimaryAccountInfo added in v0.55.0

type PrimaryAccountInfo struct {
	IsDomainPrimaryAccount bool
	Domain                 string
}

this class is used by gorm only

type ProxyAccessToken added in v0.65.0

type ProxyAccessToken struct {
	ID          string `gorm:"primaryKey"`
	Name        string
	HashedToken HashedProxyToken `gorm:"type:varchar(255);uniqueIndex"`
	// AccountID is nil for management-wide tokens, set for account-scoped tokens
	AccountID *string `gorm:"index"`
	ExpiresAt *time.Time
	CreatedBy string
	CreatedAt time.Time
	LastUsed  *time.Time
	Revoked   bool
}

ProxyAccessToken holds information about a proxy access token including a hashed version for verification

func (*ProxyAccessToken) IsExpired added in v0.65.0

func (t *ProxyAccessToken) IsExpired() bool

IsExpired returns true if the token has expired

func (*ProxyAccessToken) IsValid added in v0.65.0

func (t *ProxyAccessToken) IsValid() bool

IsValid returns true if the token is not revoked and not expired

type ProxyAccessTokenGenerated added in v0.65.0

type ProxyAccessTokenGenerated struct {
	PlainToken PlainProxyToken
	ProxyAccessToken
}

ProxyAccessTokenGenerated holds the new token and the plain text version

func CreateNewProxyAccessToken added in v0.65.0

func CreateNewProxyAccessToken(name string, expiresIn time.Duration, accountID *string, createdBy string) (*ProxyAccessTokenGenerated, error)

CreateNewProxyAccessToken generates a new proxy access token. Returns the token with hashed value stored and plain token for one-time display.

type Resource

type Resource = sharedtypes.Resource

type ResourceType added in v0.59.0

type ResourceType = sharedtypes.ResourceType

type RouteFirewallRule

type RouteFirewallRule = sharedtypes.RouteFirewallRule

func GenerateRouteFirewallRules added in v0.75.0

func GenerateRouteFirewallRules(ctx context.Context, route *nbroute.Route, rule *PolicyRule, groupPeers []*ComponentPeer, direction int, includeIPv6 bool) []*RouteFirewallRule

type RulePortRange

type RulePortRange = sharedtypes.RulePortRange

type Settings

type Settings struct {
	// PeerLoginExpirationEnabled globally enables or disables peer login expiration
	PeerLoginExpirationEnabled bool

	// PeerLoginExpiration is a setting that indicates when peer login expires.
	// Applies to all peers that have Peer.LoginExpirationEnabled set to true.
	PeerLoginExpiration time.Duration

	// PeerInactivityExpirationEnabled globally enables or disables peer inactivity expiration
	PeerInactivityExpirationEnabled bool

	// PeerInactivityExpiration is a setting that indicates when peer inactivity expires.
	// Applies to all peers that have Peer.PeerInactivityExpirationEnabled set to true.
	PeerInactivityExpiration time.Duration

	// RegularUsersViewBlocked allows to block regular users from viewing even their own peers and some UI elements
	RegularUsersViewBlocked bool

	// GroupsPropagationEnabled allows to propagate auto groups from the user to the peer
	GroupsPropagationEnabled bool

	// JWTGroupsEnabled allows extract groups from JWT claim, which name defined in the JWTGroupsClaimName
	// and add it to account groups.
	JWTGroupsEnabled bool

	// JWTGroupsClaimName from which we extract groups name to add it to account groups
	JWTGroupsClaimName string

	// JWTAllowGroups list of groups to which users are allowed access
	JWTAllowGroups []string `gorm:"serializer:json"`

	// RoutingPeerDNSResolutionEnabled enabled the DNS resolution on the routing peers
	RoutingPeerDNSResolutionEnabled bool

	// DNSDomain is the custom domain for that account
	DNSDomain string

	// NetworkRange is the custom network range for that account
	NetworkRange netip.Prefix `gorm:"serializer:json"`
	// NetworkRangeV6 is the custom IPv6 network range for that account
	NetworkRangeV6 netip.Prefix `gorm:"serializer:json"`

	// PeerExposeEnabled enables or disables peer-initiated service expose
	PeerExposeEnabled bool
	// PeerExposeGroups list of peer group IDs allowed to expose services
	PeerExposeGroups []string `gorm:"serializer:json"`

	// Extra is a dictionary of Account settings
	Extra *ExtraSettings `gorm:"embedded;embeddedPrefix:extra_"`

	// LazyConnectionEnabled indicates if the experimental feature is enabled or disabled
	LazyConnectionEnabled bool `gorm:"default:false"`

	// AutoUpdateVersion client auto-update version
	AutoUpdateVersion string `gorm:"default:'disabled'"`

	// AutoUpdateAlways when true, updates are installed automatically in the background;
	// when false, updates require user interaction from the UI
	AutoUpdateAlways bool `gorm:"default:false"`

	// IPv6EnabledGroups is the list of group IDs whose peers receive IPv6 overlay addresses.
	// Peers not in any of these groups will not be allocated an IPv6 address.
	// Empty list means IPv6 is disabled for the account.
	// For new accounts this defaults to the All group.
	IPv6EnabledGroups []string `gorm:"serializer:json"`

	// MetricsPushEnabled globally enables or disables client metrics push for the account
	MetricsPushEnabled bool `gorm:"default:false"`

	// AgentNetworkOnly limits the dashboard to the Agent Network surface for this account.
	// Set for accounts created via netbird.ai signups; users can disable it later.
	AgentNetworkOnly bool `gorm:"default:false"`

	// DashboardFeatures holds per-account dashboard section visibility overrides.
	// It serializes to a single JSON column so new sections can be added without
	// a schema change.
	DashboardFeatures *DashboardFeatures `gorm:"serializer:json"`

	// EmbeddedIdpEnabled indicates if the embedded identity provider is enabled.
	// This is a runtime-only field, not stored in the database.
	EmbeddedIdpEnabled bool `gorm:"-"`

	// LocalAuthDisabled indicates if local (email/password) authentication is disabled.
	// This is a runtime-only field, not stored in the database.
	LocalAuthDisabled bool `gorm:"-"`

	// LocalMfaEnabled indicates if TOTP MFA is enabled for local users.
	// Only applicable when the embedded IDP is enabled.
	LocalMfaEnabled bool
}

Settings represents Account settings structure that can be modified via API and Dashboard

func (*Settings) Copy

func (s *Settings) Copy() *Settings

Copy copies the Settings struct

type SetupKey

type SetupKey struct {
	Id string
	// AccountID is a reference to Account that this object belongs
	AccountID string `json:"-" gorm:"index"`
	Key       string
	KeySecret string `gorm:"index"`
	Name      string
	Type      SetupKeyType
	CreatedAt time.Time
	ExpiresAt *time.Time
	UpdatedAt time.Time `gorm:"autoUpdateTime:false"`
	// Revoked indicates whether the key was revoked or not (we don't remove them for tracking purposes)
	Revoked bool
	// UsedTimes indicates how many times the key was used
	UsedTimes int
	// LastUsed last time the key was used for peer registration
	LastUsed *time.Time
	// AutoGroups is a list of Group IDs that are auto assigned to a Peer when it uses this key to register
	AutoGroups []string `gorm:"serializer:json"`
	// UsageLimit indicates the number of times this key can be used to enroll a machine.
	// The value of 0 indicates the unlimited usage.
	UsageLimit int
	// Ephemeral indicate if the peers will be ephemeral or not
	Ephemeral bool
	// AllowExtraDNSLabels indicates if the key allows extra DNS labels
	AllowExtraDNSLabels bool
}

SetupKey represents a pre-authorized key used to register machines (peers)

func GenerateDefaultSetupKey

func GenerateDefaultSetupKey() (*SetupKey, string)

GenerateDefaultSetupKey generates a default reusable setup key with an unlimited usage and 30 days expiration

func GenerateSetupKey

func GenerateSetupKey(name string, t SetupKeyType, validFor time.Duration, autoGroups []string,
	usageLimit int, ephemeral bool, allowExtraDNSLabels bool) (*SetupKey, string)

GenerateSetupKey generates a new setup key

func (*SetupKey) Copy

func (key *SetupKey) Copy() *SetupKey

Copy copies SetupKey to a new object

func (*SetupKey) EventMeta

func (key *SetupKey) EventMeta() map[string]any

EventMeta returns activity event meta related to the setup key

func (*SetupKey) GetExpiresAt added in v0.36.0

func (key *SetupKey) GetExpiresAt() time.Time

GetExpiresAt returns the expiration time of the setup key.

func (*SetupKey) GetLastUsed added in v0.36.0

func (key *SetupKey) GetLastUsed() time.Time

GetLastUsed returns the last used time of the setup key.

func (*SetupKey) IncrementUsage

func (key *SetupKey) IncrementUsage() *SetupKey

IncrementUsage makes a copy of a key, increments the UsedTimes by 1 and sets LastUsed to now

func (*SetupKey) IsExpired

func (key *SetupKey) IsExpired() bool

IsExpired if key was expired

func (*SetupKey) IsOverUsed

func (key *SetupKey) IsOverUsed() bool

IsOverUsed if the key was used too many times. SetupKey.UsageLimit == 0 indicates the unlimited usage.

func (*SetupKey) IsRevoked

func (key *SetupKey) IsRevoked() bool

IsRevoked if key was revoked

func (*SetupKey) IsValid

func (key *SetupKey) IsValid() bool

IsValid is true if the key was not revoked, is not expired and used not more than it was supposed to

type SetupKeyType

type SetupKeyType string

SetupKeyType is the type of setup key

type UpdateOperation added in v0.70.5

type UpdateOperation string

UpdateOperation represents the kind of change that triggered the update.

const (
	UpdateOperationCreate UpdateOperation = "create"
	UpdateOperationUpdate UpdateOperation = "update"
	UpdateOperationDelete UpdateOperation = "delete"
)

type UpdateReason added in v0.70.5

type UpdateReason struct {
	Resource  UpdateResource
	Operation UpdateOperation
}

UpdateReason describes why an account peers update was triggered.

type UpdateResource added in v0.70.5

type UpdateResource string

UpdateResource represents the kind of resource that triggered an account peers update.

const (
	UpdateResourceAccountSettings UpdateResource = "account_settings"
	UpdateResourceDNSSettings     UpdateResource = "dns_settings"
	UpdateResourceGroup           UpdateResource = "group"
	UpdateResourceNameServerGroup UpdateResource = "nameserver_group"
	UpdateResourcePolicy          UpdateResource = "policy"
	UpdateResourcePostureCheck    UpdateResource = "posture_check"
	UpdateResourceRoute           UpdateResource = "route"
	UpdateResourceUser            UpdateResource = "user"
	UpdateResourcePeer            UpdateResource = "peer"
	UpdateResourceNetwork         UpdateResource = "network"
	UpdateResourceNetworkResource UpdateResource = "network_resource"
	UpdateResourceNetworkRouter   UpdateResource = "network_router"
	UpdateResourceService         UpdateResource = "service"
	UpdateResourceZone            UpdateResource = "zone"
	UpdateResourceZoneRecord      UpdateResource = "zone_record"
)

type User

type User struct {
	Id string `gorm:"primaryKey"`
	// AccountID is a reference to Account that this object belongs
	AccountID     string `json:"-" gorm:"index"`
	Role          UserRole
	IsServiceUser bool
	// NonDeletable indicates whether the service user can be deleted
	NonDeletable bool
	// ServiceUserName is only set if IsServiceUser is true
	ServiceUserName string
	// AutoGroups is a list of Group IDs to auto-assign to peers registered by this user
	AutoGroups []string                        `gorm:"serializer:json"`
	PATs       map[string]*PersonalAccessToken `gorm:"-"`
	PATsG      []PersonalAccessToken           `json:"-" gorm:"foreignKey:UserID;references:id;constraint:OnDelete:CASCADE;"`
	// Blocked indicates whether the user is blocked. Blocked users can't use the system.
	Blocked bool
	// PendingApproval indicates whether the user requires approval before being activated
	PendingApproval bool
	// LastLogin is the last time the user logged in to IdP
	LastLogin *time.Time
	// CreatedAt records the time the user was created
	CreatedAt time.Time

	// Issued of the user
	Issued string `gorm:"default:api"`

	IntegrationReference integration_reference.IntegrationReference `gorm:"embedded;embeddedPrefix:integration_ref_"`

	Name  string `gorm:"default:''"`
	Email string `gorm:"default:''"`
}

User represents a user of the system

func NewAdminUser

func NewAdminUser(id string) *User

NewAdminUser creates a new user with role UserRoleAdmin

func NewOwnerUser

func NewOwnerUser(id string, email string, name string) *User

NewOwnerUser creates a new user with role UserRoleOwner

func NewRegularUser

func NewRegularUser(id, email, name string) *User

NewRegularUser creates a new user with role UserRoleUser

func NewUser

func NewUser(id string, role UserRole, isServiceUser bool, nonDeletable bool, serviceUserName string, autoGroups []string, issued string, email string, name string) *User

NewUser creates a new user

func (*User) Copy

func (u *User) Copy() *User

Copy the user

func (*User) DecryptSensitiveData added in v0.62.0

func (u *User) DecryptSensitiveData(enc *crypt.FieldEncrypt) error

DecryptSensitiveData decrypts the user's sensitive fields (Email and Name) in place.

func (*User) EncryptSensitiveData added in v0.62.0

func (u *User) EncryptSensitiveData(enc *crypt.FieldEncrypt) error

EncryptSensitiveData encrypts the user's sensitive fields (Email and Name) in place.

func (*User) GetLastLogin added in v0.36.0

func (u *User) GetLastLogin() time.Time

GetLastLogin returns the last login time of the user.

func (*User) HasAdminPower

func (u *User) HasAdminPower() bool

HasAdminPower returns true if the user has admin or owner roles, false otherwise

func (*User) IsAdminOrServiceUser

func (u *User) IsAdminOrServiceUser() bool

IsAdminOrServiceUser checks if the user has admin power or is a service user.

func (*User) IsBlocked

func (u *User) IsBlocked() bool

IsBlocked returns true if the user is blocked, false otherwise

func (*User) IsRegularUser

func (u *User) IsRegularUser() bool

IsRegularUser checks if the user is a regular user.

func (*User) IsRestrictable added in v0.43.2

func (u *User) IsRestrictable() bool

IsRestrictable checks whether a user is in a restrictable role.

func (*User) LastDashboardLoginChanged

func (u *User) LastDashboardLoginChanged(lastLogin time.Time) bool

func (*User) ToUserInfo

func (u *User) ToUserInfo(userData *idp.UserData) (*UserInfo, error)

ToUserInfo converts a User object to a UserInfo object.

type UserInfo

type UserInfo struct {
	ID                   string                                     `json:"id"`
	Email                string                                     `json:"email"`
	Name                 string                                     `json:"name"`
	Role                 string                                     `json:"role"`
	AutoGroups           []string                                   `json:"auto_groups"`
	Status               string                                     `json:"-"`
	IsServiceUser        bool                                       `json:"is_service_user"`
	IsBlocked            bool                                       `json:"is_blocked"`
	NonDeletable         bool                                       `json:"non_deletable"`
	LastLogin            time.Time                                  `json:"last_login"`
	Issued               string                                     `json:"issued"`
	PendingApproval      bool                                       `json:"pending_approval"`
	Password             string                                     `json:"password"`
	IntegrationReference integration_reference.IntegrationReference `json:"-"`
	// IdPID is the identity provider ID (connector ID) extracted from the Dex-encoded user ID.
	// This field is only populated when the user ID can be decoded from Dex's format.
	IdPID string `json:"idp_id,omitempty"`
}

type UserInvite added in v0.64.2

type UserInvite struct {
	UserInfo        *UserInfo
	InviteToken     string
	InviteExpiresAt time.Time
	InviteCreatedAt time.Time
}

UserInvite contains the result of creating or regenerating an invite

type UserInviteInfo added in v0.64.2

type UserInviteInfo struct {
	Email     string    `json:"email"`
	Name      string    `json:"name"`
	ExpiresAt time.Time `json:"expires_at"`
	Valid     bool      `json:"valid"`
	InvitedBy string    `json:"invited_by"`
}

UserInviteInfo contains public information about an invite (for unauthenticated endpoint)

type UserInviteRecord added in v0.64.2

type UserInviteRecord struct {
	ID          string    `gorm:"primaryKey"`
	AccountID   string    `gorm:"index;not null"`
	Email       string    `gorm:"index;not null"`
	Name        string    `gorm:"not null"`
	Role        string    `gorm:"not null"`
	AutoGroups  []string  `gorm:"serializer:json"`
	HashedToken string    `gorm:"index;not null"` // SHA-256 hash of the token (base64 encoded)
	ExpiresAt   time.Time `gorm:"not null"`
	CreatedAt   time.Time `gorm:"not null"`
	CreatedBy   string    `gorm:"not null"`
}

UserInviteRecord represents an invitation for a user to set up their account (database model)

func (*UserInviteRecord) Copy added in v0.64.2

Copy creates a deep copy of the UserInviteRecord

func (*UserInviteRecord) DecryptSensitiveData added in v0.64.2

func (i *UserInviteRecord) DecryptSensitiveData(enc *crypt.FieldEncrypt) error

DecryptSensitiveData decrypts the invite's sensitive fields (Email and Name) in place.

func (*UserInviteRecord) EncryptSensitiveData added in v0.64.2

func (i *UserInviteRecord) EncryptSensitiveData(enc *crypt.FieldEncrypt) error

EncryptSensitiveData encrypts the invite's sensitive fields (Email and Name) in place.

func (*UserInviteRecord) IsExpired added in v0.64.2

func (i *UserInviteRecord) IsExpired() bool

IsExpired checks if the invite has expired

func (UserInviteRecord) TableName added in v0.64.2

func (UserInviteRecord) TableName() string

TableName returns the table name for GORM

type UserRole

type UserRole string

UserRole is the role of a User

func StrRoleToUserRole

func StrRoleToUserRole(strRole string) UserRole

StrRoleToUserRole returns UserRole for a given strRole or UserRoleUnknown if the specified role is unknown

type UserStatus

type UserStatus string

UserStatus is the status of a User

type Workload added in v0.64.0

type Workload struct {
	Type       JobType         `gorm:"column:workload_type;index;type:varchar(50)"`
	Parameters json.RawMessage `gorm:"type:json"`
	Result     json.RawMessage `gorm:"type:json"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL