Documentation
¶
Index ¶
- func ComparePassword(hashedPassword, password []byte) bool
- func CreatePassword(pw string) []byte
- func GenerateApplicationToken() string
- func GenerateClientToken() string
- func GetTokenID(ctx *gin.Context) string
- func GetUserID(ctx *gin.Context) uint
- func RegisterAuthentication(ctx *gin.Context, user *model.User, userID uint, tokenID string)
- type Auth
- type Database
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComparePassword ¶
ComparePassword compares a hashed password with its possible plaintext equivalent.
func CreatePassword ¶
CreatePassword returns a hashed version of the given password.
func GenerateApplicationToken ¶
func GenerateApplicationToken() string
GenerateApplicationToken generates an application token.
func GenerateClientToken ¶
func GenerateClientToken() string
GenerateClientToken generates a client token.
Types ¶
type Auth ¶
type Auth struct {
DB Database
}
Auth is the provider for authentication middleware
func (*Auth) RequireAdmin ¶
func (a *Auth) RequireAdmin() gin.HandlerFunc
RequireAdmin returns a gin middleware which requires a client token or basic authentication header to be supplied with the request. Also the authenticated user must be an administrator.
func (*Auth) RequireApplicationToken ¶
func (a *Auth) RequireApplicationToken() gin.HandlerFunc
RequireApplicationToken returns a gin middleware which requires an application token to be supplied with the request.
func (*Auth) RequireClient ¶
func (a *Auth) RequireClient() gin.HandlerFunc
RequireClient returns a gin middleware which requires a client token or basic authentication header to be supplied with the request.