Documentation
¶
Index ¶
- Constants
- Variables
- func IsExpired(ctx context.Context, candidate Session) (bool, error)
- func IsNotExpired(ctx context.Context, candidate Session) (bool, error)
- func IsStillValid(ctx context.Context, candidate Session) (bool, error)
- type CloseableRepository
- type ConnectionInterceptor
- type ConnectionInterceptorResult
- type Consumer
- type FindOpts
- type FsRepository
- func (this *FsRepository) Close() error
- func (this *FsRepository) Create(ctx context.Context, flow configuration.FlowName, remote common.Remote, ...) (Session, error)
- func (this *FsRepository) Delete(ctx context.Context, s Session) error
- func (this *FsRepository) DeleteBy(ctx context.Context, flow configuration.FlowName, id uuid.UUID) error
- func (this *FsRepository) FindAll(ctx context.Context, consumer Consumer, opts *FindOpts) error
- func (this *FsRepository) FindBy(ctx context.Context, flow configuration.FlowName, id uuid.UUID, opts *FindOpts) (Session, error)
- func (this *FsRepository) FindByAccessToken(ctx context.Context, t []byte, opts *FindOpts) (Session, error)
- func (this *FsRepository) FindByPublicKey(ctx context.Context, key ssh.PublicKey, opts *FindOpts) (Session, error)
- type Info
- type InfoCreated
- type InfoLastAccessed
- type Predicate
- type Predicates
- type Repository
- type RepositoryFacade
- type Session
- type State
Constants ¶
View Source
const ( FsFileSession = "s" FsFileLastAccessed = "la" FsFileAccessToken = "at" FsFileEnvironmentToken = "et" FsFilePublicKeysPrefix = "pk-" FsFilePublicKeysPrefixLen = len(FsFilePublicKeysPrefix) )
Variables ¶
View Source
var (
ErrMaxConnectionsPerSessionReached = errors.Newf(errors.User, "max connections per session reached")
)
View Source
var (
ErrNoSuchSession = errors.New("no such session")
)
Functions ¶
Types ¶
type CloseableRepository ¶
type CloseableRepository interface {
Repository
io.Closer
}
type ConnectionInterceptor ¶
type ConnectionInterceptorResult ¶
type ConnectionInterceptorResult uint8
const ( ConnectionInterceptorResultNone ConnectionInterceptorResult = iota ConnectionInterceptorResultIdle ConnectionInterceptorResultMax ConnectionInterceptorResultDisposed )
type FindOpts ¶
type FindOpts struct {
// Predicates are used to filter the returned sessions.
Predicates Predicates
// AutoCleanUpAllowed tells the repository to clean up everything
// automatically while executing the search. The requester will never
// see the requested result. This is false by default because it could
// lead to quite performance impacts or other unwanted side effects.
//
// Therefore: Use with caution.
AutoCleanUpAllowed *bool
// Logger will be used (if any log is required) instead of the standard logger.
Logger log.Logger
}
FindOpts adds some more hints what should happen when find methods of Repository are executed.
func (*FindOpts) GetPredicates ¶
func (this *FindOpts) GetPredicates() Predicates
func (*FindOpts) IsAutoCleanUpAllowed ¶
func (*FindOpts) WithPredicate ¶
type FsRepository ¶
func NewFsRepository ¶
func NewFsRepository(conf *configuration.SessionFs) (*FsRepository, error)
func (*FsRepository) Close ¶
func (this *FsRepository) Close() error
func (*FsRepository) Create ¶
func (this *FsRepository) Create(ctx context.Context, flow configuration.FlowName, remote common.Remote, authToken []byte) (Session, error)
func (*FsRepository) Delete ¶
func (this *FsRepository) Delete(ctx context.Context, s Session) error
func (*FsRepository) DeleteBy ¶
func (this *FsRepository) DeleteBy(ctx context.Context, flow configuration.FlowName, id uuid.UUID) error
func (*FsRepository) FindBy ¶
func (this *FsRepository) FindBy(ctx context.Context, flow configuration.FlowName, id uuid.UUID, opts *FindOpts) (Session, error)
func (*FsRepository) FindByAccessToken ¶
func (*FsRepository) FindByPublicKey ¶
type Info ¶
type Info interface {
Flow() configuration.FlowName
Id() uuid.UUID
State() State
Created(context.Context) (InfoCreated, error)
LastAccessed(context.Context) (InfoLastAccessed, error)
// ValidUntil defines until when the actual Session is valid to be used.
// If returned time.Time.IsZero() means forever.
ValidUntil(context.Context) (time.Time, error)
String() string
}
type Predicate ¶
func IsExpiredWithThreshold ¶
func IsFlow ¶
func IsFlow(flow configuration.FlowName) Predicate
func IsRemoteName ¶
type Predicates ¶
type Predicates []Predicate
type Repository ¶
type Repository interface {
Create(ctx context.Context, flow configuration.FlowName, remote common.Remote, authToken []byte) (Session, error)
FindBy(context.Context, configuration.FlowName, uuid.UUID, *FindOpts) (Session, error)
FindByPublicKey(context.Context, ssh.PublicKey, *FindOpts) (Session, error)
FindByAccessToken(context.Context, []byte, *FindOpts) (Session, error)
FindAll(context.Context, Consumer, *FindOpts) error
DeleteBy(context.Context, configuration.FlowName, uuid.UUID) error
Delete(context.Context, Session) error
}
type RepositoryFacade ¶
type RepositoryFacade struct {
CloseableRepository
}
func NewRepositoryFacade ¶
func NewRepositoryFacade(ctx context.Context, conf *configuration.Session) (*RepositoryFacade, error)
type Session ¶
type Session interface {
Flow() configuration.FlowName
Id() uuid.UUID
Info(context.Context) (Info, error)
AuthorizationToken(context.Context) ([]byte, error)
EnvironmentToken(context.Context) ([]byte, error)
HasPublicKey(context.Context, ssh.PublicKey) (bool, error)
// ConnectionInterceptor creates a new instance of ConnectionInterceptor to
// watch net.Conn of each connection related to this Session.
//
// It can return ErrMaxConnectionsPerSessionReached to indicate that no more
// net.Conn are allowed for this Session.
ConnectionInterceptor(context.Context) (ConnectionInterceptor, error)
SetAuthorizationToken(context.Context, []byte) error
SetEnvironmentToken(context.Context, []byte) error
AddPublicKey(context.Context, ssh.PublicKey) error
DeletePublicKey(context.Context, ssh.PublicKey) error
NotifyLastAccess(ctx context.Context, remote common.Remote, newState State) (oldState State, err error)
Dispose(ctx context.Context) (bool, error)
String() string
}
Click to show internal directories.
Click to hide internal directories.