Documentation ¶
Index ¶
- Constants
- func ExtractFromCookie(r *http.Request) (string, error)
- func GetJWTMW() *jwtMW.JWTMiddleware
- func GetKeyGetter(key string) jwt.Keyfunc
- func OptionalAuth(f func(w http.ResponseWriter, r *http.Request)) http.Handler
- func RequireAuth(f func(http.ResponseWriter, *http.Request)) http.Handler
- func ValidateCSRF(res *http.Request) error
- func ValidateJwt(bearer, key string) (jwt.MapClaims, error)
- type AuthMWHandler
- type InvalidTokenError
- type KeyJWTClaims
- type KeyUserId
- type Logger
- type UnauthorizedError
- type UserClaims
Constants ¶
View Source
const CSRFCookieName = "xcsrf"
View Source
const IdentityCookieKey = "RYL_Session"
Variables ¶
This section is empty.
Functions ¶
func ExtractFromCookie ¶
ExtractFromCookie extracts a jwt from the session Cookie
func GetJWTMW ¶
func GetJWTMW() *jwtMW.JWTMiddleware
func GetKeyGetter ¶
func GetKeyGetter(key string) jwt.Keyfunc
func OptionalAuth ¶
func RequireAuth ¶
func ValidateCSRF ¶
ValidateCSRF compares the two csrf tokens for a double submit cookie csrf protection.
func ValidateJwt ¶
Types ¶
type AuthMWHandler ¶
type AuthMWHandler struct {
// contains filtered or unexported fields
}
func NewAuthMWHandler ¶
func NewAuthMWHandler(logger *zap.SugaredLogger, key string) *AuthMWHandler
NewAuthMWHandler creates a new AuthMWR Handler
func (*AuthMWHandler) AuthMWO ¶
func (h *AuthMWHandler) AuthMWO(next http.Handler) http.Handler
AuthMWO is the auth middleware for a optional authenticated request.
func (*AuthMWHandler) AuthMWR ¶
func (h *AuthMWHandler) AuthMWR(next http.Handler) http.Handler
AuthMWR is the auth middleware for a required authenticated request.
func (*AuthMWHandler) RequireAuthTokenHandler ¶
func (h *AuthMWHandler) RequireAuthTokenHandler(rw http.ResponseWriter, r *http.Request) (jwt.MapClaims, error)
type InvalidTokenError ¶
type InvalidTokenError struct {
Err error
}
func (InvalidTokenError) Error ¶
func (err InvalidTokenError) Error() string
type KeyJWTClaims ¶
type KeyJWTClaims struct{}
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a Middleware for logging using the zap logger
func (*Logger) ServeHTTP ¶
func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ServeHTTP is the middleware handler for the logging middleware.
type UnauthorizedError ¶
type UnauthorizedError struct {
}func (UnauthorizedError) Error ¶
func (err UnauthorizedError) Error() string
type UserClaims ¶
func FromUserTokenContext ¶
func FromUserTokenContext(user interface{}) *UserClaims
FromUserTokenContext creates a claims list of a user from a given jwt token given by the mw. We trust the user parameter to be a valid jwt token with the claims username and id.
Click to show internal directories.
Click to hide internal directories.