Documentation
¶
Index ¶
- Variables
- func CookieDecryptJwt(r *http.Request) (string, string, error)
- func CookieDelete(w http.ResponseWriter, name string)
- func CookieRefreshOrDelete(w http.ResponseWriter, r *http.Request) (string, string, bool)
- func CookieSetTokens(w http.ResponseWriter, a string, r string)
- func HttpRedirect(w http.ResponseWriter, r *http.Request, ...) bool
- func InitJwt(params PasswordJwtParams) error
- func JwtConfig() *configJwt
- func MiddlewareAuth(next http.Handler) http.Handler
- func NewTokenPair(j JwtParams) (string, string, string, error)
- func ParseOrRefreshToken(a string, r string) (string, string, error)
- func RejectSubroute(path string) alice.Constructor
- type CustomClaims
- type JwtParams
- type Locations
- type PasswordJwtParams
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrHashPassword = errors.New("password hashing failed") ErrDbInsertUser = errors.New("failed to insert user") ErrParsingJwt = errors.New("failed to parse JWT") ErrJwtMethodBad = errors.New("invalid JWT signing method") ErrJwtInvalid = errors.New("JWT not found in database") ErrJwtInvalidInDb = errors.New("JWT marked as invalid in database") ErrDbInsertToken = errors.New("failed to insert token") ErrJwtGoodAccBadRef = errors.New("access token was good but refresh was bad") ErrDbSelectUserSubject = errors.New("failed to select user subject") ErrUuidFailed = errors.New("failed to generate UUID") ErrImpossible = errors.New("this should be an impossible state") )
System errors
Functions ¶
func CookieDelete ¶
func CookieDelete(w http.ResponseWriter, name string)
func CookieRefreshOrDelete ¶
func CookieSetTokens ¶
func CookieSetTokens(w http.ResponseWriter, a string, r string)
func HttpRedirect ¶
func InitJwt ¶
func InitJwt(params PasswordJwtParams) error
func MiddlewareAuth ¶
This middleware handles the following cases:
- If User's access and refresh are both valid, insert AuthContext struct into request context
- If User's access is invalid and refresh is valid, refresh JWTs
- If User's access and refresh are both invalid, delete JWTs
func RejectSubroute ¶
func RejectSubroute(path string) alice.Constructor
This returned an alice.Constructor instead of being an alice.Constructor because it requires an argument (path string).
Types ¶
type CustomClaims ¶
type CustomClaims struct {
jwt.RegisteredClaims
JwtType string `json:"jwt_type"`
Family string `json:"family"`
UserName string `json:"user"`
}
func ParseToken ¶
func ParseToken(t string) (CustomClaims, error)
type PasswordJwtParams ¶
Click to show internal directories.
Click to hide internal directories.