domain

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AutoGroupSelf     = "autogroup:self"
	AutoGroupMember   = "autogroup:member"
	AutoGroupMembers  = "autogroup:members"
	AutoGroupTagged   = "autogroup:tagged"
	AutoGroupInternet = "autogroup:internet"
)

Variables

This section is empty.

Functions

func CheckTag

func CheckTag(tag string) error

func CheckTags

func CheckTags(tags []string) error

func SanitizeTailnetName added in v0.2.0

func SanitizeTailnetName(name string) string

func SetDefaultDERPMap added in v0.15.0

func SetDefaultDERPMap(v *tailcfg.DERPMap)

Types

type ACLPolicy

type ACLPolicy struct {
	ionscale.ACLPolicy
}

func (ACLPolicy) BuildFilterRules

func (a ACLPolicy) BuildFilterRules(peers []Machine, dst *Machine) []tailcfg.FilterRule

func (ACLPolicy) BuildSSHPolicy added in v0.4.0

func (a ACLPolicy) BuildSSHPolicy(srcs []Machine, dst *Machine) *tailcfg.SSHPolicy

func (ACLPolicy) CheckTagOwners

func (a ACLPolicy) CheckTagOwners(tags []string, p *User) error

func (*ACLPolicy) Equal added in v0.15.0

func (a *ACLPolicy) Equal(x *ACLPolicy) bool

func (ACLPolicy) FindAutoApprovedIPs added in v0.2.0

func (a ACLPolicy) FindAutoApprovedIPs(routableIPs []netip.Prefix, tags []string, u *User) []netip.Prefix

func (ACLPolicy) GormDBDataType

func (ACLPolicy) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (ACLPolicy) GormDataType

func (ACLPolicy) GormDataType() string

GormDataType gorm common data type

func (ACLPolicy) IsValidPeer

func (a ACLPolicy) IsValidPeer(src *Machine, dest *Machine) bool

func (ACLPolicy) NodeCapabilities added in v0.11.0

func (a ACLPolicy) NodeCapabilities(m *Machine) []tailcfg.NodeCapability

func (*ACLPolicy) Scan

func (i *ACLPolicy) Scan(destination interface{}) error

func (ACLPolicy) Value

func (i ACLPolicy) Value() (driver.Value, error)

type Account

type Account struct {
	ID         uint64 `gorm:"primary_key"`
	ExternalID string
	LoginName  string
}

type AccountRepository added in v0.14.0

type AccountRepository interface {
	GetAccount(ctx context.Context, accountID uint64) (*Account, error)
	GetOrCreateAccount(ctx context.Context, externalID, loginName string) (*Account, bool, error)
	SetAccountLastAuthenticated(ctx context.Context, accountID uint64) error
}

type AllowIPs

type AllowIPs []netip.Prefix

func (AllowIPs) GormDBDataType

func (AllowIPs) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (AllowIPs) GormDataType

func (AllowIPs) GormDataType() string

GormDataType gorm common data type

func (*AllowIPs) Scan

func (hi *AllowIPs) Scan(destination interface{}) error

func (AllowIPs) Value

func (hi AllowIPs) Value() (driver.Value, error)

type AllowIPsSet

type AllowIPsSet struct {
	// contains filtered or unexported fields
}

func NewAllowIPsSet

func NewAllowIPsSet(t AllowIPs) *AllowIPsSet

func (*AllowIPsSet) Add

func (s *AllowIPsSet) Add(t ...netip.Prefix) *AllowIPsSet

func (*AllowIPsSet) Items

func (s *AllowIPsSet) Items() []netip.Prefix

func (*AllowIPsSet) Remove

func (s *AllowIPsSet) Remove(t ...netip.Prefix) *AllowIPsSet

type ApiKey

type ApiKey struct {
	ID   uint64 `gorm:"primary_key"`
	Key  string
	Hash string

	CreatedAt time.Time
	ExpiresAt *time.Time

	TailnetID uint64
	Tailnet   Tailnet

	UserID uint64
	User   User
}

func CreateApiKey

func CreateApiKey(tailnet *Tailnet, user *User, expiresAt *time.Time) (string, *ApiKey)

type ApiKeyRepository added in v0.14.0

type ApiKeyRepository interface {
	SaveApiKey(ctx context.Context, key *ApiKey) error
	LoadApiKey(ctx context.Context, key string) (*ApiKey, error)
	DeleteApiKeysByTailnet(ctx context.Context, tailnetID uint64) error
	DeleteApiKeysByUser(ctx context.Context, userID uint64) error
}

