Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateToken ¶
CreateLToken returns token use jwt with custom claims
func Md5Encrypt ¶
Md5Encrypt returns secret key use Mk5 encryption with username and password
Types ¶
type CustomClaims ¶
type CustomClaims struct { jwt.StandardClaims UserName string `json:"username"` Password string `json:"password"` }
CustomClaims represents jwt custom claims param need username and password and some standard claims
func ParseToken ¶
func ParseToken(tokenString string, user models.User) (*CustomClaims, error)
ParseToken returns jwt claims by token get secret key use Md5Encrypt method with username and password then jwt parse token by secret key
func (*CustomClaims) Valid ¶
func (*CustomClaims) Valid() error
Valid rewrites jwt.Claims valid method return nil
type UserAuthentication ¶
type UserAuthentication struct {
// contains filtered or unexported fields
}
UserAuthentication represents authentication param
func NewUserAuthentication ¶
func NewUserAuthentication(user models.User) *UserAuthentication
NewUserAuthentication creates authentication api instance
func (*UserAuthentication) ValidateMiddleware ¶
func (u *UserAuthentication) ValidateMiddleware(next http.Handler) http.Handler
ValidateTokenMiddleware creates middleware for user permissions validation by request header Authorization if not authorization throw error else perform the next action