secure

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Password added in v0.3.0

type Password interface {
	// HashPassword hashes the password.
	HashPassword(password string) string
	// HashMatchesPassword matches hash with password.
	HashMatchesPassword(hash, password string) bool
}

Password is abstract interface for dealing with password security.

type Secret added in v0.3.0

type Secret [32]byte

Secret stores secret of registration token.

func NewSecret added in v0.3.0

func NewSecret() (Secret, error)

NewSecret generates a random stream of bytes.

func SecretFromBase64 added in v0.3.0

func SecretFromBase64(s string) (Secret, error)

SecretFromBase64 creates new reset password secret from base64 string

func (Secret) String added in v0.3.0

func (secret Secret) String() string

String implements Stringer, it returns a URL-safe, base64 encoded string of the secret.

type Token added in v0.3.0

type Token struct {
	// Token in non-hashed format.
	// Useful to return back to the user, but not stored in the DB.
	Token string `json:"-"`
	// Secret stores the hash of the token.
	Secret string `json:"secret"`
	// OwnerID stores current token owner ID.
	OwnerID string `json:"ownerID"`
	// ID to uniquely identify a doc in the DB. This field is also not stored
	// in the DB, but only used to quickly find the doc when the user send back
	// the user send back the clear text hash.
	ID string `json:"-"`
	// Expiration represents the time the token will be  expired.
	Expiration int64 `json:"exp"`
}

Token represents a token model in the database.

type TokenGenerator added in v0.3.0

type TokenGenerator interface {
	// Create creates a new token.
	Create(ctx context.Context, ownerID string) (Token, error)
	// GetByOwnerID retrieves the Token object by id.
	GetByID(ctx context.Context, id string) (Token, error)
	// Delete deletes the Token object by id.
	Delete(ctx context.Context, id string) error
	// Hash hashes the clear text token and returns a string.
	Hash(ctx context.Context, b []byte) string
	// HashMatchesToken matches hash with token.
	HashMatchesToken(ctx context.Context, hash, token string) bool
}

TokenGenerator is interface for working with tokens.

Directories

Path Synopsis
Package token implements `TokenGenerator` for couchbase driver.
Package token implements `TokenGenerator` for couchbase driver.

Jump to

Keyboard shortcuts

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