models

package
v0.0.0-...-bbf9adb Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CredentialsTypeUser  = "User"
	CredentialsTypeToken = "Token"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Name         string        `json:"name,omitempty"`
	Email        string        `json:"email,omitempty"`
	UserID       string        `json:"user_id,omitempty"`
	SshUsername  string        `json:"user_name,omitempty"`
	SshKey       string        `json:"sshkey,omitempty"`
	Organization *Organization `json:"primary_organization"`
}

type AddSocketToPolicyRequest

type AddSocketToPolicyRequest struct {
	Actions []PolicyActionUpdateRequest `json:"actions" binding:"required"`
}

type ClientResource

type ClientResource struct {
	IPAddress                      string   `json:"ip_address,omitempty"`
	SocketType                     string   `json:"socket_type,omitempty"`
	SocketName                     string   `json:"socket_name,omitempty"`
	Description                    string   `json:"description,omitempty"`
	SocketPorts                    []int    `json:"socket_ports,omitempty"`
	Domains                        []string `json:"domains,omitempty"`
	DatabaseType                   string   `json:"database_type,omitempty"`
	SshType                        string   `json:"ssh_type,omitempty"`
	ConnectorAuthenticationEnabled bool     `json:"connector_authentication_enabled,omitempty"`
	EndToEndEncryptionEnabled      bool     `json:"end_to_end_encryption_enabled,omitempty"`
	HasUpstreamUsername            bool     `json:"has_upstream_username,omitempty"`
}

func (ClientResource) DomainsToString

func (c ClientResource) DomainsToString() string

func (ClientResource) FirstDomain

func (c ClientResource) FirstDomain(defaultValue string) string

func (ClientResource) HasDomain

func (c ClientResource) HasDomain(tryToFind string) bool

func (ClientResource) Hostname

func (c ClientResource) Hostname() string

func (ClientResource) Instruction

func (c ClientResource) Instruction() string

type ClientResources

type ClientResources struct {
	RefreshHint        int              `json:"refresh_hint,omitempty"`
	Resources          []ClientResource `json:"resources,omitempty"`
	DefaultIPAddresses []string         `json:"ip_addresses,omitempty"`
}

type Condition

type Condition struct {
	Who   ConditionWho   `json:"who,omitempty" mapstructure:"who"`
	Where ConditionWhere `json:"where,omitempty" mapstructure:"where"`
	When  ConditionWhen  `json:"when,omitempty" mapstructure:"when"`
}

type ConditionWhat

type ConditionWhat struct{}

type ConditionWhen

type ConditionWhen struct {
	After           string `json:"after,omitempty" mapstructure:"after"`
	Before          string `json:"before,omitempty" mapstructure:"before"`
	TimeOfDayAfter  string `json:"time_of_day_after,omitempty" mapstructure:"time_of_day_after"`
	TimeOfDayBefore string `json:"time_of_day_before,omitempty" mapstructure:"time_of_day_before"`
}

type ConditionWhere

type ConditionWhere struct {
	AllowedIP  []string `json:"allowed_ip,omitempty" mapstructure:"allowed_ip"`
	Country    []string `json:"country,omitempty" mapstructure:"country"`
	CountryNot []string `json:"country_not,omitempty" mapstructure:"country_not"`
}

type ConditionWho

type ConditionWho struct {
	Email          []string `json:"email,omitempty" mapstructure:"email"`
	Domain         []string `json:"domain,omitempty" mapstructure:"domain"`
	Group          []string `json:"group,omitempty" mapstructure:"group"`
	ServiceAccount []string `json:"service_account,omitempty" mapstructure:"service_account"`
}

type Connector

type Connector struct {
	Name                           string                                  `json:"name"`
	ConnectorID                    string                                  `json:"connector_id"`
	BuiltInSshServiceEnabled       bool                                    `json:"built_in_ssh_service_enabled"`
	BuiltInSshServiceConfiguration *service.BuiltInSshServiceConfiguration `json:"built_in_ssh_service_configuration,omitempty"`
	Description                    string                                  `json:"description"`
	ActiveTokens                   int                                     `json:"active_tokens"`
	Metadata                       map[string]interface{}                  `json:"metadata"`
	CreatedAt                      *time.Time                              `json:"created_at"`
	UpdatedAt                      *time.Time                              `json:"updated_at"`
	LastSeenAt                     *time.Time                              `json:"last_seen_at"`
}

Connector represents a cloud-managed Border0 Connector.

type ConnectorData

