Documentation ¶
Index ¶
- func AuthenticateWithDatabase(authD ValidationPair, userDB rdb.Database) (username string, token string, err error)
- func CreateOrUpdateAuthSecretInFile()
- func ExtractToken(r *http.Request) (token string, ok bool)
- func GenerateRandomSecureString(n int) (string, error)
- func GenerateToken(username string) (string, error)
- func GenerateTokenValidationMiddlewareFunc(userDB rdb.Database) func(http.Handler) http.Handler
- func LoadSecretsToEnv()
- func ValidateUserToken(r *http.Request, userDB rdb.Database) (username string, token string, err error)
- func ValidateUsername(username string) string
- func VerifyTokenFormatAndDecode(r *http.Request) (jwt.Token, error)
- type ValidationPair
- type ValidationResponseKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthenticateWithDatabase ¶
func AuthenticateWithDatabase(authD ValidationPair, userDB rdb.Database) (username string, token string, err error)
Verify that claimed authentication details are stored in database, if so return stored username, token, and ok=true
func CreateOrUpdateAuthSecretInFile ¶
func CreateOrUpdateAuthSecretInFile()
Creates or updates the GG_ACCESS_SECRET value in secrets.env
func ExtractToken ¶
Extract Token from request header
func GenerateRandomSecureString ¶
Generate random string of n characters
func GenerateToken ¶
Generates a new token based on username and gg_access_secret
func GenerateTokenValidationMiddlewareFunc ¶
Generates a middleware function for handling token validation on secure routes
func ValidateUserToken ¶
func ValidateUserToken(r *http.Request, userDB rdb.Database) (username string, token string, err error)
Extract token metadata and check claimed token against database
func ValidateUsername ¶
validate that username meets spec
Types ¶
type ValidationPair ¶
Defines struct for passing around Token-Username pairs
func ExtractTokenMetadata ¶
func ExtractTokenMetadata(r *http.Request) (ValidationPair, error)
Verify token format and decode, then extract metadata (e.g. username) and return
type ValidationResponseKey ¶
type ValidationResponseKey int
enum for ValidationContext
const (
ValidationContext ValidationResponseKey = iota
)