Documentation ¶
Index ¶
Constants ¶
View Source
const UserAuthKey = "user"
UserAuthKey defines usename key in jwt token.
Variables ¶
This section is empty.
Functions ¶
func AuthHandler ¶
func AuthHandler(credentials CredentialsStorage) http.Handler
AuthHandler returns a new handler for authentication endpoints.
func Authenticator ¶
func Authenticator(credentials CredentialsStorage) func(next http.Handler) http.Handler
Authenticator returns authentication middleware.
Types ¶
type CredentialsStorage ¶
type CredentialsStorage interface { // Authenticate returns jwt token if provided password matches to a // stored hash for a given user, error returned otherwise. Authenticate(username, password string) (tokenString string, err error) // Validate validates provided jwt token against stored credentials. Validate(tokenString string) (username string, err error) }
CredentialsStorage stores and validates user credentials.
func NewMemoryCredentialsStorage ¶
func NewMemoryCredentialsStorage(hashes map[string]string, signingMethod jwt.SigningMethod, signKey interface{}) CredentialsStorage
NewMemoryCredentialsStorage returns a new CredentialsStorage that stores user credentials in memory.
Click to show internal directories.
Click to hide internal directories.