Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware(secret string) gin.HandlerFunc
AuthMiddleware is a middleware function for Gin that authenticates requests using a JWT token. It checks for a valid "Authorization" header in the Bearer format. If the token is valid, the middleware extracts the user ID from the token's claims and stores it in the request context.
func GenerateToken ¶
GenerateToken creates a signed JWT token for a given user ID with a specified lifetime. The token includes standard claims, such as expiration time, issue time, user ID (as the subject), and a unique token ID. Returns the signed token string or an error if signing fails.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.