client

package
v0.0.0-...-9758eb9 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProxyHandshakeFailed     = errors.New("failed to authenticate against Border0 proxy")
	ErrConnectorHandshakeFailed = errors.New("failed to authenticate against connector")
)
View Source
var (
	// ErrResourceNotFound is returned when a fetched resource is not found
	ErrResourceNotFound = errors.New("resource not found")
)

Functions

func AutocompleteHost

func AutocompleteHost(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

func CertToKeyStore

func CertToKeyStore(cert *x509.Certificate, key *rsa.PrivateKey) (ks keystore.KeyStore, pass []byte, err error)

func CheckIfTokenIsExpired

func CheckIfTokenIsExpired(rawToken string) bool

func ClientTokenFile

func ClientTokenFile(homedir string) string

func Connect

func Connect(addr string, tlsNeeded bool, tlsConfig *tls.Config, certificate tls.Certificate, caCert *x509.Certificate, connectorAuthenticationEnabled bool, endToEndEncryptionEnabled bool, useWsProxy bool) (net.Conn, error)

func ConnectWSProxy

func ConnectWSProxy(proxyUrl string, addr string) (net.Conn, error)

func DownloadCertificateChain

func DownloadCertificateChain(hostname string) (certChainPath string, err error)

func EnterDBName

func EnterDBName(inputDBName, suggestedDBname string) (enteredDBName string, err error)

func ExecCommand

func ExecCommand(name string, arg ...string) error

func FetchCertAndReturnPaths

func FetchCertAndReturnPaths(logger *zap.Logger, hostname string) (crtPath, keyPath, caPath string, err error)

func FetchResource

func FetchResource(token string, name string) (resource models.ClientResource, err error)

func FetchResources

func FetchResources(token string, filteredTypes ...string) (resources models.ClientResources, err error)

func FindWindowsExecutable

func FindWindowsExecutable(parentDir, contains, suffix string) string

func GetClientToken

func GetClientToken(homeDir string) (string, error)

func GetSocketPort

func GetSocketPort(name string, token string) (socketPort int, err error)

func IsClientCertValid

func IsClientCertValid() (crtPath, keyPath string, valid bool)

func IsExistingClientTokenValid

func IsExistingClientTokenValid(homeDir string) (valid bool, token, identity string, err error)

func Launch

func Launch(logger *zap.Logger, url string, listener net.Listener) string

func Login

func Login(org string) (token string, claims jwt.MapClaims, err error)

Login performs an OAuth2.0 client device authorization flow against the API

func MTLSLogin

func MTLSLogin(logger *zap.Logger, hostname string) (string, jwt.MapClaims, error)

func MTLSTokenFile

func MTLSTokenFile() string

func MonWinCh

func MonWinCh(session *ssh.Session, fd uintptr)

MonWinCh watches for the system to signal a window resize and requests a window-change from the server.

func OnInterruptDo

func OnInterruptDo(action func())

func OrgIDFromToken

func OrgIDFromToken() (orgID string)

func PickHost

func PickHost(inputHost string, socketTypes ...string) (models.ClientResource, error)

func PickResourceTypes

func PickResourceTypes(inputFilter string) (pickedTypes []string, err error)

func ReadOrgCert

func ReadOrgCert(orgID string) (cert *x509.Certificate, key *rsa.PrivateKey, caCert *x509.Certificate, crtPath string, keyPath, caPath string, err error)

func ReadTokenOrAskToLogIn

func ReadTokenOrAskToLogIn() (token string, err error)

func StartConnectorAuthListener

func StartConnectorAuthListener(hostname string, port int, certificate tls.Certificate, caCertificate *x509.Certificate, localPort int, connectorAuthenticationEnabled bool, endToEndEncryptionEnabled bool, useWsProxy bool) (int, error)

func TermSize

func TermSize(fd uintptr) []byte

TermSize gets the current window size and returns it in a window-change friendly format.

func ValidateClientToken

func ValidateClientToken(token string) (identity string, claims jwt.MapClaims, err error)

func WriteCertToFile

func WriteCertToFile(cert *CertificateResponse, socketDNS string) (crtPath, keyPath, caPath string, err error)

func WriteKeyStore

func WriteKeyStore(ks keystore.KeyStore, filename string, password []byte)

func Zeroing

func Zeroing(buf []byte)

Types

type CertificateResponse

type CertificateResponse struct {
	PrivateKey    string `json:"client_private_key,omitempty"`
	Certificate   string `json:"client_certificate,omitempty"`
	CaCertificate string `json:"ca_certificate,omitempty"`
}

func GetCert

func GetCert(token string, email string) *CertificateResponse

type CertificateSigningRequest

type CertificateSigningRequest struct {
	Csr string `json:"csr"`
}

type ResourceInfo

type ResourceInfo struct {
	Certficate                     *x509.Certificate
	PrivateKey                     *rsa.PrivateKey
	CaCertificate                  *x509.Certificate
	CertificatePath                string
	PrivateKeyPath                 string
	CaCertificatePath              string
	Port                           int
	ConnectorAuthenticationEnabled bool
	EndToEndEncryptionEnabled      bool
}

func GetResourceInfo

func GetResourceInfo(logger *zap.Logger, hostname string) (info ResourceInfo, err error)

func (*ResourceInfo) SetupTLSCertificate

func (info *ResourceInfo) SetupTLSCertificate() tls.Certificate

type SSHSignRequest

type SSHSignRequest struct {
	SSHPublicKey string `json:"ssh_public_key"`
}

type SSHSignResponse

type SSHSignResponse struct {
	SSHCertSigned string `json:"signed_ssh_cert"`
}

func GenSSHKey

func GenSSHKey(token, orgID, hostname string) (*SSHSignResponse, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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