storage

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadgerStorage

type BadgerStorage struct {
	*badger.DB
	Path string
	// contains filtered or unexported fields
}

BadgerStorage is a type for a simple database storage backend -

func NewBadgerStorage

func NewBadgerStorage(path string) (*BadgerStorage, error)

NewBadgerStorage creates a new BadgerStorage at the passed storage location

func (*BadgerStorage) Delete

func (store *BadgerStorage) Delete(key string) error

Delete deletes the value associated with the given key from the database

func (*BadgerStorage) Load

func (store *BadgerStorage) Load() error

Load loads the database

func (*BadgerStorage) Read

func (store *BadgerStorage) Read(key string, target any) (bool, error)

Read reads the value for a given key into target

func (*BadgerStorage) SubordinateStorage

func (store *BadgerStorage) SubordinateStorage() *SubordinateBadgerStorage

SubordinateStorage gives a SubordinateBadgerStorage

func (*BadgerStorage) TrustMarkedEntitiesStorage

func (store *BadgerStorage) TrustMarkedEntitiesStorage() *TrustMarkedEntitiesBadgerStorage

TrustMarkedEntitiesStorage gives a TrustMarkedEntitiesBadgerStorage

func (*BadgerStorage) Write

func (store *BadgerStorage) Write(key string, value any) error

Write writes a value to the database

type BadgerSubStorage

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

BadgerSubStorage is a type for a sub-storage of a BadgerStorage

func (*BadgerSubStorage) Delete

func (store *BadgerSubStorage) Delete(key string) error

Delete deletes the value associated with the given key from the sub-database

func (*BadgerSubStorage) Load

func (store *BadgerSubStorage) Load() error

Load loads the database

func (*BadgerSubStorage) Read

func (store *BadgerSubStorage) Read(key string, target any) (bool, error)

Read reads the value for a given key into target

func (*BadgerSubStorage) ReadIterator

func (store *BadgerSubStorage) ReadIterator(do func(k, v []byte) error, prefix ...string) error

ReadIterator uses the passed iterator function do iterate over all the key-value-pairs in this sub storage

func (*BadgerSubStorage) Write

func (store *BadgerSubStorage) Write(key string, value any) error

Write writes a values to the sub-database

type BadgerSubordinateStorageQuery

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

BadgerSubordinateStorageQuery is a type implementing the SubordinateStorageQuery interface for a SubordinateBadgerStorage

func (*BadgerSubordinateStorageQuery) AddFilter

AddFilter implements the SubordinateStorageQuery interface

func (BadgerSubordinateStorageQuery) EntityIDs

func (q BadgerSubordinateStorageQuery) EntityIDs() (ids []string, err error)

EntityIDs implements the SubordinateStorageQuery interface

func (BadgerSubordinateStorageQuery) Subordinate

func (q BadgerSubordinateStorageQuery) Subordinate(entityID string) (*SubordinateInfo, error)

Subordinate implements the SubordinateStorageQuery interface

func (BadgerSubordinateStorageQuery) Subordinates

func (q BadgerSubordinateStorageQuery) Subordinates() (infos []SubordinateInfo, err error)

Subordinates implements the SubordinateStorageQuery interface

type FileStorage

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

FileStorage is a storage backend for storing things in files

func NewFileStorage

func NewFileStorage(basepath string) *FileStorage

NewFileStorage creates a new FileStorage at the given path

func (*FileStorage) SubordinateStorage

func (store *FileStorage) SubordinateStorage() SubordinateStorageBackend

SubordinateStorage returns a file-based SubordinateStorageBackend

func (*FileStorage) TrustMarkedEntitiesStorage

func (store *FileStorage) TrustMarkedEntitiesStorage() TrustMarkedEntitiesStorageBackend

TrustMarkedEntitiesStorage returns a file-based TrustMarkedEntitiesStorageBackend

type Status

type Status int

Status is a type for holding a status for something that is stored in the database; this type describes the status or state of the entity, e.g. "blocked" or "active"

const (
	StatusActive Status = iota
	StatusBlocked
	StatusPending
	StatusInactive
)

Constants for Status

