session

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package session is used for bookkeeping of SSH interactive sessions that happen in realtime across the teleport cluster

Index

Constants

View Source
const MaxSessionSliceLength = 1000

MaxSessionSliceLength is the maximum number of sessions per time window that the backend will return.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileTransferDecisionParams

type FileTransferDecisionParams struct {
	// RequestID is the ID of the request being responded to
	RequestID string `json:"requestId"`
	// Approved is true if the response approves a file transfer request
	Approved bool `json:"approved"`
}

FileTransferDecisionParams contains parameters for approving or denying a file transfer request

type FileTransferRequestParams

type FileTransferRequestParams struct {
	// Download is true if the request is a download, false if it is an upload
	Download bool `json:"direction"`
	// Location is location of file to download, or where to put an upload
	Location string `json:"location"`
	// Filename is the name of the file to be uploaded
	Filename string `json:"filename"`
	// Requester is the authenticated Teleport user who requested the file transfer
	Requester string `json:"requester"`
	// Approvers is a list of teleport users who have approved the file transfer request
	Approvers []Party `json:"approvers"`
}

FileTransferRequestParams contain parameters for requesting a file transfer

type ID

type ID string

ID is a unique session ID.

func NewID

func NewID() ID

NewID returns new session ID. The session ID is based on UUIDv4.

func ParseID

func ParseID(id string) (*ID, error)

ParseID parses ID and checks if it's correct.

func (*ID) Check

func (s *ID) Check() error

Check will check that the underlying UUID is valid.

func (*ID) IsZero

func (s *ID) IsZero() bool

IsZero returns true if this ID is empty.

func (*ID) String

func (s *ID) String() string

String returns string representation of this ID.

type Party

type Party struct {
	// ID is a unique party id
	ID ID `json:"id"`
	// Site is a remote address?
	RemoteAddr string `json:"remote_addr"`
	// User is a teleport user using this session
	User string `json:"user"`
	// ServerID is an address of the server
	ServerID string `json:"server_id"`
	// LastActive is a last time this party was active
	LastActive time.Time `json:"last_active"`
}

Party is a participant a user or a script executing some action in the context of the session

func (*Party) String

func (p *Party) String() string

String returns debug friendly representation

type Session

type Session struct {
	// Kind describes what kind of session this is e.g. ssh or k8s.
	Kind types.SessionKind `json:"kind"`
	// ID is a unique session identifier
	ID ID `json:"id"`
	// Namespace is a session namespace, separating sessions from each other
	Namespace string `json:"namespace"`
	// Parties is a list of session parties.
	Parties []Party `json:"parties"`
	// TerminalParams sets terminal properties
	TerminalParams TerminalParams `json:"terminal_params"`
	// Login is a login used by all parties joining the session
	Login string `json:"login"`
	// Created records the information about the time when session
	// was created
	Created time.Time `json:"created"`
	// LastActive holds the information about when the session
	// was last active
	LastActive time.Time `json:"last_active"`
	// ServerID of session
	ServerID string `json:"server_id"`
	// ServerHostname of session
	ServerHostname string `json:"server_hostname"`
	// ServerHostPort of session
	ServerHostPort int `json:"server_hostport"`
	// ServerAddr of session
	ServerAddr string `json:"server_addr"`
	// ClusterName is the name of the Teleport cluster that this session belongs to.
	ClusterName string `json:"cluster_name"`
	// KubernetesClusterName is the name of the kube cluster that this session is running in.
	KubernetesClusterName string `json:"kubernetes_cluster_name"`
	// DesktopName is the name of the desktop that this session is running in.
	DesktopName string `json:"desktop_name"`
	// DatabaseName is the name of the database being accessed.
	DatabaseName string `json:"database_name"`
	// AppName is the name of the app being accessed.
	AppName string `json:"app_name"`
	// Owner is the name of the session owner, ie the one who created the session.
	Owner string `json:"owner"`
	// Moderated is true if the session requires moderation (only relevant for Kind = ssh/k8s).
	Moderated bool `json:"moderated"`
	// Command is the command that was executed to start the session.
	Command string `json:"command"`
}

Session is a session of any kind (SSH, Kubernetes, Desktop, etc)

func (*Session) Participants

func (s *Session) Participants() []string

Participants returns the usernames of the current session participants.

func (*Session) RemoveParty

func (s *Session) RemoveParty(pid ID) bool

RemoveParty helper allows to remove a party by it's ID from the session's list. Returns 'false' if pid couldn't be found

type TerminalParams

type TerminalParams struct {
	W int `json:"w"`
	H int `json:"h"`
}

TerminalParams holds the terminal size in a session.

func NewTerminalParamsFromInt

func NewTerminalParamsFromInt(w int, h int) (*TerminalParams, error)

NewTerminalParamsFromInt returns new terminal parameters from int width and height

func NewTerminalParamsFromUint32

func NewTerminalParamsFromUint32(w uint32, h uint32) (*TerminalParams, error)

NewTerminalParamsFromUint32 returns new terminal parameters from uint32 width and height

func UnmarshalTerminalParams

func UnmarshalTerminalParams(s string) (*TerminalParams, error)

UnmarshalTerminalParams takes a serialized string that contains the terminal parameters and returns a *TerminalParams.

func (*TerminalParams) Serialize

func (p *TerminalParams) Serialize() string

Serialize is a more strict version of String(): it returns a string representation of terminal size, this is used in our APIs. Format : "W:H" Example: "80:25"

func (*TerminalParams) String

func (p *TerminalParams) String() string

String returns debug friendly representation of terminal

func (*TerminalParams) Winsize

func (p *TerminalParams) Winsize() *term.Winsize

Winsize returns low-level parameters for changing PTY

Jump to

Keyboard shortcuts

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