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 SecretFromBase64 ¶ added in v0.3.0
SecretFromBase64 creates new reset password secret from base64 string
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.
Click to show internal directories.
Click to hide internal directories.