type SubordinateBadgerStorage

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

SubordinateBadgerStorage is a type implementing the SubordinateStorageBackend interface

func (*SubordinateBadgerStorage) Active

Active implements the SubordinateStorageBackend interface

func (*SubordinateBadgerStorage) All

All returns a SubordinateStorageQuery for all stored SubordinateInfos

func (*SubordinateBadgerStorage) Approve

func (store *SubordinateBadgerStorage) Approve(entityID string) error

Approve implements the SubordinateStorageBackend interface

func (*SubordinateBadgerStorage) Block

func (store *SubordinateBadgerStorage) Block(entityID string) error

Block implements the SubordinateStorageBackend interface

func (*SubordinateBadgerStorage) Blocked

Blocked implements the SubordinateStorageBackend interface

func (*SubordinateBadgerStorage) Delete

func (store *SubordinateBadgerStorage) Delete(entityID string) error

Delete implements the SubordinateStorageBackend interface

func (*SubordinateBadgerStorage) Load

func (store *SubordinateBadgerStorage) Load() error

Load implements the SubordinateStorageBackend interface

func (*SubordinateBadgerStorage) Pending

Pending implements the SubordinateStorageBackend interface

func (*SubordinateBadgerStorage) Read

func (store *SubordinateBadgerStorage) Read(entityID string) (*SubordinateInfo, error)

Read implements the SubordinateStorageBackend interface

func (*SubordinateBadgerStorage) Subordinate

func (store *SubordinateBadgerStorage) Subordinate(entityID string) (*SubordinateInfo, error)

Subordinate implements the SubordinateStorageBackend interface

func (*SubordinateBadgerStorage) Write

func (store *SubordinateBadgerStorage) Write(entityID string, info SubordinateInfo) error

Write implements the SubordinateStorageBackend interface

type SubordinateInfo

type SubordinateInfo struct {
	JWKS               jwx.JWKS                        `json:"jwks"`
	EntityTypes        []string                        `json:"entity_types"`
	EntityID           string                          `json:"entity_id"`
	Metadata           *oidfed.Metadata                `json:"metadata,omitempty"`
	MetadataPolicy     *oidfed.MetadataPolicies        `json:"metadata_policy,omitempty"`
	Constraints        *oidfed.ConstraintSpecification `json:"constraints,omitempty"`
	CriticalExtensions []string                        `json:"crit,omitempty"`
	MetadataPolicyCrit []oidfed.PolicyOperatorName     `json:"metadata_policy_crit,omitempty"`
	TrustMarks         oidfed.TrustMarkInfos           `json:"trust_marks,omitempty"`
	Extra              map[string]interface{}          `json:"-"`
	Status             Status                          `json:"status"`
}

SubordinateInfo holds information about a subordinate for storage

func (*SubordinateInfo) UnmarshalJSON

