Documentation ¶
Index ¶
- Constants
- Variables
- func AuthorizeConnection(ctx context.Context, sessionRepoFn *Repository, ...) (*Connection, []*ConnectionState, *AuthzSummary, error)
- func CloseConnections(ctx context.Context, sessionRepoFn *Repository, ...) ([]closeConnectionResp, error)
- func DeriveED25519Key(ctx context.Context, wrapper wrapping.Wrapper, userId, jobId string) (ed25519.PublicKey, ed25519.PrivateKey, error)
- func TestCert(wrapper wrapping.Wrapper, userId, jobId string) (ed25519.PrivateKey, []byte, error)
- func TestTofu(t testing.TB) []byte
- func TestWorker(t testing.TB, conn *db.DB, wrapper wrapping.Wrapper, opt ...Option) *servers.Server
- type AuthzSummary
- type Cloneable
- type CloseConnectionsForDeadWorkersResult
- type CloseWith
- type ClosedReason
- type ComposedOf
- type ConnectWith
- type Connection
- type ConnectionRepository
- func (r *ConnectionRepository) AuthorizeConnection(ctx context.Context, sessionId, workerId string) (*Connection, []*ConnectionState, error)
- func (r *ConnectionRepository) CloseConnectionsForDeadWorkers(ctx context.Context, gracePeriod time.Duration) ([]CloseConnectionsForDeadWorkersResult, error)
- func (r *ConnectionRepository) ConnectConnection(ctx context.Context, c ConnectWith) (*Connection, []*ConnectionState, error)
- func (r *ConnectionRepository) DeleteConnection(ctx context.Context, publicId string, _ ...Option) (int, error)
- func (r *ConnectionRepository) ListConnectionsBySessionId(ctx context.Context, sessionId string, opt ...Option) ([]*Connection, error)
- func (r *ConnectionRepository) LookupConnection(ctx context.Context, connectionId string, _ ...Option) (*Connection, []*ConnectionState, error)
- type ConnectionState
- type ConnectionStatus
- type Credential
- type DynamicCredential
- type Option
- func WithDbOpts(opts ...db.Option) Option
- func WithDeadWorkerConnCloseMinGrace(d time.Duration) Option
- func WithExpirationTime(exp *timestamp.Timestamp) Option
- func WithLimit(limit int) Option
- func WithOrderByCreateTime(orderBy db.OrderBy) Option
- func WithScopeIds(scopeIds []string) Option
- func WithServerId(id string) Option
- func WithSessionIds(ids ...string) Option
- func WithTestTofu(tofu []byte) Option
- func WithUserId(userId string) Option
- func WithWorkerStateDelay(d time.Duration) Option
- type Repository
- func (r *Repository) ActivateSession(ctx context.Context, sessionId string, sessionVersion uint32, ...) (*Session, []*State, error)
- func (r *Repository) AddSessionCredentials(ctx context.Context, sessScopeId, sessionId string, credData []Credential, ...) error
- func (r *Repository) CancelSession(ctx context.Context, sessionId string, sessionVersion uint32) (*Session, error)
- func (r *Repository) CreateSession(ctx context.Context, sessionWrapper wrapping.Wrapper, newSession *Session, ...) (*Session, ed25519.PrivateKey, error)
- func (r *Repository) DeleteSession(ctx context.Context, publicId string, _ ...Option) (int, error)
- func (r *Repository) FetchAuthzProtectedEntitiesByScope(ctx context.Context, scopeIds []string) (map[string][]boundary.AuthzProtectedEntity, error)
- func (r *Repository) ListSessionCredentials(ctx context.Context, sessScopeId, sessionId string, _ ...Option) ([]Credential, error)
- func (r *Repository) ListSessions(ctx context.Context, opt ...Option) ([]*Session, error)
- func (r *Repository) LookupSession(ctx context.Context, sessionId string, _ ...Option) (*Session, *AuthzSummary, error)
- func (r *Repository) TerminateCompletedSessions(ctx context.Context) (int, error)
- type Session
- func (s *Session) Clone() interface{}
- func (s Session) GetPublicId() string
- func (s Session) GetScopeId() string
- func (s Session) GetUserId() string
- func (s *Session) SetTableName(n string)
- func (s *Session) TableName() string
- func (s *Session) VetForWrite(ctx context.Context, _ db.Reader, opType db.OpType, opt ...db.Option) error
- type State
- type StateReport
- type Status
- type TerminationReason
Constants ¶
const ( // SessionPrefix for session PK ids SessionPrefix = "s" // StatePrefix for state PK ids StatePrefix = "ss" // ConnectionPrefix for connection PK ids ConnectionPrefix = "sc" // ConnectionStatePrefix for connection state PK ids ConnectionStatePrefix = "scs" )
Variables ¶
var DeadWorkerConnCloseMinGrace = servers.DefaultLiveness
DeadWorkerConnCloseMinGrace is the minimum allowable setting for the CloseConnectionsForDeadWorkers method. This is synced with the default server liveness setting.
Functions ¶
func AuthorizeConnection ¶ added in v0.7.6
func AuthorizeConnection(ctx context.Context, sessionRepoFn *Repository, connectionRepoFn *ConnectionRepository, sessionId, workerId string, opt ...Option, ) (*Connection, []*ConnectionState, *AuthzSummary, error)
AuthorizeConnection is a domain service function that will create a Connection for a session if the following criteria are met: * The session is active. * The session is not expired. * The session has not reached its connection limit or has a connection limit of -1. If any of these criteria is not met, it returns an error with Code InvalidSessionState.
func CloseConnections ¶ added in v0.7.6
func CloseConnections(ctx context.Context, sessionRepoFn *Repository, connectionRepoFn *ConnectionRepository, closeWiths []CloseWith, ) ([]closeConnectionResp, error)
CloseConnections is a domain service function that: * closes requested connections * uses the sessionId of the connection to see if the session meets conditions for termination
func DeriveED25519Key ¶
func DeriveED25519Key(ctx context.Context, wrapper wrapping.Wrapper, userId, jobId string) (ed25519.PublicKey, ed25519.PrivateKey, error)
DeriveED25519Key generates a key based on the scope's session DEK, the requesting user, and the generated job ID.
func TestCert ¶
TestCert is a temporary test func that intentionally doesn't take testing.T as a parameter. It's currently used in controller.jobTestingHandler() and should be deprecated once that function is refactored to use sessions properly.
Types ¶
type AuthzSummary ¶ added in v0.7.6
type Cloneable ¶
type Cloneable interface {
Clone() interface{}
}
Clonable provides a cloning interface
type CloseConnectionsForDeadWorkersResult ¶ added in v0.5.0
type CloseWith ¶
type CloseWith struct { ConnectionId string BytesUp uint64 BytesDown uint64 ClosedReason ClosedReason }
CloseWith defines the boundary data that is saved in the repo when the worker closes a connection between the client and the endpoint.
type ClosedReason ¶
type ClosedReason string
ClosedReason of the connection
const ( UnknownReason ClosedReason = "unknown" ConnectionTimedOut ClosedReason = "timed out" ConnectionClosedByUser ClosedReason = "closed by end-user" ConnectionCanceled ClosedReason = "canceled" ConnectionNetworkError ClosedReason = "network error" ConnectionSystemError ClosedReason = "system error" )
func (ClosedReason) String ¶
func (r ClosedReason) String() string
String representation of the termination reason
type ComposedOf ¶
type ComposedOf struct { // UserId of the session UserId string // HostId of the session HostId string // TargetId of the session TargetId string // HostSetId of the session HostSetId string // AuthTokenId of the session AuthTokenId string // ScopeId of the session ScopeId string // Endpoint. This is generated by the target, but is not stored in the // warehouse as the worker may need to e.g. resolve DNS. This is to round // trip the information to the worker when it validates a session. Endpoint string // Expiration time for the session ExpirationTime *timestamp.Timestamp // Max connections for the session ConnectionLimit int32 // Worker filter. Active filter when the session was created, used to // validate the session via the same set of rules at consumption time as // existed at creation time. Round tripping it through here saves a lookup // in the DB. It is not stored in the warehouse. WorkerFilter string // DynamicCredentials are dynamic credentials that will be retrieved // for the session. DynamicCredentials optional. DynamicCredentials []*DynamicCredential }
ComposedOf defines the boundary data that is referenced to compose a session.
func TestSessionParams ¶
func TestSessionParams(t testing.TB, conn *db.DB, wrapper wrapping.Wrapper, iamRepo *iam.Repository) ComposedOf
TestSessionParams returns an initialized ComposedOf which can be used to create a session in the repository.
type ConnectWith ¶
type ConnectWith struct { ConnectionId string ClientTcpAddress string ClientTcpPort uint32 EndpointTcpAddress string EndpointTcpPort uint32 UserClientIp string }
ConnectWith defines the boundary data that is saved in the repo when the worker has established a connection between the client and the endpoint.
type Connection ¶
type Connection struct { // PublicId is used to access the connection via an API PublicId string `json:"public_id,omitempty" gorm:"primary_key"` // SessionId of the connection SessionId string `json:"session_id,omitempty" gorm:"default:null"` // ClientTcpAddress of the connection ClientTcpAddress string `json:"client_tcp_address,omitempty" gorm:"default:null"` // ClientTcpPort of the connection ClientTcpPort uint32 `json:"client_tcp_port,omitempty" gorm:"default:null"` // UserClientIp is the user's client IP UserClientIp string `json:"user_client_ip,omitempty" gorm:"default:null"` // EndpointTcpAddress of the connection EndpointTcpAddress string `json:"endpoint_tcp_address,omitempty" gorm:"default:null"` // EndpointTcpPort of the connection EndpointTcpPort uint32 `json:"endpoint_tcp_port,omitempty" gorm:"default:null"` // BytesUp of the connection BytesUp uint64 `json:"bytes_up,omitempty" gorm:"default:null"` // BytesDown of the connection BytesDown uint64 `json:"bytes_down,omitempty" gorm:"default:null"` // ClosedReason of the conneciont ClosedReason string `json:"closed_reason,omitempty" gorm:"default:null"` // CreateTime from the RDBMS CreateTime *timestamp.Timestamp `json:"create_time,omitempty" gorm:"default:current_timestamp"` // UpdateTime from the RDBMS UpdateTime *timestamp.Timestamp `json:"update_time,omitempty" gorm:"default:current_timestamp"` // Version of the connection Version uint32 `json:"version,omitempty" gorm:"default:null"` // contains filtered or unexported fields }
Connection contains information about session's connection to a target
func AllocConnection ¶
func AllocConnection() Connection
AllocConnection will allocate a Connection.
func NewConnection ¶
func NewConnection(sessionID, clientTcpAddress string, clientTcpPort uint32, endpointTcpAddr string, endpointTcpPort uint32, userClientIp string, _ ...Option) (*Connection, error)
NewConnection creates a new in memory connection. No options are currently supported.
func TestConnection ¶
func TestConnection(t testing.TB, conn *db.DB, sessionId, clientTcpAddr string, clientTcpPort uint32, endpointTcpAddr string, endpointTcpPort uint32, userClientIp string) *Connection
TestConnection creates a test connection for the sessionId in the repository.
func (*Connection) Clone ¶
func (c *Connection) Clone() interface{}
Clone creates a clone of the Connection.
func (*Connection) GetPublicId ¶
func (c *Connection) GetPublicId() string
func (*Connection) SetTableName ¶
func (c *Connection) SetTableName(n string)
SetTableName sets the tablename and satisfies the ReplayableMessage interface. If the caller attempts to set the name to "" the name will be reset to the default name.
func (*Connection) TableName ¶
func (c *Connection) TableName() string
TableName returns the tablename to override the default gorm table name
type ConnectionRepository ¶ added in v0.7.6
type ConnectionRepository struct {
// contains filtered or unexported fields
}
ConnectionRepository is the session connection database repository.
func NewConnectionRepository ¶ added in v0.7.6
func NewConnectionRepository(ctx context.Context, r db.Reader, w db.Writer, kms *kms.Kms, opt ...Option) (*ConnectionRepository, error)
NewConnectionRepository creates a new session Connection Repository. Supports the options: WithLimit which sets a default limit on results returned by repo operations.
func (*ConnectionRepository) AuthorizeConnection ¶ added in v0.7.6
func (r *ConnectionRepository) AuthorizeConnection(ctx context.Context, sessionId, workerId string) (*Connection, []*ConnectionState, error)
AuthorizeConnection will check to see if a connection is allowed. Currently, that authorization checks: * the hasn't expired based on the session.Expiration * number of connections already created is less than session.ConnectionLimit If authorization is success, it creates/stores a new connection in the repo and returns it, along with its states. If the authorization fails, it an error with Code InvalidSessionState.
func (*ConnectionRepository) CloseConnectionsForDeadWorkers ¶ added in v0.7.6
func (r *ConnectionRepository) CloseConnectionsForDeadWorkers(ctx context.Context, gracePeriod time.Duration) ([]CloseConnectionsForDeadWorkersResult, error)
CloseConnectionsForDeadWorkers will run closeConnectionsForDeadServersCte to look for connections that should be marked because they are on a server that is no longer sending status updates to the controller(s).
The only input to the method is the grace period, in seconds.
func (*ConnectionRepository) ConnectConnection ¶ added in v0.7.6
func (r *ConnectionRepository) ConnectConnection(ctx context.Context, c ConnectWith) (*Connection, []*ConnectionState, error)
ConnectConnection updates a connection in the repo with a state of "connected".
func (*ConnectionRepository) DeleteConnection ¶ added in v0.7.6
func (r *ConnectionRepository) DeleteConnection(ctx context.Context, publicId string, _ ...Option) (int, error)
DeleteConnection will delete a connection from the repository.
func (*ConnectionRepository) ListConnectionsBySessionId ¶ added in v0.7.6
func (r *ConnectionRepository) ListConnectionsBySessionId(ctx context.Context, sessionId string, opt ...Option) ([]*Connection, error)
ListConnectionsBySessionId will list connections by session ID. Supports the WithLimit and WithOrder options.
func (*ConnectionRepository) LookupConnection ¶ added in v0.7.6
func (r *ConnectionRepository) LookupConnection(ctx context.Context, connectionId string, _ ...Option) (*Connection, []*ConnectionState, error)
LookupConnection will look up a connection in the repository and return the connection with its states. If the connection is not found, it will return nil, nil, nil. No options are currently supported.
type ConnectionState ¶
type ConnectionState struct { // ConnectionId is used to access the state via an API ConnectionId string `json:"public_id,omitempty" gorm:"primary_key"` // status of the connection Status ConnectionStatus `protobuf:"bytes,20,opt,name=status,proto3" json:"status,omitempty" gorm:"column:state"` // PreviousEndTime from the RDBMS PreviousEndTime *timestamp.Timestamp `json:"previous_end_time,omitempty" gorm:"default:current_timestamp"` // StartTime from the RDBMS StartTime *timestamp.Timestamp `json:"start_time,omitempty" gorm:"default:current_timestamp;primary_key"` // EndTime from the RDBMS EndTime *timestamp.Timestamp `json:"end_time,omitempty" gorm:"default:current_timestamp"` // contains filtered or unexported fields }
ConnectionState of the state of the connection
func NewConnectionState ¶
func NewConnectionState(connectionId string, state ConnectionStatus, _ ...Option) (*ConnectionState, error)
NewConnectionState creates a new in memory connection state. No options are currently supported.
func TestConnectionState ¶
func TestConnectionState(t testing.TB, conn *db.DB, connectionId string, state ConnectionStatus) *ConnectionState
TestConnectionState creates a test connection state for the connectionId in the repository.
func (*ConnectionState) Clone ¶
func (s *ConnectionState) Clone() interface{}
Clone creates a clone of the State
func (*ConnectionState) SetTableName ¶
func (s *ConnectionState) SetTableName(n string)
SetTableName sets the tablename and satisfies the ReplayableMessage interface. If the caller attempts to set the name to "" the name will be reset to the default name.
func (*ConnectionState) TableName ¶
func (s *ConnectionState) TableName() string
TableName returns the tablename to override the default gorm table name
type ConnectionStatus ¶
type ConnectionStatus string
ConnectionStatus of the connection's state
const ( StatusAuthorized ConnectionStatus = "authorized" StatusConnected ConnectionStatus = "connected" StatusClosed ConnectionStatus = "closed" StatusUnspecified ConnectionStatus = "unspecified" // Utility state not valid in the DB )
func ConnectionStatusFromProtoVal ¶ added in v0.4.0
func ConnectionStatusFromProtoVal(s workerpbs.CONNECTIONSTATUS) ConnectionStatus
ConnectionStatusFromProtoVal is the reverse of ConnectionStatus.ProtoVal.
func (ConnectionStatus) ProtoVal ¶
func (s ConnectionStatus) ProtoVal() workerpbs.CONNECTIONSTATUS
ProtoVal returns the enum value corresponding to the state
func (ConnectionStatus) String ¶
func (s ConnectionStatus) String() string
String representation of the state's status
type Credential ¶ added in v0.7.4
type Credential []byte
Credential represents the credential data which is sent to the worker.
type DynamicCredential ¶ added in v0.4.0
type DynamicCredential struct { SessionId string `json:"session_id,omitempty" gorm:"primary_key"` LibraryId string `json:"library_id,omitempty" gorm:"primary_key"` CredentialPurpose string `json:"credential_purpose,omitempty" gorm:"primary_key"` CredentialId string `json:"credential_id,omitempty" gorm:"default:null"` // contains filtered or unexported fields }
A DynamicCredential represents the relationship between a session, a credential, and the credential library where the credential was retrieved plus the purpose of the credential.
func NewDynamicCredential ¶ added in v0.4.0
func NewDynamicCredential(libraryId string, purpose cred.Purpose) *DynamicCredential
NewDynamicCredential creates a new in memory Credential representing the relationship between session and a credential library.
func (*DynamicCredential) SetTableName ¶ added in v0.4.0
func (c *DynamicCredential) SetTableName(n string)
SetTableName sets the table name.
func (*DynamicCredential) TableName ¶ added in v0.4.0
func (c *DynamicCredential) TableName() string
TableName returns the table name.
type Option ¶
type Option func(*options)
Option - how Options are passed as arguments
func WithDbOpts ¶ added in v0.2.2
WithDbOpts passes through given DB options to the DB layer
func WithDeadWorkerConnCloseMinGrace ¶ added in v0.7.6
WithDeadWorkerConnCloseMinGrace is used to set the minimum allowable setting for the CloseConnectionsForDeadWorkers method. This defaults to the default server liveness setting.
func WithExpirationTime ¶
WithExpirationTime allows specifying an expiration time for the session
func WithLimit ¶
WithLimit provides an option to provide a limit. Intentionally allowing negative integers. If WithLimit < 0, then unlimited results are returned. If WithLimit == 0, then default limits are used for results.
func WithOrderByCreateTime ¶ added in v0.2.0
WithOrderByCreateTime provides an option to specify ordering by the CreateTime field.
func WithScopeIds ¶ added in v0.1.5
WithScopeIds allows specifying a scope ID criteria for the function.
func WithServerId ¶ added in v0.2.2
WithServerId allows the specification of the server id to use for the operation.
func WithSessionIds ¶
WithSessionIds allows the specification of the session ids to use for the operation.
func WithTestTofu ¶
WithTestTofu allows specifying a test tofu for a test session
func WithUserId ¶
WithUserId allows specifying a user ID criteria for the function.
func WithWorkerStateDelay ¶ added in v0.7.6
WithWorkerStateDelay is used by queries to account for a delay in state propagation between worker and controller.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository is the session database repository
func NewRepository ¶
NewRepository creates a new session Repository. Supports the options: WithLimit which sets a default limit on results returned by repo operations.
func (*Repository) ActivateSession ¶
func (r *Repository) ActivateSession(ctx context.Context, sessionId string, sessionVersion uint32, serverId, serverType string, tofuToken []byte) (*Session, []*State, error)
ActivateSession will activate the session and is called by a worker after authenticating the session. The session must be in a "pending" state to be activated. States are ordered by start time descending. Returns an InvalidSessionState error code if a connection cannot be made because the session was canceled or terminated.
func (*Repository) AddSessionCredentials ¶ added in v0.7.4
func (r *Repository) AddSessionCredentials(ctx context.Context, sessScopeId, sessionId string, credData []Credential, _ ...Option) error
AddSessionCredentials encrypts the credData and adds the credentials to the repository. The credentials are linked to the sessionID provided, and encrypted using the sessScopeId. Session credentials are only valid for pending and active sessions, once a session ends, all session credentials are deleted. All options are ignored.
func (*Repository) CancelSession ¶
func (r *Repository) CancelSession(ctx context.Context, sessionId string, sessionVersion uint32) (*Session, error)
CancelSession sets a session's state to "canceling" in the repo. It's called when the user cancels a session and the controller wants to update the session state to "canceling" for the given reason, so the workers can get the "canceling signal" during their next status heartbeat. CancelSession is idempotent.
func (*Repository) CreateSession ¶
func (r *Repository) CreateSession(ctx context.Context, sessionWrapper wrapping.Wrapper, newSession *Session, workerAddresses []string, _ ...Option) (*Session, ed25519.PrivateKey, error)
CreateSession inserts into the repository and returns the new Session with its State of "Pending". The following fields must be empty when creating a session: ServerId, ServerType, and PublicId. No options are currently supported.
func (*Repository) DeleteSession ¶
DeleteSession will delete a session from the repository.
func (*Repository) FetchAuthzProtectedEntitiesByScope ¶ added in v0.8.0
func (r *Repository) FetchAuthzProtectedEntitiesByScope(ctx context.Context, scopeIds []string) (map[string][]boundary.AuthzProtectedEntity, error)
FetchAuthzProtectedEntitiesByScope implements boundary.AuthzProtectedEntityProvider
func (*Repository) ListSessionCredentials ¶ added in v0.7.4
func (r *Repository) ListSessionCredentials(ctx context.Context, sessScopeId, sessionId string, _ ...Option) ([]Credential, error)
ListSessionCredentials returns all Credential attached to the sessionId. All options are ignored.
func (*Repository) ListSessions ¶
ListSessions will sessions. Supports the WithLimit, WithScopeId, WithSessionIds, and WithServerId options.
func (*Repository) LookupSession ¶
func (r *Repository) LookupSession(ctx context.Context, sessionId string, _ ...Option) (*Session, *AuthzSummary, error)
LookupSession will look up a session in the repository and return the session with its states. Returned States are ordered by start time descending. If the session is not found, it will return nil, nil, nil. No options are currently supported.
func (*Repository) TerminateCompletedSessions ¶
func (r *Repository) TerminateCompletedSessions(ctx context.Context) (int, error)
TerminateCompletedSessions will terminate sessions in the repo based on:
- sessions that have exhausted their connection limit and all their connections are closed.
- sessions that are expired and all their connections are closed.
- sessions that are canceling and all their connections are closed
This function should called on a periodic basis a Controllers via it's "ticker" pattern.
type Session ¶
type Session struct { // PublicId is used to access the session via an API PublicId string `json:"public_id,omitempty" gorm:"primary_key"` // UserId for the session UserId string `json:"user_id,omitempty" gorm:"default:null"` // HostId of the session HostId string `json:"host_id,omitempty" gorm:"default:null"` // ServerId that proxied the session ServerId string `json:"server_id,omitempty" gorm:"default:null"` // ServerType that proxied the session ServerType string `json:"server_type,omitempty" gorm:"default:null"` // TargetId for the session TargetId string `json:"target_id,omitempty" gorm:"default:null"` // HostSetId for the session HostSetId string `json:"host_set_id,omitempty" gorm:"default:null"` // AuthTokenId for the session AuthTokenId string `json:"auth_token_id,omitempty" gorm:"default:null"` // ScopeId for the session ScopeId string `json:"scope_id,omitempty" gorm:"default:null"` // Certificate to use when connecting (or if using custom certs, to // serve as the "login"). Raw DER bytes. Private key is not, and should not be // stored in the database. Certificate []byte `json:"certificate,omitempty" gorm:"default:null"` // ExpirationTime - after this time the connection will be expired, e.g. forcefully terminated ExpirationTime *timestamp.Timestamp `json:"expiration_time,omitempty" gorm:"default:null"` // CtTofuToken is the ciphertext Tofutoken value stored in the database CtTofuToken []byte `json:"ct_tofu_token,omitempty" gorm:"column:tofu_token;default:null" wrapping:"ct,tofu_token"` // TofuToken - plain text of the "trust on first use" token for session TofuToken []byte `json:"tofu_token,omitempty" gorm:"-" wrapping:"pt,tofu_token"` // termination_reason for the session TerminationReason string `json:"termination_reason,omitempty" gorm:"default:null"` // CreateTime from the RDBMS CreateTime *timestamp.Timestamp `json:"create_time,omitempty" gorm:"default:current_timestamp"` // UpdateTime from the RDBMS UpdateTime *timestamp.Timestamp `json:"update_time,omitempty" gorm:"default:current_timestamp"` // Version for the session Version uint32 `json:"version,omitempty" gorm:"default:null"` // Endpoint Endpoint string `json:"-" gorm:"default:null"` // Maximum number of connections in a session ConnectionLimit int32 `json:"connection_limit,omitempty" gorm:"default:null"` // Worker filter WorkerFilter string `json:"-" gorm:"default:null"` // key_id is the key ID that was used for the encryption operation. It can be // used to identify a specific version of the key needed to decrypt the value, // which is useful for caching purposes. // @inject_tag: `gorm:"not_null"` KeyId string `json:"key_id,omitempty" gorm:"not_null"` // States for the session which are for read only and are ignored during // write operations States []*State `gorm:"-"` // DynamicCredentials for the session. DynamicCredentials []*DynamicCredential `gorm:"-"` // Connections for the session are for read only and are ignored during write operations Connections []*Connection `gorm:"-"` // contains filtered or unexported fields }
Session contains information about a user's session with a target
func New ¶
func New(c ComposedOf, _ ...Option) (*Session, error)
New creates a new in memory session.
func TestDefaultSession ¶
func TestDefaultSession(t testing.TB, conn *db.DB, wrapper wrapping.Wrapper, iamRepo *iam.Repository, opt ...Option) *Session
TestDefaultSession creates a test session in the repository using defaults.
func TestSession ¶
func TestSession(t testing.TB, conn *db.DB, wrapper wrapping.Wrapper, c ComposedOf, opt ...Option) *Session
TestSession creates a test session composed of c in the repository. Options are passed into New, and withServerId is handled locally.
func (Session) GetPublicId ¶
func (Session) GetScopeId ¶ added in v0.8.0
func (*Session) SetTableName ¶
SetTableName sets the tablename and satisfies the ReplayableMessage interface. If the caller attempts to set the name to "" the name will be reset to the default name.
type State ¶
type State struct { // SessionId references the session public id SessionId string `json:"session_id,omitempty" gorm:"primary_key"` // status of the session Status Status `json:"status,omitempty" gorm:"column:state"` // PreviousEndTime from the RDBMS PreviousEndTime *timestamp.Timestamp `json:"previous_end_time,omitempty" gorm:"default:current_timestamp"` // StartTime from the RDBMS StartTime *timestamp.Timestamp `json:"start_time,omitempty" gorm:"default:current_timestamp;primary_key"` // EndTime from the RDBMS EndTime *timestamp.Timestamp `json:"end_time,omitempty" gorm:"default:current_timestamp"` // contains filtered or unexported fields }
State of the session
func (*State) SetTableName ¶
SetTableName sets the tablename and satisfies the ReplayableMessage interface. If the caller attempts to set the name to "" the name will be reset to the default name.
type StateReport ¶ added in v0.7.6
StateReport is used to report on the state of a Session.
func WorkerStatusReport ¶ added in v0.7.6
func WorkerStatusReport(ctx context.Context, repo *Repository, connRepo *ConnectionRepository, workerId string, report []StateReport) ([]StateReport, error)
WorkerStatusReport is a domain service function that compares the state of sessions and connections as reported by a Worker, to the known state in the repositories. It returns a []StateReport for each session that is in the canceling or terminated state. It also will check for any orphaned connections, which is defined as a connection that is in an active state, but was not reported by worker. Any orphaned connections will be marked as closed.
type Status ¶
type Status string
Status of the session's state
func (Status) ProtoVal ¶
func (s Status) ProtoVal() workerpbs.SESSIONSTATUS
ProtoVal returns the enum value corresponding to the state
type TerminationReason ¶
type TerminationReason string
TerminationReason of the session
const ( UnknownTermination TerminationReason = "unknown" TimedOut TerminationReason = "timed out" ClosedByUser TerminationReason = "closed by end-user" Terminated TerminationReason = "terminated" NetworkError TerminationReason = "network error" SystemError TerminationReason = "system error" ConnectionLimit TerminationReason = "connection limit" SessionCanceled TerminationReason = "canceled" )
func (TerminationReason) String ¶
func (r TerminationReason) String() string
String representation of the termination reason
Source Files ¶
- connection.go
- connection_closed_reason.go
- connection_closed_with.go
- connection_state.go
- credential.go
- dynamic_credential.go
- ids.go
- options.go
- query.go
- repository.go
- repository_connection.go
- repository_credential.go
- repository_session.go
- service_authorize_connection.go
- service_close_connections.go
- service_worker_status_report.go
- session.go
- session_connect_with.go
- state.go
- term_reason.go
- testing.go
- util.go