type ConnectorData struct {
	Name           string
	Connector      string
	ProviderEnv    string
	ProviderType   string
	ProviderRegion string
	Type           string
	Port           int
	TargetHostname string
	PolicyGroup    string
	Ec2Tag         string
	InstanceId     string
	PluginName     string
	ManagedBy      string
}

func (*ConnectorData) Key

func (c *ConnectorData) Key() string

func (*ConnectorData) Tags

func (c *ConnectorData) Tags() map[string]string

type ConnectorList

type ConnectorList struct {
	List []Connector `json:"list"`
}

ConnectorList represents a list of connectors

type ConnectorLocalData

type ConnectorLocalData struct {
	UpstreamUsername               string
	UpstreamPassword               string
	UpstreamCertFile               string
	UpstreamKeyFile                string
	UpstreamCACertFile             string
	UpstreamCertBlock              []byte
	UpstreamKeyBlock               []byte
	UpstreamCACertBlock            []byte
	UpstreamTLS                    *bool
	UpstreamIdentifyFile           string
	UpstreamIdentityPrivateKey     []byte
	SqlAuthProxy                   bool
	RdsIAMAuth                     bool
	AWSRegion                      string
	CloudSQLConnector              bool
	CloudSQLIAMAuth                bool
	CloudSQLInstance               string
	GoogleCredentialsFile          string
	GoogleCredentialsJSON          []byte
	SSHServer                      bool
	AWSECSCluster                  string
	AWSECSServices                 []string
	AWSECSTasks                    []string
	AWSECSContainers               []string
	AwsEC2InstanceId               string
	AWSEC2InstanceConnectEnabled   bool
	AwsCredentials                 *common.AwsCredentials
	IsDockerExec                   bool
	DockerContainerNameAllowlist   []string
	IsKubectlExec                  bool
	K8sNamespaceAllowlist          []string
	K8sNamespaceSelectorsAllowlist map[string]map[string][]string
	K8sMasterUrl                   string
	K8sKubeconfigPath              string
	IsAwsEks                       bool
	AwsEksCluster                  string
	AzureAD                        bool
	Kerberos                       bool

	// vpn sockets
	DHCPPoolSubnet   string
	AdvertisedRoutes []string
}

type ConnectorPlugin

type ConnectorPlugin struct {
	ID            string                        `json:"id"`
	Enabled       bool                          `json:"enabled"`
	PluginType    string                        `json:"plugin_type"`
	Configuration connector.PluginConfiguration `json:"configuration"`
}

ConnectorPlugin represents a plugin for a Border0 Connector.

type ConnectorPluginRequest

type ConnectorPluginRequest struct {
	ConnectorId   string                         `json:"connector_id"`
	Enabled       bool                           `json:"enabled"`
	PluginType    string                         `json:"plugin_type"`
	Configuration *connector.PluginConfiguration `json:"configuration"`
}

ConnectorPluginRequest represents a request to create a plugin for a Border0 Connector.

type ConnectorToken

type ConnectorToken struct {
	ConnectorName string `json:"connector_name,omitempty"`
	Name          string `json:"name,omitempty"`
	ExpiresAt     string `json:"expires_at,omitempty"`
	Token         string `json:"token,omitempty"`
}

ConnectorToken represents a token for a Border0 Connector.

type ConnectorTokenRequest

type ConnectorTokenRequest struct {
	ConnectorId string `json:"connector_id,omitempty"`
	Name        string `json:"name,omitempty"`
	ExpiresAt   int64  `json:"expires_at,omitempty"`
}

ConnectorTokenRequest represents a request to create a token for a Border0 Connector.

type ConnectorWithInstallTokenRequest

type ConnectorWithInstallTokenRequest struct {
	Connector
	InstallToken string `json:"install_token"`
}

ConnectorWithInstallTokenRequest represents a request to create a Border0 connector and connector token with an install token.

type ConnectorWithInstallTokenResponse

type ConnectorWithInstallTokenResponse struct {
	Connector      Connector      `json:"connector"`
	ConnectorToken ConnectorToken `json:"connector_token"`
}

ConnectorWithInstallTokenResponse represents a response from the request that created a Border0 connector and connector token with an install token.

type CreatePolicyRequest

type CreatePolicyRequest struct {
	Name        string     `json:"name" binding:"required"`
	Description string     `json:"description"`
	PolicyData  PolicyData `json:"policy_data" binding:"required"`
	Orgwide     bool       `json:"org_wide"`
}

type Credentials

type Credentials struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	TokenType   string `json:"token_type"`
}

func NewCredentials

func NewCredentials(accessToken string, credentialsType string) *Credentials