func (info *SubordinateInfo) UnmarshalJSON(src []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

func (*SubordinateInfo) UnmarshalMsgpack

func (info *SubordinateInfo) UnmarshalMsgpack(src []byte) error

UnmarshalMsgpack implements the msgpack.Unmarshaler interface

type SubordinateStorageBackend

type SubordinateStorageBackend interface {
	Write(entityID string, info SubordinateInfo) error
	Delete(entityID string) error
	Block(entityID string) error
	Approve(entityID string) error
	Subordinate(entityID string) (*SubordinateInfo, error)
	Active() SubordinateStorageQuery
	Blocked() SubordinateStorageQuery
	Pending() SubordinateStorageQuery
	Load() error
}

SubordinateStorageBackend is an interface to store SubordinateInfo

type SubordinateStorageQuery

type SubordinateStorageQuery interface {
	Subordinates() ([]SubordinateInfo, error)
	EntityIDs() ([]string, error)
	AddFilter(filter SubordinateStorageQueryFilter, value any) error
}

SubordinateStorageQuery is an interface to query SubordinateInfo from storage

type SubordinateStorageQueryFilter

type SubordinateStorageQueryFilter func(info SubordinateInfo, value any) bool

SubordinateStorageQueryFilter is function to filter SubordinateInfo

type TrustMarkedEntitiesBadgerStorage

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

TrustMarkedEntitiesBadgerStorage is a type implementing the TrustMarkedEntitiesStorageBackend interface

func (*TrustMarkedEntitiesBadgerStorage) Active

func (store *TrustMarkedEntitiesBadgerStorage) Active(trustMarkType string) ([]string, error)

Active implements the TrustMarkedEntitiesStorageBackend interface

func (*TrustMarkedEntitiesBadgerStorage) Approve

func (store *TrustMarkedEntitiesBadgerStorage) Approve(trustMarkType, entityID string) error

Approve implements the TrustMarkedEntitiesStorageBackend interface

func (*TrustMarkedEntitiesBadgerStorage) Block

func (store *TrustMarkedEntitiesBadgerStorage) Block(trustMarkType, entityID string) error

Block implements the TrustMarkedEntitiesStorageBackend interface

func (*TrustMarkedEntitiesBadgerStorage) Blocked

func (store *TrustMarkedEntitiesBadgerStorage) Blocked(trustMarkType string) ([]string, error)

Blocked implements the TrustMarkedEntitiesStorageBackend interface

func (*TrustMarkedEntitiesBadgerStorage) Delete

func (store *TrustMarkedEntitiesBadgerStorage) Delete(trustMarkType, entityID string) error

Delete implements the TrustMarkedEntitiesStorageBackend interface

func (*TrustMarkedEntitiesBadgerStorage) HasTrustMark

func (store *TrustMarkedEntitiesBadgerStorage) HasTrustMark(trustMarkType, entityID string) (bool, error)

HasTrustMark implements the TrustMarkedEntitiesStorageBackend interface

func (*TrustMarkedEntitiesBadgerStorage) Load

Load implements the SubordinateStorageBackend interface

func (*TrustMarkedEntitiesBadgerStorage) Pending

func (store *TrustMarkedEntitiesBadgerStorage) Pending(trustMarkType string) ([]string, error)

Pending implements the TrustMarkedEntitiesStorageBackend interface

func (*TrustMarkedEntitiesBadgerStorage) Request

func (store *TrustMarkedEntitiesBadgerStorage) Request(trustMarkType, entityID string) error

Request implements the TrustMarkedEntitiesStorageBackend interface

func (*TrustMarkedEntitiesBadgerStorage) TrustMarkedStatus

func (store *TrustMarkedEntitiesBadgerStorage) TrustMarkedStatus(trustMarkType, entityID string) (Status, error)

TrustMarkedStatus implements the TrustMarkedEntitiesStorageBackend interface

type TrustMarkedEntitiesStorageBackend

type TrustMarkedEntitiesStorageBackend interface {
	// Delete marks that a certain trust mark is no longer valid for a certain entity
	Delete(trustMarkType, entityID string) error
	// Block marks that a certain trust mark is blocked for a certain entity
	Block(trustMarkType, entityID string) error
	// Approve marks that a certain trust mark is valid for a certain entity
	Approve(trustMarkType, entityID string) error
	// Request marks that a certain trust mark is pending (waiting for approval) for a certain entity
	Request(trustMarkType, entityID string) error
	// TrustMarkedStatus returns the Status for the trustMarkType
	// entityID combination
	TrustMarkedStatus(trustMarkType, entityID string) (Status, error)
	// HasTrustMark checks if a certain entity has a certain trust mark or not
	HasTrustMark(trustMarkType, entityID string) (bool, error)
	// Active returns a list of entity ids that have a certain trust mark; if an
	// empty trustMarkType is passed all entities that have at least one valid
	// trust mark are returned
	Active(trustMarkType string) ([]string, error)
	// Blocked returns a list of entity ids that have been blocked from a
	// certain trust mark
	Blocked(trustMarkType string) ([]string, error)
	// Pending returns a list of entity ids that have pending approval for a
	// certain trust mark
	Pending(trustMarkType string) ([]string, error)
	// Load loads the storage
	Load() error
}

TrustMarkedEntitiesStorageBackend is an interface to store information about trust marked entities

Jump to

Keyboard shortcuts

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