state

package
v0.0.0-...-56cb166 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BakeryConfigState

type BakeryConfigState struct {
	*domain.StateBase
}

BakeryConfigState describes the persistence layer for the macaroon bakery config

func NewBakeryConfigState

func NewBakeryConfigState(factory coredatabase.TxnRunnerFactory) *BakeryConfigState

NewBakeryConfigState returns a new config state reference

func (*BakeryConfigState) GetExternalUsersThirdPartyKey

func (st *BakeryConfigState) GetExternalUsersThirdPartyKey(ctx context.Context) (*bakery.KeyPair, error)

GetExternalUsersThirdPartyKey returns the third party key pair used with the external users bakery.

func (*BakeryConfigState) GetLocalUsersKey

func (st *BakeryConfigState) GetLocalUsersKey(ctx context.Context) (*bakery.KeyPair, error)

GetLocalUsersKey returns the key pair used with the local users bakery.

func (*BakeryConfigState) GetLocalUsersThirdPartyKey

func (st *BakeryConfigState) GetLocalUsersThirdPartyKey(ctx context.Context) (*bakery.KeyPair, error)

GetLocalUsersThirdPartyKey returns the third party key pair used with the local users bakery.

func (*BakeryConfigState) GetOffersThirdPartyKey

func (st *BakeryConfigState) GetOffersThirdPartyKey(ctx context.Context) (*bakery.KeyPair, error)

GetOffersThirdPartyKey returns the key pair used with the cross model offers bakery.

func (*BakeryConfigState) InitialiseBakeryConfig

func (st *BakeryConfigState) InitialiseBakeryConfig(
	ctx context.Context,
	localUsersKey,
	localUsersThirdPartyKey,
	externalUsersThirdPartyKey,
	offersThirdPartyKey *bakery.KeyPair,
) error

InitialiseBakeryConfig creates and fills in the bakery config in state.

type ExternalUsersThirdPartyKeyPair

type ExternalUsersThirdPartyKeyPair struct {
	ExternalUsersThirdPartyPrivateKey *keyScanner `db:"external_users_third_party_private_key"`
	ExternalUsersThirdPartyPublicKey  *keyScanner `db:"external_users_third_party_public_key"`
}

type FullConfig

type FullConfig struct {
	LocalUsersPrivateKey              *keyScanner `db:"local_users_private_key"`
	LocalUsersPublicKey               *keyScanner `db:"local_users_public_key"`
	LocalUsersThirdPartyPrivateKey    *keyScanner `db:"local_users_third_party_private_key"`
	LocalUsersThirdPartyPublicKey     *keyScanner `db:"local_users_third_party_public_key"`
	ExternalUsersThirdPartyPrivateKey *keyScanner `db:"external_users_third_party_private_key"`
	ExternalUsersThirdPartyPublicKey  *keyScanner `db:"external_users_third_party_public_key"`
	OffersThirdPartyPrivateKey        *keyScanner `db:"offers_third_party_private_key"`
	OffersThirdPartyPublicKey         *keyScanner `db:"offers_third_party_public_key"`
}

FullConfig holds the full macaroon bakery config data

type LocalUsersKeyPair

type LocalUsersKeyPair struct {
	LocalUsersPrivateKey *keyScanner `db:"local_users_private_key"`
	LocalUsersPublicKey  *keyScanner `db:"local_users_public_key"`
}

type LocalUsersThirdPartyKeyPair

type LocalUsersThirdPartyKeyPair struct {
	LocalUsersThirdPartyPrivateKey *keyScanner `db:"local_users_third_party_private_key"`
	LocalUsersThirdPartyPublicKey  *keyScanner `db:"local_users_third_party_public_key"`
}

type OffersThirdPartyKeyPair

type OffersThirdPartyKeyPair struct {
	OffersThirdPartyPrivateKey *keyScanner `db:"offers_third_party_private_key"`
	OffersThirdPartyPublicKey  *keyScanner `db:"offers_third_party_public_key"`
}

type RootKeyState

type RootKeyState struct {
	*domain.StateBase
}

RootKeyState describes the persistence layer for macaroon root keys

func NewRootKeyState

func NewRootKeyState(factory coredatabase.TxnRunnerFactory) *RootKeyState

NewRootKeyState return a new macaroon root key state reference

func (*RootKeyState) FindLatestKey

func (st *RootKeyState) FindLatestKey(ctx context.Context, createdAfter, expiresAfter, expiresBefore, now time.Time) (macaroon.RootKey, error)

FindLatestKey returns the most recently created root key k following all the conditions:

k.Created >= createdAfter k.Expires >= expiresAfter k.Expires <= expiresBefore

If no such key was found, return a macaroonerrors.KeyNotFound error

func (*RootKeyState) GetKey

func (st *RootKeyState) GetKey(ctx context.Context, id []byte, now time.Time) (macaroon.RootKey, error)

GetKey gets the key with a given id from dqlite. If not key is found, a macaroonerrors.KeyNotFound error is returned.

func (*RootKeyState) InsertKey

func (st *RootKeyState) InsertKey(ctx context.Context, key macaroon.RootKey) error

InsertKey inserts the given root key into dqlite. If a key with matching id already exists, return a macaroonerrors.KeyAlreadyExists error.

type State

type State struct {
	*BakeryConfigState
	*RootKeyState
}

State describes the persistence layer for macaroon bakery bakery storage

func NewState

func NewState(factory database.TxnRunnerFactory) *State

NewState returns a new state reference

Jump to

Keyboard shortcuts

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