Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdminAuthentificator ¶
AdminAuthentificator is a middle which check if the user is administrator (role=1)
func RandString ¶
RandString generate a random string with the default charset ([A-Za-z])
func RandStringWithCharset ¶
RandStringWithCharset generate a random string with a specific charset
Types ¶
type Auth ¶
Auth refers to a generic interface which must be implemented by every authentication backend
type DatabaseAuth ¶
DatabaseAuth is a basic Auth implementation requiring the tuple admin/admin to authenticate successfully
func NewDatabaseAuth ¶
func NewDatabaseAuth(DBClient *sqlx.DB) *DatabaseAuth
NewDatabaseAuth returns a pointer of DatabaseAuth
func (*DatabaseAuth) Authenticate ¶
Get search and returns an User from the repository by its id
type JwtToken ¶
type JwtToken struct {
Token string `json:"token"`
}
JwtToken wrap the json web token string
type Middleware ¶
Middleware is an interface for standard http middleware
type MiddlewareJWT ¶
type MiddlewareJWT struct { Auth Auth Handler func(h http.Handler) http.Handler // contains filtered or unexported fields }
MiddlewareJWT is an implementation of Middleware interface, which provides a specific security handler based on JWT (JSON Web Token)
func NewMiddlewareJWT ¶
func NewMiddlewareJWT(jwtSigningKey []byte, auth Auth) *MiddlewareJWT
NewMiddlewareJWT initialize a new instance of MiddlewareJWT and returns a pointer of it
func (*MiddlewareJWT) GetToken ¶
func (middleware *MiddlewareJWT) GetToken() http.HandlerFunc
GetToken returns a http.Handler to authenticate and get a JWT