Documentation ¶
Index ¶
- Constants
- Variables
- type AccessTokenRawPayload
- type JWT
- type JwtInstance
- type JwtPayload
- type Password
- type RawPayload
- type RefreshTokenRawPayload
- type Responses
- func (r *Responses) BadRequest(ctx *fiber.Ctx, message string) error
- func (r *Responses) Custom(ctx *fiber.Ctx, status int, message string, data *fiber.Map) error
- func (r *Responses) Error(ctx *fiber.Ctx, status int, message string) error
- func (r *Responses) Forbidden(ctx *fiber.Ctx) error
- func (r *Responses) GatewayTimeout(ctx *fiber.Ctx) error
- func (r *Responses) InternalServerError(ctx *fiber.Ctx) error
- func (r *Responses) NotFound(ctx *fiber.Ctx) error
- func (r *Responses) ServiceUnavailable(ctx *fiber.Ctx) error
- func (r *Responses) Success(ctx *fiber.Ctx, data *fiber.Map) error
- func (r *Responses) Unauthorized(ctx *fiber.Ctx, message string) error
- type Tokens
Constants ¶
View Source
const ( RefreshTokenDuration = 24 * 2 // 2 days AccessTokenDuration = 6 // 6 hours )
Variables ¶
View Source
var ResponsesModel = Responses{}
Functions ¶
This section is empty.
Types ¶
type AccessTokenRawPayload ¶
type AccessTokenRawPayload struct { ID primitive.ObjectID `json:"id"` Username string `json:"username"` Scopes []string `json:"scopes"` }
AccessTokenRawPayload create a custom type for the claims
type JWT ¶
type JWT[T RawPayload] struct{}
JWT create a generic JWT struct
func (*JWT[T]) GenerateToken ¶
GenerateToken generate the payload for the jwt
func (*JWT[T]) GetInstance ¶
func (j *JWT[T]) GetInstance() *JwtInstance
GetInstance get the instance of the JWT
func (*JWT[T]) ValidateToken ¶
func (j *JWT[T]) ValidateToken(tokenString string) (*JwtPayload[T], error)
ValidateToken validate the token
type JwtInstance ¶
type JwtInstance struct {
// contains filtered or unexported fields
}
type JwtPayload ¶
type JwtPayload[T RawPayload] struct { Payload *T `json:"payload"` jwt.RegisteredClaims }
type RawPayload ¶
type RawPayload interface { AccessTokenRawPayload | RefreshTokenRawPayload }
type RefreshTokenRawPayload ¶
type RefreshTokenRawPayload struct {
AccessToken string `json:"access_token"`
}
RefreshTokenRawPayload create a custom type for the claims
type Responses ¶
type Responses struct { Status int `json:"status"` Message string `json:"message"` Data *fiber.Map `json:"data"` Timestamp time.Time `json:"timestamp"` }
func (*Responses) BadRequest ¶
func (*Responses) GatewayTimeout ¶
func (*Responses) InternalServerError ¶
func (*Responses) ServiceUnavailable ¶
func (*Responses) Unauthorized ¶
Click to show internal directories.
Click to hide internal directories.