Documentation
¶
Index ¶
- Variables
- func CompareArgon2id(hash, password string) bool
- func ComparePassword(hash, password string) bool
- func GenerateSecret() (string, error)
- func HashArgon2id(password string) (string, error)
- func HashPassword(password string) (string, error)
- func ParseUnverified(tokenString string, claims *Claims) (*jwt.Token, error)
- func Sign(cfg Config, userID uint, username, role string, tokenVersion int, ...) (string, error)
- type Claims
- type Config
- type ContextKey
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidArgon2Hash = errors.New("argon2 encoded hash is not in the correct format") ErrIncompatibleArgon2Version = errors.New("incompatible argon2 version") )
View Source
var ErrTokenVersionMismatch = errors.New("token version mismatch")
Functions ¶
func CompareArgon2id ¶
CompareArgon2id returns true if password matches the Argon2id-encoded hash.
func ComparePassword ¶
ComparePassword compares a password with a hash.
func GenerateSecret ¶
GenerateSecret creates a 32-byte random secret for signing.
func HashArgon2id ¶
HashArgon2id hashes a password using Argon2id and returns a PHC-encoded string.
func HashPassword ¶
HashPassword hashes a password using bcrypt.
func ParseUnverified ¶
ParseUnverified parses a JWT without verifying the signature.
Types ¶
type Claims ¶
type Claims struct {
jwt.RegisteredClaims
UserID uint `json:"userId"`
Username string `json:"username"`
Role string `json:"role"`
TokenVersion int `json:"tokenVersion"`
}
Claims holds JWT claims.
type ContextKey ¶
type ContextKey string
ContextKey is the type for context keys.
const ClaimsKey ContextKey = "claims"
ClaimsKey is the context key for JWT claims.
Click to show internal directories.
Click to hide internal directories.