Documentation
¶
Index ¶
- Variables
- func DecodeAccessToken(token string, db *gorm.DB) (*models.User, *string)
- func DecodeRefreshToken(token string) bool
- func GenerateAccessToken(userId uuid.UUID) string
- func GenerateRefreshToken() string
- func GetUser(token string, db *gorm.DB) (*models.User, *string)
- func RemoveAuthCookie(c *fiber.Ctx, cookieType CookieType)
- func SetAuthCookie(c *fiber.Ctx, cookieType CookieType, token string)
- func ValidateAndFetchGoogleUser(ctx context.Context, oauthConfig *oauth2.Config, db *gorm.DB, code string) (*models.User, error)
- type AccessTokenPayload
- type CookieType
- type GoogleUserInfo
- type Middleware
- type RefreshTokenPayload
Constants ¶
This section is empty.
Variables ¶
View Source
var SECRETKEY = []byte(cfg.SecretKey)
Functions ¶
func DecodeRefreshToken ¶
func GenerateAccessToken ¶
func GenerateRefreshToken ¶
func GenerateRefreshToken() string
func RemoveAuthCookie ¶
func RemoveAuthCookie(c *fiber.Ctx, cookieType CookieType)
func SetAuthCookie ¶
func SetAuthCookie(c *fiber.Ctx, cookieType CookieType, token string)
Types ¶
type AccessTokenPayload ¶
type AccessTokenPayload struct {
UserId uuid.UUID `json:"user_id"`
jwt.RegisteredClaims
}
type CookieType ¶
type CookieType string
const ( AccessToken CookieType = "accessToken" RefreshToken CookieType = "refreshToken" )
type GoogleUserInfo ¶
type GoogleUserInfo struct {
Email string `json:"email"`
Name string `json:"name"`
GoogleID string `json:"id"`
GivenName string `json:"given_name"`
Family string `json:"family_name"`
Avatar string `json:"picture"`
IsEmailVerified bool `json:"verified_email"`
}
GoogleUserInfo represents the structure of user data from Google
type Middleware ¶
func (Middleware) AuthMiddleware ¶
func (mid Middleware) AuthMiddleware(c *fiber.Ctx) error
func (Middleware) RateLimiter ¶
func (mid Middleware) RateLimiter(c *fiber.Ctx) error
type RefreshTokenPayload ¶
type RefreshTokenPayload struct {
Data string `json:"data"`
jwt.RegisteredClaims
}
Click to show internal directories.
Click to hide internal directories.