type AuthKey

type AuthKey struct {
	ID            uint64 `gorm:"primary_key"`
	Key           string
	Hash          string
	Ephemeral     bool
	PreAuthorized bool
	Tags          Tags

	CreatedAt time.Time
	ExpiresAt *time.Time

	TailnetID uint64
	Tailnet   Tailnet

	UserID uint64
	User   User
}

func CreateAuthKey

func CreateAuthKey(tailnet *Tailnet, user *User, ephemeral bool, preAuthorized bool, tags Tags, expiresAt *time.Time) (string, *AuthKey)

type AuthKeyRepository added in v0.14.0

type AuthKeyRepository interface {
	GetAuthKey(ctx context.Context, id uint64) (*AuthKey, error)
	SaveAuthKey(ctx context.Context, key *AuthKey) error
	DeleteAuthKey(ctx context.Context, id uint64) (bool, error)
	DeleteAuthKeysByTailnet(ctx context.Context, tailnetID uint64) error
	DeleteAuthKeysByUser(ctx context.Context, userID uint64) error
	ListAuthKeys(ctx context.Context, tailnetID uint64) ([]AuthKey, error)
	ListAuthKeysByTailnetAndUser(ctx context.Context, tailnetID, userID uint64) ([]AuthKey, error)
	LoadAuthKey(ctx context.Context, key string) (*AuthKey, error)
}

type AuthenticationRequest

type AuthenticationRequest struct {
	Key       string `gorm:"primary_key"`
	Token     string
	TailnetID *uint64
	Error     string
	CreatedAt time.Time
}

type AuthenticationRequestRepository added in v0.14.0

type AuthenticationRequestRepository interface {
	SaveAuthenticationRequest(ctx context.Context, session *AuthenticationRequest) error
	GetAuthenticationRequest(ctx context.Context, key string) (*AuthenticationRequest, error)
	DeleteAuthenticationRequest(ctx context.Context, key string) error
}

type AutoApprovers added in v0.2.0

type AutoApprovers struct {
	Routes   map[string][]string `json:"routes,omitempty"`
	ExitNode []string            `json:"exitNode,omitempty"`
}

type ControlKeys added in v0.2.0

type ControlKeys struct {
	ControlKey       tkey.MachinePrivate
	LegacyControlKey tkey.MachinePrivate
}

type DERPMap added in v0.4.0

type DERPMap struct {
	Checksum string
	DERPMap  tailcfg.DERPMap
}

func GetDefaultDERPMap added in v0.15.0

func GetDefaultDERPMap() DERPMap

func WrapDERPMap added in v0.15.0

func WrapDERPMap(d tailcfg.DERPMap) DERPMap

func (DERPMap) GetDERPMap added in v0.15.0

func (d DERPMap) GetDERPMap(_ context.Context) (*DERPMap, error)

func (DERPMap) GormDBDataType added in v0.4.0

func (DERPMap) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (DERPMap) GormDataType added in v0.4.0

func (DERPMap) GormDataType() string

GormDataType gorm common data type

func (*DERPMap) Scan added in v0.4.0

func (hi *DERPMap) Scan(destination interface{}) error

func (DERPMap) Value added in v0.4.0

func (hi DERPMap) Value() (driver.Value, error)

type DNSConfig

type DNSConfig struct {
	HttpsCertsEnabled bool                `json:"http_certs"`
	MagicDNS          bool                `json:"magic_dns"`
	OverrideLocalDNS  bool                `json:"override_local_dns"`
	Nameservers       []string            `json:"nameservers"`
	Routes            map[string][]string `json:"routes"`
	SearchDomains     []string            `json:"search_domains"`
}

func (*DNSConfig) Equal added in v0.15.0

func (i *DNSConfig) Equal(x *DNSConfig) bool

func (DNSConfig) GormDBDataType

func (DNSConfig) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (DNSConfig) GormDataType

func (DNSConfig) GormDataType() string

GormDataType gorm common data type

func (*DNSConfig) Scan

func (i *DNSConfig) Scan(destination interface{}) error

func (DNSConfig) Value

func (i DNSConfig) Value() (driver.Value, error)

type DefaultDERPMap added in v0.4.0

type DefaultDERPMap interface {
	GetDERPMap(ctx context.Context) (*DERPMap, error)
}

type Endpoints

type Endpoints []netip.AddrPort

func (Endpoints) GormDBDataType