func (*Credentials) ShouldRefresh

func (a *Credentials) ShouldRefresh() bool

type DatabaseActions

type DatabaseActions struct {
	Schemas                   []DatabaseSchemaAction `json:"schemas" mapstructure:"schemas"`
	ReadOnly                  bool                   `json:"read_only" mapstructure:"read_only"`
	AllowedQueryTypes         []string               `json:"allowed_query_types,omitempty" mapstructure:"allowed_query_types,omitempty"`
	MaxSessionDurationSeconds int                    `json:"max_session_duration_seconds" mapstructure:"max_session_duration_seconds"`
}

type DatabaseSchemaAction

type DatabaseSchemaAction struct {
	Schema            string   `json:"schema" mapstructure:"schema"`
	AllowedQueryTypes []string `json:"allowed_query_types" mapstructure:"allowed_query_types"`
	ReadOnly          bool     `json:"read_only" mapstructure:"read_only"`
}

type Domain

type Domain struct {
	Domain  string `json:"domain"`
	Default bool   `json:"default"`
}

type EvaluatePolicyRequest

type EvaluatePolicyRequest struct {
	ClientIP   string `json:"client_ip"`
	UserEmail  string `json:"user_email"`
	SessionKey string `json:"session_key"`
}

type EvaluatePolicyResponse

type EvaluatePolicyResponse struct {
	Actions map[string][]any    `json:"allowed_actions"`
	Info    map[string][]string `json:"info"`
}

type ExtendedAction

type ExtendedAction struct {
	Database *DatabaseActions `json:"database" mapstructure:"database"`
	Ssh      *SSHActions      `json:"ssh" mapstructure:"ssh"`
}

type KubectlExecNamespace

type KubectlExecNamespace struct {
	Namespace   string            `json:"namespace" mapstructure:"namespace"`
	PodSelector map[string]string `json:"pod_selector" mapstructure:"pod_selector"`
}

type LoginForm

type LoginForm struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type LoginRefresh

type LoginRefresh struct {
}

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type LoginResponse

type LoginResponse struct {
	Token string `json:"token"`
	MFA   bool   `json:"require_mfa"`
}

type Metadata

type Metadata struct {
	Principal      string // e.g. "token:${token_uuid}" OR "user:${user_uuid}"
	ProviderEnv    string // e.g. "prod, or "dev"
	ProviderRegion string // e.g. "us-east-1
	ProviderType   string // e.g. "aws
}

type MfaForm

type MfaForm struct {
	Code string `json:"code"`
}

type Notification

type Notification struct {
	Name            string   `json:"name"`
	Type            string   `json:"type"`
	Enabled         bool     `json:"enabled"`
	Events          []string `json:"events"`
	WebhookURL      string   `json:"webhook_url,omitempty"`
	EmailRecipients []string `json:"email_recipients,omitempty"`
}

type NotificationUpdate

type NotificationUpdate struct {
	Enabled         *bool    `json:"enabled,omitempty"`
	Events          []string `json:"events,omitempty"`
	WebhookURL      *string  `json:"webhook_url,omitempty"`
	EmailRecipients []string `json:"email_recipients,omitempty"`
}

type Organization

type Organization struct {
	ID           string            `json:"id"`
	Name         string            `json:"name"`
	Subdomain    string            `json:"subdomain"`
	Certificates map[string]string `json:"certificate"`
}

type Policy

type Policy struct {
	ID          string     `json:"id"`
	Name        string     `json:"name"`
	Description string     `json:"description"`
	PolicyData  PolicyData `json:"policy_data"`
	SocketIDs   []string   `json:"socket_ids"`
	OrgID       string     `json:"org_id"`
	OrgWide     bool       `json:"org_wide"`
	CreatedAt   time.Time  `json:"created_at"`
}

type PolicyActionUpdateRequest

type PolicyActionUpdateRequest struct {
	Action string `json:"action" binding:"required"`
	ID     string `json:"id" binding:"required"`
}

type PolicyData

type PolicyData struct {
	Version   string    `json:"version"`
	Action    any       `json:"action"`
	Condition Condition `json:"condition" mapstructure:"condition"`
}

type PolicyTest

type PolicyTest struct {
	Email     string `json:"email" binding:"required"`
	IPAddress string `json:"ip_address" binding:"required"`
	Time      string `json:"time" binding:"required"`
}

type PolicyTestRespone

type PolicyTestRespone struct {
	Actions map[string][]string `json:"Actions,omitempty"`
	Info    struct {
		Allowed []string `json:"allowed,omitempty"`
		Failed  []string `json:"failed,omitempty"`
	} `json:"Info,omitempty"`
}

