Documentation ¶
Index ¶
- Constants
- Variables
- func CreateSession(email string, userAgent string, clientIP string) (*models.Session, error)
- func GetCurrentUser() string
- func Login(ctx *gin.Context)
- func RefreshSession(ctx *gin.Context)
- func SetCurrentUser(username string)
- func SignUp(ctx *gin.Context)
- type JWTMaker
- type PasetoMaker
- type Payload
- type TokenMaker
Constants ¶
View Source
const SessionTokenAgeInMinutes = 60
View Source
const TokenAgeInMinutes = 5
Variables ¶
View Source
var ( ErrInvalidToken = errors.New("token is invalid") ErrExpiredToken = errors.New("token is expired") )
Functions ¶
func CreateSession ¶
func GetCurrentUser ¶
func GetCurrentUser() string
func RefreshSession ¶
func SetCurrentUser ¶
func SetCurrentUser(username string)
Types ¶
type PasetoMaker ¶
type PasetoMaker struct {
// contains filtered or unexported fields
}
func (*PasetoMaker) CreateToken ¶
func (*PasetoMaker) VerifyToken ¶
func (pasetoMaker *PasetoMaker) VerifyToken(token string) (*Payload, error)
type Payload ¶
type TokenMaker ¶
type TokenMaker interface { CreateToken(username string, duration time.Duration) (string, error) VerifyToken(token string) (*Payload, error) }
func NewJWTMaker ¶
func NewJWTMaker(secretKey string) (TokenMaker, error)
func NewPasetoMaker ¶
func NewPasetoMaker() (TokenMaker, error)
Click to show internal directories.
Click to hide internal directories.