func (Endpoints) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (Endpoints) GormDataType

func (Endpoints) GormDataType() string

GormDataType gorm common data type

func (*Endpoints) Scan

func (hi *Endpoints) Scan(destination interface{}) error

func (Endpoints) Value

func (hi Endpoints) Value() (driver.Value, error)

type HostInfo

type HostInfo tailcfg.Hostinfo

func (HostInfo) GormDBDataType

func (HostInfo) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (HostInfo) GormDataType

func (HostInfo) GormDataType() string

GormDataType gorm common data type

func (*HostInfo) Scan

func (hi *HostInfo) Scan(destination interface{}) error

func (HostInfo) Value

func (hi HostInfo) Value() (driver.Value, error)

type HuJSON added in v0.15.0

type HuJSON[T any] struct {
	// contains filtered or unexported fields
}

func NewHuJSON added in v0.15.0

func NewHuJSON[T any](t *T) HuJSON[T]

func ParseHuJson added in v0.15.0

func ParseHuJson[T any](v string) (*HuJSON[T], error)

func (*HuJSON[T]) Equal added in v0.15.0

func (i *HuJSON[T]) Equal(x *HuJSON[T]) bool

func (*HuJSON[T]) Get added in v0.15.0

func (h *HuJSON[T]) Get() *T

func (*HuJSON[T]) Scan added in v0.15.0

func (h *HuJSON[T]) Scan(destination interface{}) error

func (*HuJSON[T]) String added in v0.15.0

func (h *HuJSON[T]) String() string

func (HuJSON[T]) Value added in v0.15.0

func (h HuJSON[T]) Value() (driver.Value, error)

type IAMPolicy

type IAMPolicy struct {
	Subs    []string            `json:"subs,omitempty"`
	Emails  []string            `json:"emails,omitempty"`
	Filters []string            `json:"filters,omitempty"`
	Roles   map[string]UserRole `json:"roles,omitempty"`
}

func (*IAMPolicy) Equal added in v0.15.0

func (i *IAMPolicy) Equal(x *IAMPolicy) bool

func (*IAMPolicy) EvaluatePolicy

func (i *IAMPolicy) EvaluatePolicy(identity *Identity) (bool, error)

func (*IAMPolicy) GetRole

func (i *IAMPolicy) GetRole(user User) UserRole

func (IAMPolicy) GormDBDataType

func (IAMPolicy) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (IAMPolicy) GormDataType

func (IAMPolicy) GormDataType() string

GormDataType gorm common data type

func (*IAMPolicy) Scan

func (i *IAMPolicy) Scan(destination interface{}) error

func (IAMPolicy) Value

func (i IAMPolicy) Value() (driver.Value, error)

type IP

type IP struct {
	*netip.Addr
}

func (IP) GormDBDataType

func (IP) GormDBDataType(db *gorm.DB, field *schema.Field) string

func (*IP) Scan

func (i *IP) Scan(destination interface{}) error

func (IP) Value

func (i IP) Value() (driver.Value, error)

type Identity

type Identity struct {
	UserID   string
	Username string
	Email    string
	Attr     map[string]interface{}
}

type JSONWebKey added in v0.3.0

type JSONWebKey struct {
	Id         string
	PrivateKey rsa.PrivateKey
	CreatedAt  time.Time
}

func (JSONWebKey) Public added in v0.3.0

func (j JSONWebKey) Public() crypto.PublicKey

type JSONWebKeys added in v0.3.0

type JSONWebKeys struct {
	Key JSONWebKey
}

type Machine

type Machine struct {
	ID                uint64 `gorm:"primary_key"`
	Name              string
	NameIdx           uint64
	MachineKey        string
	NodeKey           string
	DiscoKey          string
	Ephemeral         bool
	RegisteredTags    Tags
	Tags              Tags
	KeyExpiryDisabled bool
	Authorized        bool

	HostInfo     HostInfo
	Endpoints    Endpoints
	AllowIPs     AllowIPs
	AutoAllowIPs AllowIPs

	IPv4 IP
	IPv6 IP

	CreatedAt time.Time
	ExpiresAt time.Time
	LastSeen  *time.Time

	UserID uint64
	User   User

	TailnetID uint64
	Tailnet   Tailnet
}

func (*Machine) AdvertisedPrefixes added in v0.2.0

func (m *Machine) AdvertisedPrefixes() []string

func (*Machine) AllowedPrefixes added in v0.2.0

