session

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyToc = errors.New("the provided Toc is empty")
View Source
var ErrKekInvalidLength = errors.New("the provided kek has an invalid length")
View Source
var ErrNotEnoughTocs = errors.New("the provided Tocs are less than the threshold")
View Source
var ErrSessionAlreadyExists = errors.New("a session with the requested ID already exists")
View Source
var ErrSessionNotFound = errors.New("session not found")
View Source
var ErrTocAlreadyExists = errors.New("the provided Toc already exists")
View Source
var ErrTocIsNotEncrypted = errors.New("the provided Toc is not a valid age armored string")

Functions

This section is empty.

Types

type DDBBatchWriteItemApi

type DDBBatchWriteItemApi interface {
	BatchWriteItem(ctx context.Context, params *ddb.BatchWriteItemInput, optFns ...func(*ddb.Options)) (*ddb.BatchWriteItemOutput, error)
}

type DDBGetItemApi

type DDBGetItemApi interface {
	GetItem(ctx context.Context, params *ddb.GetItemInput, optFns ...func(*ddb.Options)) (*ddb.GetItemOutput, error)
}

type DDBPutItemApi

type DDBPutItemApi interface {
	PutItem(ctx context.Context, params *ddb.PutItemInput, optFns ...func(*ddb.Options)) (*ddb.PutItemOutput, error)
}

type DDBQueryApi

type DDBQueryApi interface {
	Query(ctx context.Context, params *ddb.QueryInput, optFns ...func(*ddb.Options)) (*ddb.QueryOutput, error)
}

type DDBTransactWriteItemsApi

type DDBTransactWriteItemsApi interface {
	TransactWriteItems(ctx context.Context, params *ddb.TransactWriteItemsInput, optFns ...func(*ddb.Options)) (*ddb.TransactWriteItemsOutput, error)
}

type DynamoDbStore

type DynamoDbStore struct {
	// contains filtered or unexported fields
}

func (*DynamoDbStore) AddEncryptedToc

func (d *DynamoDbStore) AddEncryptedToc(id string, encryptedToc string) error

func (*DynamoDbStore) CreateSession

func (d *DynamoDbStore) CreateSession(session *api.Session, encryptedTEK []byte, encryptedTocZero string) error

func (*DynamoDbStore) GarbageCollect

func (d *DynamoDbStore) GarbageCollect(func(session *api.Session) bool)

func (*DynamoDbStore) GetEncryptedTocs

func (d *DynamoDbStore) GetEncryptedTocs(id string) ([]string, error)

func (*DynamoDbStore) GetSession

func (d *DynamoDbStore) GetSession(id string) (*api.Session, error)

func (*DynamoDbStore) GetTEK

func (d *DynamoDbStore) GetTEK(id string) ([]byte, error)

type InMemoryStore

type InMemoryStore struct {
	// contains filtered or unexported fields
}

InMemoryStore simply stores session in the process memory. If HA or reliability in the event of failure is needed, this is clearly not a great option...

func (*InMemoryStore) AddEncryptedToc

func (i *InMemoryStore) AddEncryptedToc(id string, encryptedToc string) error

func (*InMemoryStore) CreateSession

func (i *InMemoryStore) CreateSession(session *api.Session, encryptedTEK []byte, encryptedTocZero string) error

func (*InMemoryStore) GarbageCollect

func (i *InMemoryStore) GarbageCollect(shouldDelete func(session *api.Session) bool)

func (*InMemoryStore) GetEncryptedTocs

func (i *InMemoryStore) GetEncryptedTocs(id string) ([]string, error)

func (*InMemoryStore) GetSession

func (i *InMemoryStore) GetSession(id string) (*api.Session, error)

func (*InMemoryStore) GetTEK

func (i *InMemoryStore) GetTEK(id string) ([]byte, error)

type Oracle

type Oracle struct {
	// contains filtered or unexported fields
}

func NewOracle

func NewOracle(store Store) *Oracle

func (*Oracle) AddToc

func (o *Oracle) AddToc(id string, encryptedToc string) error

func (*Oracle) CreateSession

func (o *Oracle) CreateSession(tocZero *api.Toc) (*api.SessionCredentials, error)

func (*Oracle) GenerateTOTP

func (o *Oracle) GenerateTOTP(id string, key *api.SessionKeyEncryptionKey) (string, error)

func (*Oracle) GetSession

func (o *Oracle) GetSession(id string) (*api.Session, error)

type Store

type Store interface {
	// CreateSession is used to persist a new session.
	// It may return ErrSessionAlreadyExists if the ID in session has been already used
	CreateSession(session *api.Session, encryptedTEK []byte, encryptedTocZero string) error

	// GetSession retrieves a session by its ID.
	// ErrSessionNotFound may be returned if the provided ID does not exist.
	GetSession(id string) (*api.Session, error)

	// AddEncryptedToc is used to append a Toc to an existing session.
	// It may return ErrTocAlreadyExists if the provided value has already been seen
	// ErrSessionNotFound may also be returned.
	AddEncryptedToc(id string, encryptedToc string) error

	// GetEncryptedTocs returns a slice of strings with the encrypted Tocs
	GetEncryptedTocs(id string) ([]string, error)

	// GetTEK is used to retrieve the Toc encryption key
	GetTEK(id string) ([]byte, error)

	// GarbageCollect should process all sessions by sending them to the shouldDelete func;
	// if it returns true, remove the given session from storage
	GarbageCollect(shouldDelete func(session *api.Session) bool)
}

Store is used to keep track of Sessions, and their Tocs ErrSessionNotFound may be returned by any method where a session is referenced by ID

func NewDynamoDbStore

func NewDynamoDbStore(ctx context.Context, client DDBClient, table string) Store

func NewInMemoryStore

func NewInMemoryStore() Store

Jump to

Keyboard shortcuts

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