Documentation
¶
Overview ¶
Package gateway implments various auth logic used across noebs services
Index ¶
- Variables
- func GenerateAPIKey() (string, error)
- func GenerateSecretKey(n int) ([]byte, error)
- func Instrumentation() gin.HandlerFunc
- func OptionsMiddleware(c *gin.Context)
- type Cards
- type ErrorResponse
- type GetRedisClient
- type JWT
- type JWTAuth
- type Service
- type TokenClaims
- type UserLogin
- type UserModel
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrCreateDbRow = errors.New("unable to create a new db row/column")
)
Functions ¶
func GenerateAPIKey ¶
func GenerateSecretKey ¶
GenerateSecretKey generates secret key for jwt signing
func Instrumentation ¶
func Instrumentation() gin.HandlerFunc
Types ¶
type ErrorResponse ¶
type GetRedisClient ¶
type JWTAuth ¶
type JWTAuth struct {
Key []byte
}
JWTAuth provides an encapsulation for jwt auth
func (*JWTAuth) AuthMiddleware ¶
func (a *JWTAuth) AuthMiddleware() gin.HandlerFunc
AuthMiddleware is a JWT authorization middleware. It is used in our consumer services to get a username from the payload (maybe change it to mobile number at somepoint)
func (*JWTAuth) GenerateJWT ¶
GenerateJWT generates a JWT standard token with default values hardcoded. FIXME
func (*JWTAuth) GenerateJWTWithClaim ¶
func (j *JWTAuth) GenerateJWTWithClaim(username string, tk TokenClaims) (string, error)
GenerateJWTWithClaim generates a JWT standard token with default values hardcoded. FIXME
type TokenClaims ¶
type TokenClaims struct {
Username string `json:"username"`
jwt.StandardClaims
}
TokenClaims noebs standard claim
type UserModel ¶
type UserModel struct {
gorm.Model
Username string `binding:"min=3" json:"username"`
Password string `binding:"required,min=8,max=20" json:"password"`
Fullname string `json:"fullname"`
Birthday string `json:"birthday"`
Mobile string `json:"mobile" binding:"required,len=10" gorm:"unique_index"`
Email string `json:"email"`
Password2 string `binding:"required,eqfield=Password,min=8,max=20" json:"password2"`
Card []Cards
// contains filtered or unexported fields
}
func (*UserModel) HashPassword ¶
func (*UserModel) SanitizeName ¶
func (u *UserModel) SanitizeName()
Click to show internal directories.
Click to hide internal directories.