func (m *Machine) AllowedPrefixes() []string

func (*Machine) CompleteName added in v0.3.0

func (m *Machine) CompleteName() string

func (*Machine) HasIP

func (m *Machine) HasIP(v netip.Addr) bool

func (*Machine) HasTag

func (m *Machine) HasTag(tag string) bool

func (*Machine) HasTags

func (m *Machine) HasTags() bool

func (*Machine) HasUser

func (m *Machine) HasUser(loginName string) bool

func (*Machine) IPs added in v0.2.0

func (m *Machine) IPs() []string

func (*Machine) IsAdvertisedExitNode added in v0.2.0

func (m *Machine) IsAdvertisedExitNode() bool

func (*Machine) IsAllowedExitNode added in v0.2.0

func (m *Machine) IsAllowedExitNode() bool

func (*Machine) IsAllowedIP

func (m *Machine) IsAllowedIP(i netip.Addr) bool

func (*Machine) IsAllowedIPPrefix

func (m *Machine) IsAllowedIPPrefix(i netip.Prefix) bool

func (*Machine) IsExitNode added in v0.2.0

func (m *Machine) IsExitNode() bool

func (*Machine) IsExpired

func (m *Machine) IsExpired() bool

type MachineRepository added in v0.14.0

type MachineRepository interface {
	SaveMachine(ctx context.Context, m *Machine) error
	DeleteMachine(ctx context.Context, id uint64) (bool, error)
	GetMachine(ctx context.Context, id uint64) (*Machine, error)
	GetMachineByKeyAndUser(ctx context.Context, key string, userID uint64) (*Machine, error)
	GetMachineByKeys(ctx context.Context, machineKey string, nodeKey string) (*Machine, error)
	CountMachinesWithIPv4(ctx context.Context, ip string) (int64, error)
	GetNextMachineNameIndex(ctx context.Context, tailnetID uint64, name string) (uint64, error)
	ListMachineByTailnet(ctx context.Context, tailnetID uint64) (Machines, error)
	CountMachineByTailnet(ctx context.Context, tailnetID uint64) (int64, error)
	DeleteMachineByTailnet(ctx context.Context, tailnetID uint64) error
	DeleteMachineByUser(ctx context.Context, userID uint64) error
	ListMachinePeers(ctx context.Context, tailnetID uint64, machineID uint64) (Machines, error)
	ListInactiveEphemeralMachines(ctx context.Context, checkpoint time.Time) (Machines, error)
	SetMachineLastSeen(ctx context.Context, machineID uint64) error
}

type Machines

type Machines []Machine

type Principal

type Principal struct {
	SystemRole SystemRole
	User       *User
	UserRole   UserRole
}

func (Principal) IsSystemAdmin

func (p Principal) IsSystemAdmin() bool

func (Principal) IsTailnetAdmin

func (p Principal) IsTailnetAdmin(tailnetID uint64) bool

func (Principal) IsTailnetMember

func (p Principal) IsTailnetMember(tailnetID uint64) bool

func (Principal) UserMatches

func (p Principal) UserMatches(userID uint64) bool

type RegistrationRequest

type RegistrationRequest struct {
	MachineKey    string `gorm:"primary_key"`
	Key           string
	Data          RegistrationRequestData
	CreatedAt     time.Time
	Authenticated bool
	Error         string
	UserID        uint64
}

type RegistrationRequestData

type RegistrationRequestData tailcfg.RegisterRequest

func (RegistrationRequestData) GormDBDataType

func (RegistrationRequestData) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (RegistrationRequestData) GormDataType

func (RegistrationRequestData) GormDataType() string

GormDataType gorm common data type

func (*RegistrationRequestData) Scan

func (hi *RegistrationRequestData) Scan(destination interface{}) error

func (RegistrationRequestData) Value

func (hi RegistrationRequestData) Value() (driver.Value, error)

type RegistrationRequestRepository added in v0.14.0

type RegistrationRequestRepository interface {
	SaveRegistrationRequest(ctx context.Context, request *RegistrationRequest) error
	GetRegistrationRequestByKey(ctx context.Context, key string) (*RegistrationRequest, error)
	GetRegistrationRequestByMachineKey(ctx context.Context, key string) (*RegistrationRequest, error)
}

type SSHActionRequest added in v0.4.0

type SSHActionRequest struct {
	Key          string `gorm:"primary_key"`
	Action       string
	SrcMachineID uint64
	DstMachineID uint64
	CreatedAt    time.Time
}

