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 FacadeRepository
- type FindOpts
- type FsRepository
- func (this *FsRepository) Close() error
- func (this *FsRepository) Create(ctx context.Context, flow configuration.FlowName, remote net.Remote, ...) (Session, error)
- func (this *FsRepository) Delete(ctx context.Context, s Session) error
- func (this *FsRepository) DeleteBy(ctx context.Context, flow configuration.FlowName, id Id) error
- func (this *FsRepository) FindAll(ctx context.Context, consumer Consumer, opts *FindOpts) error
- func (this *FsRepository) FindBy(ctx context.Context, flow configuration.FlowName, id Id, 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 Id
- func (this *Id) DecodeMsgPack(dec codec.MsgPackDecoder) error
- func (this *Id) DecodeMsgpack(dec *msgpack.Decoder) error
- func (this Id) EncodeMsgPack(enc codec.MsgPackEncoder) error
- func (this Id) EncodeMsgpack(enc *msgpack.Encoder) error
- func (this Id) IsEqualTo(other any) bool
- func (this Id) IsZero() bool
- func (this Id) MarshalBinary() (b []byte, err error)
- func (this Id) MarshalText() (text []byte, err error)
- func (this *Id) Set(text string) error
- func (this Id) String() string
- func (this *Id) UnmarshalBinary(b []byte) error
- func (this *Id) UnmarshalText(text []byte) error
- type Info
- type InfoCreated
- type InfoLastAccessed
- type Predicate
- type Predicates
- type Repository
- type RepositoryFactory
- type Session
- type State
Constants ¶
View Source
const ( FsFileSession = "s" FsFileLastAccessed = "la" FsFileAccessToken = "at" FsFileEnvironmentToken = "et" FsFilePublicKeysPrefix = "pk-" FsFilePublicKeysPrefixLen = len(FsFilePublicKeysPrefix) )
View Source
const (
EnvName = "BIFROEST_SESSION_ID"
)
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 FacadeRepository ¶ added in v0.2.0
type FacadeRepository struct {
CloseableRepository
}
func NewFacadeRepository ¶ added in v0.2.0
func NewFacadeRepository(ctx context.Context, conf *configuration.Session) (*FacadeRepository, error)
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(_ context.Context, 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 net.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 Id) error
func (*FsRepository) FindBy ¶
func (this *FsRepository) FindBy(ctx context.Context, flow configuration.FlowName, id Id, opts *FindOpts) (Session, error)
func (*FsRepository) FindByAccessToken ¶
func (*FsRepository) FindByPublicKey ¶
type Id ¶ added in v0.4.0
func (*Id) DecodeMsgPack ¶ added in v0.4.0
func (this *Id) DecodeMsgPack(dec codec.MsgPackDecoder) error
func (*Id) DecodeMsgpack ¶ added in v0.4.0
func (Id) EncodeMsgPack ¶ added in v0.4.0
func (this Id) EncodeMsgPack(enc codec.MsgPackEncoder) error
func (Id) MarshalBinary ¶ added in v0.4.0
func (Id) MarshalText ¶ added in v0.4.0
func (*Id) UnmarshalBinary ¶ added in v0.4.0
func (*Id) UnmarshalText ¶ added in v0.4.0
type Info ¶
type Info interface {
Flow() configuration.FlowName
Id() Id
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 net.Remote, authToken []byte) (Session, error)
FindBy(context.Context, configuration.FlowName, Id, *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, Id) error
Delete(context.Context, Session) error
}
type RepositoryFactory ¶ added in v0.2.0
type RepositoryFactory[C any, R CloseableRepository] func(ctx context.Context, conf C) (R, error)
func RegisterRepository ¶ added in v0.2.0
func RegisterRepository[C any, R CloseableRepository](factory RepositoryFactory[C, R]) RepositoryFactory[C, R]
type Session ¶
type Session interface {
Flow() configuration.FlowName
Id() Id
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 net.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.