package
module
Version:
v0.0.0-...-f641761
Opens a new window with list of versions in this module.
Published: Apr 4, 2020
License: MIT
Opens a new window with license information.
Imports: 5
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
gauth
Handles authentication using basic auth or JWTs.
Types
JWTAuth
: Does JWT authentication. Contains the secret key used to sign JWTs as well as the expiration time.
BasicAuth
: Defines an interface for handling basic auth.
StaticBasicAuth
: BasicAuth
implementation that uses a static username and password.
Methods
JWTAuth.Create
: Creates a JWT token with the provided metadata.
JWTAuth.Extract
: Extracts metadata from the given JWT token.
StaticBasicAuth.Validate
: Validates the given username and password with it's static values.
Testing
make test
Documentation
¶
BasicAuth defines an interface for interaction with the Basic Auth protocol.
type JWTAuth struct {
Secret string
}
JWTAuth handles encoding and decoding JWT tokens.
Create creates a JWT token for a given user ID.
Extract will take a raw token and extract the value.
ExtractFromHeader returns the encoded object from the header.
type StaticBasicAuth struct {
Username string
Password string
}
StaticBasicAuth takes a static username/password combo.
Validate that the given username and password are correct.
Source Files
¶
Directories
¶
Click to show internal directories.
Click to hide internal directories.