secret

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2020 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSecret = errs.Class("no secret error")

ErrNoSecret represents errors from the secret database.

View Source
var ErrSecretService = errs.Class("secret service error")

ErrSecretService defines secret service error.

Functions

This section is empty.

Types

type DB

type DB interface {
	// Store stores secret token into db.
	Store(ctx context.Context, secret UniqSecret) error

	// Check checks if uniq secret exists in db by token.
	Check(ctx context.Context, token uuid.UUID) (_ bool, err error)

	// Revoke removes token from db.
	Revoke(ctx context.Context, token uuid.UUID) error
}

DB is interface for working with secret tokens.

architecture: Database

type Service

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

Service responsible for operations with storagenode's uniq secret.

architecture: Service

func (*Service) Check

func (service *Service) Check(ctx context.Context, token uuid.UUID) (_ bool, err error)

Check returns boolean values if unique secret exists in db by secret token.

func (*Service) Issue

func (service *Service) Issue(ctx context.Context) error

Issue generates new storagenode uniq secret and stores it into db.

func (*Service) Remove

func (service *Service) Remove(ctx context.Context, token uuid.UUID) error

Remove revokes token, delete's it from db.

type Token

type Token [32]byte

Token stores secret of sno token.

func NewSecretToken

func NewSecretToken() (Token, error)

NewSecretToken creates new secret token.

func TokenSecretFromBase64

func TokenSecretFromBase64(s string) (Token, error)

TokenSecretFromBase64 creates new secret token from base64 string.

func (Token) IsZero

func (secret Token) IsZero() bool

IsZero returns if the secret token is not set.

func (Token) String

func (secret Token) String() string

String implements Stringer.

type UniqSecret

type UniqSecret struct {
	// Secret is PK of the table and keeps unique value sno secret token
	Secret Token

	CreatedAt time.Time `json:"createdAt"`
}

UniqSecret describing secret model in the database.

Jump to

Keyboard shortcuts

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