border0_api

package
v0.0.0-14789vxlan Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENV_NAME_BORDER0_ADMIN_TOKEN = "BORDER0_ADMIN_TOKEN"
	ENV_NAME_BORDER0_API         = "BORDER0_API"
)

Variables

This section is empty.

Functions

func CreateBorder0Config

func CreateBorder0Config(ctx context.Context, nodesMap map[string]nodes.Node, labname string) (string, error)

CreateBorder0Config inspects the `publish` section of the nodes configuration and builds a configuration for the border0.com cli clients "Static Sockets plugin" [https://docs.border0.com/docs/static-sockets-plugin]

func Login

func Login(ctx context.Context, email, password string) error

Login performs a login to border0.com and stores the retrieved the access-token in the cwd.

func ParseSocketCfg

func ParseSocketCfg(s, host string) (*configSocket, error)

ParseSocketCfg parses the nodes publish configuration string and returns resulting *configSocket.

func RefreshLogin

func RefreshLogin(ctx context.Context) error

RefreshLogin checking the validity of the login token as well as it.

func Request

func Request(ctx context.Context, method string, url string, targetStruct interface{}, data interface{}, requireAccessToken bool) error

Request is the helper function that handels the http requests, as well as the marshalling of request structs and unmarshalling of responses.

Types

type AddSocketToPolicyRequest

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

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"`
}

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 ErrorMessage

type ErrorMessage struct {
	ErrorMessage string `json:"error_message,omitempty"`
}

type LoginRefreshResponse

type LoginRefreshResponse struct {
	Token string `json:"token"`
}

type LoginRequest

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

type LoginResponse

type LoginResponse struct {
	LoginRefreshResponse
	MFA bool `json:"require_mfa"`
}

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"`
}

func GetExistingPolicies

func GetExistingPolicies(ctx context.Context) ([]Policy, error)

GetExistingPolicies retrieved the existing policies from border0.com.

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    []string  `json:"action" mapstructure:"action"`
	Condition Condition `json:"condition" mapstructure:"condition"`
}

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"`
	ProtectedSocket                bool              `json:"protected_socket"`
	ProtectedUsername              string            `json:"protected_username"`
	ProtectedPassword              string            `json:"protected_password"`
	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"`
	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"`
	Tags                           map[string]string `json:"tags,omitempty"`
	CustomDomains                  []string          `json:"custom_domains,omitempty"`
	PrivateSocket                  bool              `json:"private_socket"`
	PolicyNames                    []string          `json:"policy_names,omitempty"`
}

func (*Socket) SanitizeName

func (s *Socket) SanitizeName()

type StaticSocketsConfig

type StaticSocketsConfig struct {
	Connector   *configConnector           `yaml:"connector"`
	Credentials *configCredentials         `yaml:"credentials"`
	Sockets     []map[string]*configSocket `yaml:"sockets"`
}

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"`
}

Jump to

Keyboard shortcuts

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