Documentation
¶
Index ¶
- Constants
- type JWT
- func (j *JWT) GenerateToken(email string) (string, error)
- func (j *JWT) GetCookie(r *http.Request) (*http.Cookie, error)
- func (j *JWT) RemoveCookie(w http.ResponseWriter, secure bool, domain ...string)
- func (j *JWT) SetCookie(w http.ResponseWriter, token string, secure bool, domain ...string)
- func (j *JWT) ValidateJWT(tokenString string) (string, error)
Constants ¶
View Source
const ( Email = "email" Exp = "exp" Alg = "alg" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JWT ¶
type JWT struct {
CookieName string // Name of the cookie to store the JWT
Secret string // Secret key used to sign the JWT
TokenTTL time.Duration // Token time-to-live duration
}
JWT handles JWT token creation, validation, and cookie management.
func (*JWT) GenerateToken ¶
GenerateToken creates a signed JWT token containing the user's email and expiration.
func (*JWT) RemoveCookie ¶ added in v1.1.5
func (j *JWT) RemoveCookie(w http.ResponseWriter, secure bool, domain ...string)
RemoveCookie removes the JWT cookie by setting an expired Set-Cookie header.
Click to show internal directories.
Click to hide internal directories.