authhandler

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Handler
	ErrInternal         = httperror.NewInternalHttpError(errors.New(""), "")
	ErrRequestBodyEmpty = httperror.NewExternalHttpError(errors.New("request body empty"), http.StatusBadRequest)
	ErrBadJsonBody      = httperror.NewExternalHttpError(errors.New("bad request json body"), http.StatusBadRequest)
	ErrFailedReadBody   = httperror.NewInternalHttpError(errors.New("failed read request body"), "") // Use WithDesc() and WithFuncName() to write response

	// Middleware
	ErrGetJWTClaims = httperror.NewInternalHttpError(errors.New("failed get jwt claims"), "AuthMiddleware.WithAuth")

	ErrUserNotAuthorized   = httperror.NewExternalHttpError(errors.New("user not authorized"), http.StatusUnauthorized)
	ErrBadJWTToken         = httperror.NewExternalHttpError(errors.New("bad jwt token"), http.StatusBadRequest)
	ErrJwtSignatureInvalid = httperror.NewExternalHttpError(errors.New("jwt signature is invalid"), http.StatusBadRequest)

	ErrAuthorizationExpired = httperror.NewExternalHttpError(errors.New("authorization expired"), http.StatusUnauthorized)
)

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewAuthHandler

func NewAuthHandler(cfg authconfig.AuthHandlerConfig) Handler

func (Handler) Login

func (handler Handler) Login(w http.ResponseWriter, r *http.Request)

func (Handler) Register

func (handler Handler) Register(w http.ResponseWriter, r *http.Request)

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

func (Middleware) WithAuth

func (mid Middleware) WithAuth(handler http.HandlerFunc) http.HandlerFunc

Extract username from jwt and put him in request context

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL