Documentation ¶
Index ¶
Constants ¶
const JWTCookieName string = "token"
JWTCookieName name of the cookie JWT token is stored in
Variables ¶
var ( // ErrBadCredentials represents an error when validating wrong c. ErrBadCredentials = errors.New("bad credentials") )
var ( errors.New("unauthorized") )ErrUnauthorized =
Functions ¶
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator wraps CredentialsManager to provide an easy way of authentication for builtin UI.
func NewAuthenticator ¶
func NewAuthenticator() *Authenticator
NewAuthenticator creates an authenticator.
func (*Authenticator) ChangePassword ¶
func (a *Authenticator) ChangePassword(username, oldPassword, newPassword string) error
ChangePassword changes user password.
func (*Authenticator) CheckCredentials ¶
func (a *Authenticator) CheckCredentials(username, password string) error
CheckCredentials checks if provided username and password combo is valid comparing it to stored credentials.
type CredentialsManager ¶
type CredentialsManager struct {
// contains filtered or unexported fields
}
CredentialsManager verifies/sets user credentials for web UI.
func NewCredentialsManager ¶
func NewCredentialsManager(dataDir string) *CredentialsManager
NewCredentialsManager returns given a password file directory returns a new credentials manager, which can be used to validate or alter user credentials.
func (*CredentialsManager) SetPassword ¶
func (c *CredentialsManager) SetPassword(password string) error
SetPassword sets a new password for a user.
func (*CredentialsManager) Validate ¶
func (c *CredentialsManager) Validate(username, password string) error
Validate username and password against stored credentials.
type JWTAuthenticator ¶
type JWTAuthenticator struct {
// contains filtered or unexported fields
}
JWTAuthenticator contains JWT handling methods
func NewJWTAuthenticator ¶
func NewJWTAuthenticator(encryptionKey JWTEncryptionKey) *JWTAuthenticator
NewJWTAuthenticator creates a new JWT authentication instance
func (*JWTAuthenticator) CreateToken ¶
func (jwtAuth *JWTAuthenticator) CreateToken(username string) (JWT, error)
CreateToken creates a new JWT token
func (*JWTAuthenticator) ValidateToken ¶
func (jwtAuth *JWTAuthenticator) ValidateToken(token string) (bool, error)
ValidateToken validates a JWT token
type JWTEncryptionKey ¶
type JWTEncryptionKey []byte
JWTEncryptionKey contains the encryption key for JWT
func NewJWTEncryptionKey ¶
func NewJWTEncryptionKey(storage Storage) (JWTEncryptionKey, error)
NewJWTEncryptionKey creates and stores or re-uses an existing JWT encryption key