Documentation ¶
Index ¶
- func ContextWithClaims(ctx context.Context, c *Claims) context.Context
- func CreateToken(ctx context.Context, secret string, u *model.User) (string, error)
- func Init(_ *config.Config, store Store) http.HandlerFunc
- func Login(cfg *config.Config, store Store) http.HandlerFunc
- func Root(cfg *config.Config, store Store) http.HandlerFunc
- func Router(cfg *config.Config, store Store) func(chi.Router)
- func WithClaims(cfg *config.Config, required, onlyAdmin bool) func(http.Handler) http.Handler
- type Claims
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithClaims ¶
ContextWithClaims store claims in context
func CreateToken ¶
CreateToken from user and sign it
func Login ¶
func Login(cfg *config.Config, store Store) http.HandlerFunc
Login with email/password credentials
func Root ¶
func Root(cfg *config.Config, store Store) http.HandlerFunc
Root check login availability and update jwt if present valid
Types ¶
type Claims ¶
type Claims struct { jwt.StandardClaims UserID bson.ObjectId `json:"userId"` Email string `json:"email"` IsAdmin bool `json:"isAdmin"` }
Claims of authorization token
type Store ¶
type Store interface { GetUserCount(context.Context) (int, error) GetUserByID(context.Context, bson.ObjectId) (*model.User, error) GetUserByEmail(context.Context, string) (*model.User, error) CreateUser(context.Context, *model.User) error }
Store is a interface of store required in package auth
Click to show internal directories.
Click to hide internal directories.