kv

package
v0.0.0-...-e2594dc Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperatorPrefix = "O"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KvProvider

type KvProvider struct {
	Bucket     string
	Nc         *nats.Conn
	Js         jetstream.JetStream
	Kv         jetstream.KeyValue
	EncryptKey nkeys.KeyPair
}

KvProvider is an AuthProvider that stores data in a JetStream KeyValue store The data is stored in the following format: Operators "O.<operatorPublicKey>" -> operator JWT Accounts "<operatorPublicKey>.<accountPublicKey>" -> account JWT Users "<accountPublicKey>.<userPublicKey>" -> user JWT Keys "keys.<publicKey>" -> seeds The required arguments are a natsURL, bucket name, and an optional encryption key. if an optional encryption key (an nkey CurveKeys) is used, the keys will be encrypted and require the same key to be decrypted.

func NewKvProvider

func NewKvProvider(opts ...KvProviderOption) (*KvProvider, error)

func NewKvProviderWithConnection

func NewKvProviderWithConnection(nc *nats.Conn, bucket string, encrypt string) (*KvProvider, error)

func (*KvProvider) DeleteAccount

func (p *KvProvider) DeleteAccount(a *ab.AccountData) error

func (*KvProvider) DeleteKey

func (p *KvProvider) DeleteKey(key string) error

func (*KvProvider) DeleteUser

func (p *KvProvider) DeleteUser(u *ab.UserData) error

func (*KvProvider) Destroy

func (p *KvProvider) Destroy() error

func (*KvProvider) Disconnect

func (p *KvProvider) Disconnect()

func (*KvProvider) GetChildren

func (p *KvProvider) GetChildren(prefix string) (map[string][]byte, error)

GetChildren returns entities are stored under <prefix>.<childPublicKey>

func (*KvProvider) GetKey

func (p *KvProvider) GetKey(pk string) (*ab.Key, error)

func (*KvProvider) Load

func (p *KvProvider) Load() ([]*ab.OperatorData, error)

func (*KvProvider) LoadAccounts

func (p *KvProvider) LoadAccounts(od *ab.OperatorData) error

func (*KvProvider) LoadOperators

func (p *KvProvider) LoadOperators() ([]*ab.OperatorData, error)

func (*KvProvider) LoadUsers

func (p *KvProvider) LoadUsers(ad *ab.AccountData) error

func (*KvProvider) PutKey

func (p *KvProvider) PutKey(key *ab.Key) error

func (*KvProvider) Store

func (p *KvProvider) Store(operators []*ab.OperatorData) error

func (*KvProvider) StoreAccount

func (p *KvProvider) StoreAccount(a *ab.AccountData) error

func (*KvProvider) StoreOperator

func (p *KvProvider) StoreOperator(o *ab.OperatorData) error

func (*KvProvider) StoreUser

func (p *KvProvider) StoreUser(u *ab.UserData) error

type KvProviderOption

type KvProviderOption func(*KvProviderOptions) error

func Bucket

func Bucket(bucket string) KvProviderOption

func EncryptKey

func EncryptKey(key string) KvProviderOption

func NatsContext

func NatsContext(context string) KvProviderOption

func NatsOptions

func NatsOptions(url string, options ...nats.Option) KvProviderOption

type KvProviderOptions

type KvProviderOptions struct {
	NatsContext string
	NatsOptions []nats.Option
	Bucket      string
	EncryptKey  string
}

Jump to

Keyboard shortcuts

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