type SSHActionRequestRepository added in v0.14.0

type SSHActionRequestRepository interface {
	SaveSSHActionRequest(ctx context.Context, session *SSHActionRequest) error
	GetSSHActionRequest(ctx context.Context, key string) (*SSHActionRequest, error)
	DeleteSSHActionRequest(ctx context.Context, key string) error
}

type ServerConfig

type ServerConfig struct {
	Key   configKey `gorm:"primary_key"`
	Value []byte
}

type StringSet

type StringSet struct {
	// contains filtered or unexported fields
}

func (*StringSet) Add

func (s *StringSet) Add(t ...string) *StringSet

func (*StringSet) Empty added in v0.12.0

func (s *StringSet) Empty() bool

func (*StringSet) Items

func (s *StringSet) Items() []string

type SystemApiKey

type SystemApiKey struct {
	ID   uint64 `gorm:"primary_key"`
	Key  string
	Hash string

	CreatedAt time.Time
	ExpiresAt *time.Time

	AccountID uint64
	Account   Account
}

func CreateSystemApiKey

func CreateSystemApiKey(account *Account, expiresAt *time.Time) (string, *SystemApiKey)

type SystemApiKeyRepository added in v0.14.0

type SystemApiKeyRepository interface {
	SaveSystemApiKey(ctx context.Context, key *SystemApiKey) error
	LoadSystemApiKey(ctx context.Context, key string) (*SystemApiKey, error)
}

type SystemRole

type SystemRole string
const (
	SystemRoleNone  SystemRole = ""
	SystemRoleAdmin SystemRole = "admin"
)

func (SystemRole) IsAdmin

func (s SystemRole) IsAdmin() bool

type Tags

type Tags []string

func SanitizeTags

func SanitizeTags(input []string) Tags

func (*Tags) Scan

func (i *Tags) Scan(destination interface{}) error

func (Tags) Value

func (i Tags) Value() (driver.Value, error)

type Tailnet

type Tailnet struct {
	ID                          uint64 `gorm:"primary_key"`
	Name                        string
	DNSConfig                   DNSConfig
	IAMPolicy                   HuJSON[IAMPolicy]
	ACLPolicy                   HuJSON[ACLPolicy]
	DERPMap                     DERPMap
	ServiceCollectionEnabled    bool
	FileSharingEnabled          bool
	SSHEnabled                  bool
	MachineAuthorizationEnabled bool
}

func (Tailnet) GetDERPMap added in v0.4.0

func (t Tailnet) GetDERPMap(ctx context.Context, fallack DefaultDERPMap) (*DERPMap, error)

type TailnetRepository added in v0.14.0

type TailnetRepository interface {
	SaveTailnet(ctx context.Context, tailnet *Tailnet) error
	GetTailnet(ctx context.Context, id uint64) (*Tailnet, error)
	GetTailnetByName(ctx context.Context, name string) (*Tailnet, error)
	ListTailnets(ctx context.Context) ([]Tailnet, error)
	DeleteTailnet(ctx context.Context, id uint64) error
}

type User

type User struct {
	ID                uint64 `gorm:"primary_key"`
	Name              string
	UserType          UserType
	LastAuthenticated *time.Time
	TailnetID         uint64
	Tailnet           Tailnet
	AccountID         *uint64
	Account           *Account
}

type UserRepository added in v0.14.0

type UserRepository interface {
	GetOrCreateServiceUser(ctx context.Context, tailnet *Tailnet) (*User, bool, error)
	GetOrCreateUserWithAccount(ctx context.Context, tailnet *Tailnet, account *Account) (*User, bool, error)
	GetUser(ctx context.Context, userID uint64) (*User, error)
	DeleteUser(ctx context.Context, userID uint64) error
	ListUsers(ctx context.Context, tailnetID uint64) (Users, error)
	DeleteUsersByTailnet(ctx context.Context, tailnetID uint64) error
	SetUserLastAuthenticated(ctx context.Context, userID uint64, timestamp time.Time) error
}

type UserRole

type UserRole string
const (
	UserRoleNone   UserRole = ""
	UserRoleMember UserRole = "member"
	UserRoleAdmin  UserRole = "admin"
)

func (UserRole) IsAdmin

func (s UserRole) IsAdmin() bool

type UserType

type UserType string
const (
	UserTypeService UserType = "service"
	UserTypePerson  UserType = "person"
)

type Users

type Users []User

Jump to

Keyboard shortcuts

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