Documentation
¶
Index ¶
- func DisableAuthorization()
- func EnableAuthorization()
- func EncryptPassword(password string) ([]byte, error)
- func GenerateJWT(model interface{}) (s string, e error)
- func GenerateJWTAndSetExpiredTime(model interface{}, hours int64, minutes int64, seconds int64) (s string, e error)
- func GetJWTFromEchoHeader(c echo.Context) (token string, err error)
- func GetJWTFromGinHeader(c *gin.Context) (token string, err error)
- func GetJWTFromHeader(header string) (token string, err error)
- func GetJWTSecretCode() []byte
- func GetStringJWTSecretCode() string
- func IsUseAuthorization() bool
- func SetExpiredTime(hour int64, minute int64, second int64)
- func SetHMACSigningMethod(s SigningHMAC)
- func SetJWTSecretCode(secretCode string)
- func VerifyAndBinding(model interface{}, t string) (bool, error)
- func VerifyAndBindingEchoHeader(model interface{}, c echo.Context) (token string, isValid bool, err error)
- func VerifyAndBindingGinHeader(model interface{}, c *gin.Context) (token string, isValid bool, err error)
- func VerifyAndBindingJWT(model interface{}, token string) (bool, error)
- func VerifyEchoHeader(c echo.Context) (string, bool, error)
- func VerifyGinHeader(c *gin.Context) (string, bool, error)
- func VerifyJWT(token string) (bool, error)
- func VerifyPassword(encryptedPassword string, password string) (bool, error)
- type Authorization
- func (auth Authorization) GenerateJWT() (string, error)
- func (auth Authorization) GenerateJWTAndSetExpiredTime(hour int64, minute int64, seconds int64) (string, error)
- func (auth Authorization) GetPasswordEncryption() ([]byte, error)
- func (auth Authorization) GetStringPasswordEncryption() (string, error)
- func (auth Authorization) VerifyEncryptedPassword(password string) (bool, error)
- func (auth Authorization) VerifyJWT(token string) (bool, error)
- func (auth Authorization) VerifyPassword(password string) (bool, error)
- type CustomClaims
- type SigningHMAC
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableAuthorization ¶
func DisableAuthorization()
DisableAuthorization is to Disable the authorization
func EnableAuthorization ¶
func EnableAuthorization()
EnableAuthorization is to enable authorization
func EncryptPassword ¶
EncryptPassword is the function provided to encrypt any password safely
func GenerateJWT ¶
GenerateJWT is the function for generate JWT token
func GenerateJWTAndSetExpiredTime ¶
func GenerateJWTAndSetExpiredTime(model interface{}, hours int64, minutes int64, seconds int64) (s string, e error)
GenerateJWTAndSetExpiredTime will generate JWT token alongside with custom expired time
func GetJWTFromEchoHeader ¶
GetJWTFromEchoHeader get JWT from header which provided by echo web framework
func GetJWTFromGinHeader ¶
GetJWTFromGinHeader is to get JWT from header which provided by gin web framework
func GetJWTFromHeader ¶
GetJWTFromHeader get JWT from header which provided by any of web framework, but with rules JWT "token"
func GetJWTSecretCode ¶
func GetJWTSecretCode() []byte
GetJWTSecretCode get JWT secret code as a byte
func GetStringJWTSecretCode ¶
func GetStringJWTSecretCode() string
GetStringJWTSecretCode is to get JWT secret code as a string
func IsUseAuthorization ¶
func IsUseAuthorization() bool
IsUseAuthorization is to get status whether use authorization or not
func SetExpiredTime ¶
SetExpiredTime is to set expired time for JWT session
func SetHMACSigningMethod ¶ added in v1.2.0
func SetHMACSigningMethod(s SigningHMAC)
SetHMACSigningMethod is to set signing method globally
func SetJWTSecretCode ¶
func SetJWTSecretCode(secretCode string)
SetJWTSecretCode is to set JWT secret code globally
func VerifyAndBinding ¶
VerifyAndBinding is to verify and binding any given token
func VerifyAndBindingEchoHeader ¶
func VerifyAndBindingEchoHeader(model interface{}, c echo.Context) (token string, isValid bool, err error)
VerifyAndBindingEchoHeader verify and binding the jwt model
func VerifyAndBindingGinHeader ¶
func VerifyAndBindingGinHeader(model interface{}, c *gin.Context) (token string, isValid bool, err error)
VerifyAndBindingGinHeader is to verify and binding the jwt model
func VerifyAndBindingJWT ¶
VerifyAndBindingJWT is the easy way to verify and binding JWT token at the same time
func VerifyEchoHeader ¶
VerifyEchoHeader only verify echo header
func VerifyGinHeader ¶
VerifyGinHeader is the function that only verify gin header
Types ¶
type Authorization ¶
type Authorization struct { Username string `form:"username" json:"username" xml:"username" binding:"required"` Password string `form:"password" json:"password" xml:"password" binding:"required"` }
Authorization is the default authorization model
func (Authorization) GenerateJWT ¶
func (auth Authorization) GenerateJWT() (string, error)
GenerateJWT is to generate JWT token by authorization model
func (Authorization) GenerateJWTAndSetExpiredTime ¶
func (auth Authorization) GenerateJWTAndSetExpiredTime(hour int64, minute int64, seconds int64) (string, error)
GenerateJWTAndSetExpiredTime generate JWT token by authorization model also set the expired time manually
func (Authorization) GetPasswordEncryption ¶
func (auth Authorization) GetPasswordEncryption() ([]byte, error)
GetPasswordEncryption is to create password encryption using bcrypt
func (Authorization) GetStringPasswordEncryption ¶
func (auth Authorization) GetStringPasswordEncryption() (string, error)
GetStringPasswordEncryption is to create password encryption using bcrypt and string as the result
func (Authorization) VerifyEncryptedPassword ¶ added in v1.3.0
func (auth Authorization) VerifyEncryptedPassword(password string) (bool, error)
VerifyEncryptedPassword is the fastest way to verify encrypted password stored in database
func (Authorization) VerifyJWT ¶
func (auth Authorization) VerifyJWT(token string) (bool, error)
VerifyJWT is the simply way to check authorization
func (Authorization) VerifyPassword ¶
func (auth Authorization) VerifyPassword(password string) (bool, error)
VerifyPassword is the fastest way to verify password
type CustomClaims ¶
type CustomClaims struct { Object interface{} jwt.StandardClaims }
CustomClaims is the model provided by this library
type SigningHMAC ¶ added in v1.2.0
type SigningHMAC struct {
Method *jwt.SigningMethodHMAC
}
SigningHMAC is type of signing that can be used for signing and validation JWT
func GetHMACSigningMethod ¶ added in v1.2.0
func GetHMACSigningMethod() SigningHMAC
GetHMACSigningMethod is to get signing method