type RegisterForm

type RegisterForm struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Password string `json:"password"`
	Sshkey   string `json:"sshkey"`
}

type ResultValue

type ResultValue string
const (
	ResultSuccess ResultValue = "success"
	ResultDenied  ResultValue = "denied"
)

type SSHActions

type SSHActions struct {
	Shell                     SSHShellAction         `json:"shell" mapstructure:"shell"`
	Exec                      SSHExecAction          `json:"exec" mapstructure:"exec"`
	SFTP                      SSHSFTPAction          `json:"sftp" mapstructure:"sftp"`
	TcpForwarding             SSHTcpForwardingAction `json:"tcp_forwarding" mapstructure:"tcp_forwarding"`
	KubectlExec               SSHKubectlExecAction   `json:"kubectl_exec" mapstructure:"kubectl_exec"`
	DockerExec                SSHDockerExecAction    `json:"docker_exec" mapstructure:"docker_exec"`
	MaxSessionDurationSeconds int                    `json:"max_session_duration_seconds" mapstructure:"max_session_duration_seconds"`
	AllowedUsernames          []string               `json:"allowed_usernames" mapstructure:"allowed_usernames"`
}

type SSHDockerExecAction

type SSHDockerExecAction struct {
	Enabled           bool     `json:"enabled" mapstructure:"enabled"`
	AllowedContainers []string `json:"allowed_containers" mapstructure:"allowed_containers"`
}

type SSHExecAction

type SSHExecAction struct {
	Enabled  bool     `json:"enabled" mapstructure:"enabled"`
	Commands []string `json:"commands" mapstructure:"commands"`
}

type SSHKubectlExecAction

type SSHKubectlExecAction struct {
	Enabled           bool                   `json:"enabled" mapstructure:"enabled"`
	AllowedNamespaces []KubectlExecNamespace `json:"allowed_namespaces" mapstructure:"allowed_namespaces"`
	PodSelector       map[string]string      `json:"pod_selector" mapstructure:"pod_selector"`
}

type SSHSFTPAction

type SSHSFTPAction struct {
	Enabled bool `json:"enabled" mapstructure:"enabled"`
}

type SSHShellAction

type SSHShellAction struct {
	Enabled bool `json:"enabled" mapstructure:"enabled"`
}

type SSHTcpForwardingAction

type SSHTcpForwardingAction struct {
	Enabled            bool                         `json:"enabled" mapstructure:"enabled"`
	AllowedConnections []SSHTcpForwardingConnection `json:"allowed_connections" mapstructure:"allowed_connections"`
}

type SSHTcpForwardingConnection

type SSHTcpForwardingConnection struct {
	DestinationAddress *string `json:"destination_address,omitempty" mapstructure:"destination_address,omitempty"`
	DestinationPort    *int    `json:"destination_port,omitempty" mapstructure:"destination_port,omitempty"`
}

type SessionTokenForm

type SessionTokenForm struct {
	Token string `json:"token"`
	MFA   bool   `json:"require_mfa"`
	State string `json:"state"`
}

type SessionUpdate

type SessionUpdate struct {
	SessionKey string
	Socket     *Socket
	UserData   string
}

type SignSshOrgCertificateRequest

type SignSshOrgCertificateRequest struct {
	SocketID   string `json:"socket_id"`
	SessionKey string `json:"session_key"`
	UserEmail  string `json:"user_email"`
	Ticket     string `json:"ticket"`
	PublicKey  string `json:"public_key"`
}

type SignSshOrgCertificateResponse

type SignSshOrgCertificateResponse struct {
	Certificate string `json:"certificate"`
}

type Socket

