Documentation
¶
Overview ¶
Package store provides interfaces and cryptographic primitives for Store implementations.
Index ¶
- Constants
- type ArgonHash
- type Authenticator
- func (a *Authenticator) AddPaperKey(ctx context.Context, keyOwner string, keyName string) (key *PaperKey, err error)
- func (a *Authenticator) Authenticate(ctx context.Context, keyOwner string, key string) (bool, error)
- func (a *Authenticator) ListPaperKeys(ctx context.Context, keyOwner string) ([]*PaperKey, error)
- func (a *Authenticator) RemoveOwner(ctx context.Context, keyOwner string) (err error)
- func (a *Authenticator) RemovePaperKey(ctx context.Context, ID string, keyOwner string) (err error)
- type Option
- type PaperKey
- type PostgresStore
- func (s *PostgresStore) Create(ctx context.Context, p *PaperKey) error
- func (s *PostgresStore) Delete(ctx context.Context, ID string) error
- func (s *PostgresStore) DeleteByOwner(ctx context.Context, owner string) error
- func (s *PostgresStore) RetrieveAll(ctx context.Context, owner string) (result []*PaperKey, err error)
- type SQLiteStore
- func (s *SQLiteStore) Create(ctx context.Context, p *PaperKey) error
- func (s *SQLiteStore) Delete(ctx context.Context, ID string) error
- func (s *SQLiteStore) DeleteByOwner(ctx context.Context, owner string) error
- func (s *SQLiteStore) RetrieveAll(ctx context.Context, owner string) (result []*PaperKey, err error)
- type Store
Constants ¶
View Source
const ( DefaultArgonKeyLength = 128 DefaultArgonTimeCost = 1 DefaultArgonMemoryCost = 64 * 1024 // recommended by x/crypto/argon2 DefaultArgonThreads = 4 )
View Source
const DefaultTableName = `kidwords_paper_keys`
View Source
const InstallPostgresTable = `` /* 232-byte string literal not displayed */
View Source
const InstallSQLiteTable = `` /* 208-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArgonHash ¶
type ArgonHash struct { Type string Version uint8 TimeCost uint32 MemoryCost uint32 ParallelThreads uint8 Salt []byte Secret []byte }
ArgonHash is a parameterized salted hash used for storing keys.
func NewArgonHash ¶
NewArgonHash creates an Argon2id hash using default parameters.
func NewCustomArgonHash ¶
func NewCustomArgonHash( key []byte, timeCost uint32, memoryCost uint32, parallelThreads uint8, ) (*ArgonHash, error)
NewCustomArgonHash creates an Argon hash.
func ParseArgonHash ¶
ParseArgonHash constructs an ArgonHash from a serialized string following the format `$<type>$v=<version>$m=<memory>,t=<time>,p=<parallel>$<salt>$<secret>`.
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator simplifies low level Store operations and secures them with reasonable defaults. Use it to verify that a particular owner knows one of the [PaperKey]s associated with them.
func NewAuthenticator ¶
func NewAuthenticator(using Store, desiredPaperKeyByteCount int64) (*Authenticator, error)
func (*Authenticator) AddPaperKey ¶
func (*Authenticator) Authenticate ¶
func (*Authenticator) ListPaperKeys ¶
func (*Authenticator) RemoveOwner ¶
func (a *Authenticator) RemoveOwner( ctx context.Context, keyOwner string, ) (err error)
func (*Authenticator) RemovePaperKey ¶
type Option ¶
type Option func(*options) error
func WithGuaranteedTable ¶
func WithGuaranteedTable() Option
func WithTableName ¶
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
func NewPostgresStore ¶
func NewPostgresStore(database *sql.DB, withOptions ...Option) (s *PostgresStore, err error)
func (*PostgresStore) Create ¶
func (s *PostgresStore) Create(ctx context.Context, p *PaperKey) error
func (*PostgresStore) DeleteByOwner ¶
func (s *PostgresStore) DeleteByOwner(ctx context.Context, owner string) error
func (*PostgresStore) RetrieveAll ¶
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
func NewSQLiteStore ¶
func NewSQLiteStore(database *sql.DB, withOptions ...Option) (s *SQLiteStore, err error)
func (*SQLiteStore) DeleteByOwner ¶
func (s *SQLiteStore) DeleteByOwner(ctx context.Context, owner string) error
func (*SQLiteStore) RetrieveAll ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.