cosmosdb

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DATABASE_NAME        = "gatewayDB"
	USERS_CONTAINER_NAME = "users"
)

Constants for the CosmosDB database and container names

View Source
const (
	METRICS_CONTAINER_NAME = "metrics"
	METRICS_DOC_ID         = "global_metrics"
)
View Source
const (
	CERT_CONTAINER_NAME = "certificates"
)
View Source
const MAX_RETRIES = 3

Variables

This section is empty.

Functions

This section is empty.

Types

type CertStorageCosmosDB added in v1.0.0

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

CertStorageCosmosDB implements autocert.Cache interface using CosmosDB

func NewCertStorageCosmosDB added in v1.0.0

func NewCertStorageCosmosDB(connectionString string, encryptionKey []byte, encryptionEnabled bool) (*CertStorageCosmosDB, error)

NewCertStorageCosmosDB creates a new CosmosDB-based certificate storage

func (*CertStorageCosmosDB) Delete added in v1.0.0

func (c *CertStorageCosmosDB) Delete(ctx context.Context, key string) error

Delete removes certificate data for the given key

func (*CertStorageCosmosDB) Get added in v1.0.0

func (c *CertStorageCosmosDB) Get(ctx context.Context, key string) ([]byte, error)

Get retrieves a certificate data for the given key

func (*CertStorageCosmosDB) Put added in v1.0.0

func (c *CertStorageCosmosDB) Put(ctx context.Context, key string, data []byte) error

Put stores certificate data with the given key

type CosmosDB

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

CosmosDB struct represents the CosmosDB storage implementation

func NewCosmosDB

func NewCosmosDB(connectionString string, encryptionKey []byte) (*CosmosDB, error)

func (*CosmosDB) ActivateSessionKey added in v1.0.0

func (c *CosmosDB) ActivateSessionKey(userID []byte, active bool) error

Sets the ActiveSK flag for the user, with retries on ETag mismatch

func (*CosmosDB) AddAccount

func (c *CosmosDB) AddAccount(userID []byte, accountAddress []byte, signature []byte, signatureType viewingkey.SignatureType) error

Adds a new account for the user, with retries on ETag mismatch

func (*CosmosDB) AddSessionKey added in v1.0.0

func (c *CosmosDB) AddSessionKey(userID []byte, key common.GWSessionKey) error

Adds or updates a session key for the user, with retries on ETag mismatch

func (*CosmosDB) AddUser

func (c *CosmosDB) AddUser(userID []byte, privateKey []byte) error

func (*CosmosDB) DeleteUser

func (c *CosmosDB) DeleteUser(userID []byte) error

func (*CosmosDB) GetEncryptionKey added in v1.0.0

func (c *CosmosDB) GetEncryptionKey() []byte

GetEncryptionKey returns the encryption key used by the CosmosDB instance

func (*CosmosDB) GetUser

func (c *CosmosDB) GetUser(userID []byte) (*common.GWUser, error)

func (*CosmosDB) RemoveSessionKey added in v1.0.0

func (c *CosmosDB) RemoveSessionKey(userID []byte) error

Removes the session key for the user, with retries on ETag mismatch

type EncryptedCertDocument added in v1.0.0

type EncryptedCertDocument struct {
	ID   string `json:"id"`
	Data []byte `json:"data"`
}

EncryptedCertDocument represents the structure of a certificate document in CosmosDB

type EncryptedDocument

type EncryptedDocument struct {
	ID   string `json:"id"`
	Data []byte `json:"data"`
}

EncryptedDocument struct is used to store encrypted user data in CosmosDB We use this structure to add an extra layer of security by encrypting the actual user data The 'ID' field is used as the document ID and partition key in CosmosDB The 'Data' field contains the base64-encoded encrypted user data

type MetricsDocument added in v1.0.0

type MetricsDocument struct {
	ID                 string            `json:"id"`
	TotalUsers         uint64            `json:"totalUsers"`
	AccountsRegistered uint64            `json:"accountsRegistered"`
	ActiveUsers        map[string]string `json:"activeUsers"` // double-hashed userID -> ISO timestamp
	ActiveUsersCount   int               `json:"activeUsersCount"`
	LastUpdated        string            `json:"lastUpdated"`
}

type MetricsStorage added in v1.0.0

type MetricsStorage interface {
	LoadMetrics() (*MetricsDocument, error)
	SaveMetrics(*MetricsDocument) error
}

MetricsStorage interface defines the metrics storage operations

func NewNoOpMetricsStorage added in v1.0.0

func NewNoOpMetricsStorage() MetricsStorage

type MetricsStorageCosmosDB added in v1.0.0

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

MetricsStorageCosmosDB handles metrics persistence in CosmosDB

func NewMetricsStorage added in v1.0.0

func NewMetricsStorage(connectionString string) (*MetricsStorageCosmosDB, error)

func (*MetricsStorageCosmosDB) LoadMetrics added in v1.0.0

func (m *MetricsStorageCosmosDB) LoadMetrics() (*MetricsDocument, error)

func (*MetricsStorageCosmosDB) SaveMetrics added in v1.0.0

func (m *MetricsStorageCosmosDB) SaveMetrics(metrics *MetricsDocument) error

Jump to

Keyboard shortcuts

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