defaultmux

package
v0.0.0-...-923a007 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	Username string `json:"login"`
	Password string `json:"password"`
}

Credentials is a struct to read the username and password from the request body

type Router

type Router struct {
	*http.ServeMux
	// contains filtered or unexported fields
}

Router ...

func New

func New(stor storage.UserStorage, jwtSecretKey string, slog *zap.SugaredLogger) *Router

New creates a new router

func (*Router) AuthMiddleware

func (rt *Router) AuthMiddleware(next http.Handler) http.Handler

AuthMiddleware implements password check middleware

func (*Router) Info

func (rt *Router) Info(w http.ResponseWriter, r *http.Request)

Info checks token and sends username as response

func (*Router) Login

func (rt *Router) Login(w http.ResponseWriter, r *http.Request)

Login handle func produces JWT and refresh token

func (*Router) Logout

func (rt *Router) Logout(w http.ResponseWriter, r *http.Request)

Logout clears users tokens

func (*Router) PostmanAuthMW

func (rt *Router) PostmanAuthMW(next http.Handler) http.Handler

PostmanAuthMW ...

func (*Router) PostmanLogin

func (rt *Router) PostmanLogin(w http.ResponseWriter, r *http.Request)

PostmanLogin handle func produces JWT and refresh token

func (*Router) PostmanLogout

func (rt *Router) PostmanLogout(w http.ResponseWriter, r *http.Request)

PostmanLogout clears users tokens

func (*Router) ProfilerOff

func (rt *Router) ProfilerOff(w http.ResponseWriter, r *http.Request)

ProfilerOff makes it impossible to use /debug/pprof/* endpoints

func (*Router) ProfilerOn

func (rt *Router) ProfilerOn(w http.ResponseWriter, r *http.Request)

ProfilerOn makes it possible to use /debug/pprof/* endpoints to get application profile

func (*Router) TokenMW

func (rt *Router) TokenMW(next http.Handler) http.Handler

TokenMW ...

type TokenPair

type TokenPair struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

TokenPair represents JWT tokens given to authenticated user

Jump to

Keyboard shortcuts

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