db

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2019 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExists = errors.New("already exists")

ErrAlreadyExists can be returned if the DB attempts to set a key that has been previously set.

View Source
var ErrNotImplemented = errors.Errorf("not implemented")

ErrNotImplemented is an error returned when an operation is Not Implemented.

Functions

This section is empty.

Types

type AuthDB

type AuthDB interface {
	IsRevoked(sn string) (bool, error)
	Revoke(rci *RevokedCertificateInfo) error
	StoreCertificate(crt *x509.Certificate) error
	UseToken(id, tok string) (bool, error)
	Shutdown() error
}

AuthDB is an interface over an Authority DB client that implements a nosql.DB interface.

func New

func New(c *Config) (AuthDB, error)

New returns a new database client that implements the AuthDB interface.

type Config

type Config struct {
	Type       string `json:"type"`
	DataSource string `json:"dataSource"`
	ValueDir   string `json:"valueDir,omitempty"`
	Database   string `json:"database,omitempty"`
}

Config represents the JSON attributes used for configuring a step-ca DB.

type DB

type DB struct {
	nosql.DB
	// contains filtered or unexported fields
}

DB is a wrapper over the nosql.DB interface.

func (*DB) IsRevoked

func (db *DB) IsRevoked(sn string) (bool, error)

IsRevoked returns whether or not a certificate with the given identifier has been revoked. In the case of an X509 Certificate the `id` should be the Serial Number of the Certificate.

func (*DB) Revoke

func (db *DB) Revoke(rci *RevokedCertificateInfo) error

Revoke adds a certificate to the revocation table.

func (*DB) Shutdown

func (db *DB) Shutdown() error

Shutdown sends a shutdown message to the database.

func (*DB) StoreCertificate

func (db *DB) StoreCertificate(crt *x509.Certificate) error

StoreCertificate stores a certificate PEM.

func (*DB) UseToken added in v0.11.0

func (db *DB) UseToken(id, tok string) (bool, error)

UseToken returns true if we were able to successfully store the token for for the first time, false otherwise.

type MockNoSQLDB added in v0.13.0

type MockNoSQLDB struct {
	Err          error
	Ret1, Ret2   interface{}
	MGet         func(bucket, key []byte) ([]byte, error)
	MSet         func(bucket, key, value []byte) error
	MOpen        func(dataSourceName string, opt ...database.Option) error
	MClose       func() error
	MCreateTable func(bucket []byte) error
	MDeleteTable func(bucket []byte) error
	MDel         func(bucket, key []byte) error
	MList        func(bucket []byte) ([]*database.Entry, error)
	MUpdate      func(tx *database.Tx) error
	MCmpAndSwap  func(bucket, key, old, newval []byte) ([]byte, bool, error)
}

MockNoSQLDB //

func (*MockNoSQLDB) Close added in v0.13.0

func (m *MockNoSQLDB) Close() error

Close mock

func (*MockNoSQLDB) CmpAndSwap added in v0.13.0

func (m *MockNoSQLDB) CmpAndSwap(bucket, key, old, newval []byte) ([]byte, bool, error)

CmpAndSwap mock

func (*MockNoSQLDB) CreateTable added in v0.13.0

func (m *MockNoSQLDB) CreateTable(bucket []byte) error

CreateTable mock

func (*MockNoSQLDB) Del added in v0.13.0

func (m *MockNoSQLDB) Del(bucket, key []byte) error

Del mock

func (*MockNoSQLDB) DeleteTable added in v0.13.0

func (m *MockNoSQLDB) DeleteTable(bucket []byte) error

DeleteTable mock

func (*MockNoSQLDB) Get added in v0.13.0

func (m *MockNoSQLDB) Get(bucket, key []byte) ([]byte, error)

Get mock

func (*MockNoSQLDB) List added in v0.13.0

func (m *MockNoSQLDB) List(bucket []byte) ([]*database.Entry, error)

List mock

func (*MockNoSQLDB) Open added in v0.13.0

func (m *MockNoSQLDB) Open(dataSourceName string, opt ...database.Option) error

Open mock

func (*MockNoSQLDB) Set added in v0.13.0

func (m *MockNoSQLDB) Set(bucket, key, value []byte) error

Set mock

func (*MockNoSQLDB) Update added in v0.13.0

func (m *MockNoSQLDB) Update(tx *database.Tx) error

Update mock

type RevokedCertificateInfo

type RevokedCertificateInfo struct {
	Serial        string
	ProvisionerID string
	ReasonCode    int
	Reason        string
	RevokedAt     time.Time
	TokenID       string
	MTLS          bool
}

RevokedCertificateInfo contains information regarding the certificate revocation action.

type SimpleDB added in v0.11.0

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

SimpleDB is a barebones implementation of the DB interface. It is NOT an in memory implementation of the DB, but rather the bare minimum of functionality that the CA requires to operate securely.

func (*SimpleDB) Close added in v0.13.0

func (s *SimpleDB) Close() error

Close closes the current database.

func (*SimpleDB) CmpAndSwap added in v0.13.0

func (s *SimpleDB) CmpAndSwap(bucket, key, oldValue, newValue []byte) ([]byte, bool, error)

CmpAndSwap swaps the value at the given bucket and key if the current value is equivalent to the oldValue input. Returns 'true' if the swap was successful and 'false' otherwise.

func (*SimpleDB) CreateTable added in v0.13.0

func (s *SimpleDB) CreateTable(bucket []byte) error

CreateTable creates a table or a bucket in the database.

func (*SimpleDB) Del added in v0.13.0

func (s *SimpleDB) Del(bucket, key []byte) error

Del deletes the data in the given table/bucket and key.

func (*SimpleDB) DeleteTable added in v0.13.0

func (s *SimpleDB) DeleteTable(bucket []byte) error

DeleteTable deletes a table or a bucket in the database.

func (*SimpleDB) Get added in v0.13.0

func (s *SimpleDB) Get(bucket, key []byte) ([]byte, error)

Get returns the value stored in the given table/bucket and key.

func (*SimpleDB) IsRevoked added in v0.11.0

func (s *SimpleDB) IsRevoked(sn string) (bool, error)

IsRevoked noop

func (*SimpleDB) List added in v0.13.0

func (s *SimpleDB) List(bucket []byte) ([]*database.Entry, error)

List returns a list of all the entries in a given table/bucket.

func (*SimpleDB) Open added in v0.13.0

func (s *SimpleDB) Open(dataSourceName string, opt ...database.Option) error

Open opens the database available with the given options.

func (*SimpleDB) Revoke added in v0.11.0

func (s *SimpleDB) Revoke(rci *RevokedCertificateInfo) error

Revoke returns a "NotImplemented" error.

func (*SimpleDB) Set added in v0.13.0

func (s *SimpleDB) Set(bucket, key, value []byte) error

Set sets the given value in the given table/bucket and key.

func (*SimpleDB) Shutdown added in v0.11.0

func (s *SimpleDB) Shutdown() error

Shutdown returns nil

func (*SimpleDB) StoreCertificate added in v0.11.0

func (s *SimpleDB) StoreCertificate(crt *x509.Certificate) error

StoreCertificate returns a "NotImplemented" error.

func (*SimpleDB) Update added in v0.13.0

func (s *SimpleDB) Update(tx *database.Tx) error

Update performs a transaction with multiple read-write commands.

func (*SimpleDB) UseToken added in v0.11.0

func (s *SimpleDB) UseToken(id, tok string) (bool, error)

UseToken returns a "NotImplemented" error.

Jump to

Keyboard shortcuts

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