Documentation ¶
Index ¶
- func AddUserIDHeader(r *http.Request, claim *Claim)
- func BlacklistToken(token string)
- func CleanBlacklist(cleanInterval time.Duration)
- func GenerateJWTToken(username string) (string, time.Time, error)
- func GetAuthToken(r *http.Request) (string, error)
- func GetUserIDFromRequest(r *http.Request) (string, error)
- func IsBlacklisted(token string) bool
- func RemoveUserIDHeader(r *http.Request)
- func SetAuthCookie(w http.ResponseWriter, tokenString string, expires time.Time)
- type Claim
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUserIDHeader ¶
AddUserIDHeader adds a header to the request that represents the user ID
func BlacklistToken ¶
func BlacklistToken(token string)
BlacklistToken blacklists a token so that it cannot be used anymore
func CleanBlacklist ¶
CleanBlacklist starts a go routine that periodically clears the black list
func GenerateJWTToken ¶
GenerateJWTToken generates a JWT token for the provided username
func GetAuthToken ¶
GetAuthToken extracts the auth token from a request
func GetUserIDFromRequest ¶
GetUserIDFromRequest returns the user ID from the request
func IsBlacklisted ¶
IsBlacklisted checks if a token is blacklisted
func RemoveUserIDHeader ¶
RemoveUserIDHeader removes the header that contains the user ID
func SetAuthCookie ¶
func SetAuthCookie(w http.ResponseWriter, tokenString string, expires time.Time)
SetAuthCookie add an auth cookie to the response writer
Types ¶
type Claim ¶
type Claim struct { Username string `json:"username"` jwt.StandardClaims }
Claim uses the standard JWT Claim to create a custom claim
Click to show internal directories.
Click to hide internal directories.