Documentation
¶
Index ¶
- func APIKey(config APIKeyConfig) goexpress.Middleware
- func BasicAuth(config BasicAuthConfig) goexpress.Middleware
- func CheckPassword(password, hash string) bool
- func GenerateToken(claims jwt.MapClaims, secret string, expirationTime time.Duration) (string, error)
- func HashPassword(password string) (string, error)
- func JWT(config JWTConfig) goexpress.Middleware
- func RefreshToken(tokenString, secret string, expirationTime time.Duration) (string, error)
- func SecureCompare(a, b string) bool
- func Session(config SessionConfig) goexpress.Middleware
- func VerifyToken(tokenString, secret string) (jwt.MapClaims, error)
- type APIKeyConfig
- type BasicAuthConfig
- type JWTConfig
- type SessionConfig
- type SessionStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIKey ¶
func APIKey(config APIKeyConfig) goexpress.Middleware
APIKey returns an API key authentication middleware
func BasicAuth ¶
func BasicAuth(config BasicAuthConfig) goexpress.Middleware
BasicAuth returns a basic authentication middleware
func CheckPassword ¶
CheckPassword checks if a password matches the hash
func GenerateToken ¶
func GenerateToken(claims jwt.MapClaims, secret string, expirationTime time.Duration) (string, error)
GenerateToken generates a JWT token with the given claims
func HashPassword ¶
HashPassword hashes a password using bcrypt
func JWT ¶
func JWT(config JWTConfig) goexpress.Middleware
JWT returns a JWT authentication middleware
func RefreshToken ¶
RefreshToken generates a new token from an existing one
func SecureCompare ¶
SecureCompare performs a constant-time comparison of two strings
func Session ¶
func Session(config SessionConfig) goexpress.Middleware
Session returns a session middleware
Types ¶
type APIKeyConfig ¶
type APIKeyConfig struct {
Validator func(key string) bool
KeyLookup string // "header:<name>" or "query:<name>"
ContextKey string
ErrorHandler goexpress.HandlerFunc
}
APIKeyConfig holds API key authentication configuration
type BasicAuthConfig ¶
type BasicAuthConfig struct {
Validator func(username, password string) bool
Realm string
ErrorHandler goexpress.HandlerFunc
}
BasicAuthConfig holds basic authentication configuration
type JWTConfig ¶
type JWTConfig struct {
Secret string
SigningMethod jwt.SigningMethod
TokenLookup string // "header:<name>" or "query:<name>" or "cookie:<name>"
ContextKey string
ErrorHandler goexpress.HandlerFunc
SkipperFunc func(*goexpress.Context) bool
ExpirationTime time.Duration
}
JWTConfig holds JWT configuration
func DefaultJWTConfig ¶
DefaultJWTConfig returns a default JWT configuration
type SessionConfig ¶
type SessionConfig struct {
Store SessionStore
CookieName string
CookiePath string
CookieDomain string
MaxAge int
Secure bool
HttpOnly bool
SameSite http.SameSite
}
SessionConfig holds session configuration
func DefaultSessionConfig ¶
func DefaultSessionConfig(store SessionStore) SessionConfig
DefaultSessionConfig returns a default session configuration