type Socket struct {
	Tunnels                        []Tunnel          `json:"tunnels,omitempty"`
	Username                       string            `json:"user_name,omitempty"`
	SocketID                       string            `json:"socket_id,omitempty"`
	SocketTcpPorts                 []int             `json:"socket_tcp_ports,omitempty"`
	Dnsname                        string            `json:"dnsname,omitempty"`
	Name                           string            `json:"name,omitempty"`
	Description                    string            `json:"description,omitempty"`
	SocketType                     string            `json:"socket_type,omitempty"`
	AllowedEmailAddresses          []string          `json:"cloud_authentication_email_allowed_addressses,omitempty"`
	AllowedEmailDomains            []string          `json:"cloud_authentication_email_allowed_domains,omitempty"`
	SSHCa                          string            `json:"ssh_ca,omitempty"`
	UpstreamUsername               *string           `json:"upstream_username,omitempty"`
	UpstreamPassword               *string           `json:"upstream_password,omitempty"`
	UpstreamCert                   *string           `json:"upstream_cert,omitempty"`
	UpstreamKey                    *string           `json:"upstream_key,omitempty"`
	UpstreamCa                     *string           `json:"upstream_ca,omitempty"`
	UpstreamHttpHostname           *string           `json:"upstream_http_hostname,omitempty"`
	UpstreamType                   string            `json:"upstream_type,omitempty"`
	CloudAuthEnabled               bool              `json:"cloud_authentication_enabled,omitempty"`
	ConnectorAuthenticationEnabled bool              `json:"connector_authentication_enabled,omitempty"`
	EndToEndEncryptionEnabled      bool              `json:"end_to_end_encryption_enabled,omitempty"`
	RecordingEnabled               bool              `json:"recording_enabled,omitempty"`
	Tags                           map[string]string `json:"tags,omitempty"`
	CustomDomains                  []string          `json:"custom_domains,omitempty"`
	PolicyNames                    []string          `json:"policy_names,omitempty"`
	Policies                       []Policy          `json:"policies,omitempty"`
	OrgCustomDomain                string            `json:"org_custom_domain,omitempty"`

	TargetHostname     string              `json:"-"`
	TargetPort         int                 `json:"-"`
	PolicyGroup        string              `json:"-"`
	Ec2Tag             string              `json:"-"`
	InstanceId         string              `json:"-"`
	PluginName         string              `json:"-"`
	ManagedBy          string              `json:"-"`
	ConnectorData      *ConnectorData      `json:"-"`
	ConnectorLocalData *ConnectorLocalData `json:"-"`

	IsBorder0Certificate bool `json:"-"`

	UpstreamCertFile      string `json:"-"`
	UpstreamKeyFile       string `json:"-"`
	UpstreamCACertFile    string `json:"-"`
	UpstreamIdentifyFile  string `json:"-"`
	UpstreamTLS           *bool  `json:"-"`
	RdsIAMAuth            bool   `json:"-"`
	AWSRegion             string `json:"-"`
	CloudSQLConnector     bool   `json:"-"`
	CloudSQLIAMAuth       bool   `json:"-"`
	CloudSQLInstance      string `json:"-"`
	GoogleCredentialsFile string `json:"-"`
	SSHServer             bool   `json:"-"`
}

func (*Socket) BuildConnectorData

func (s *Socket) BuildConnectorData(connectorName string, metadata Metadata)

func (*Socket) BuildConnectorDataAndTags

func (s *Socket) BuildConnectorDataAndTags(connectorName string, metadata Metadata)

func (*Socket) BuildConnectorDataByTags

func (s *Socket) BuildConnectorDataByTags()

func (*Socket) SanitizeName

func (s *Socket) SanitizeName()

func (*Socket) SetupTypeAndUpstreamTypeByPortOrTags

func (s *Socket) SetupTypeAndUpstreamTypeByPortOrTags()

type SshCsr

type SshCsr struct {
	SSHPublicKey  string `json:"ssh_public_key"`
	SSHSignedCert string `json:"signed_ssh_cert,omitempty"`
	HostKey       string `json:"host_key,omitempty"`
}

type SwitchOrgRequest

type SwitchOrgRequest struct {
	OrgName string `json:"org_name"`
}

type SwitchOrgResponse

type SwitchOrgResponse struct {
	Token   string `json:"token"`
	OrgName string `json:"org_name"`
	OrgID   string `json:"org_id"`
}

type Token

type Token struct {
	ExpiresAt int64  `json:"expires_at,omitempty"`
	Name      string `json:"name,omitempty"`
	Role      string `json:"role,omitempty"`
	Token     string `json:"token,omitempty"`
}

type TokenForm

type TokenForm struct {
	Token string `json:"token"`
	MFA   bool   `json:"require_mfa"`
}

type Tunnel

type Tunnel struct {
	TunnelID     string `json:"tunnel_id,omitempty"`
	LocalPort    int    `json:"local_port,omitempty"`
	TunnelServer string `json:"tunnel_server,omitempty"`
}

type UpdatePolicyRequest

type UpdatePolicyRequest struct {
	Name        *string     `json:"name"`
	Description *string     `json:"description"`
	PolicyData  *PolicyData `json:"policy_data" binding:"required"`
}

type UpdateSessionRequest

type UpdateSessionRequest struct {
	UserData   string `json:"user_data"`
	SessionKey string `json:"session_key"`
}

Jump to

Keyboard shortcuts

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