Documentation
¶
Overview ¶
Package ginutils provides helpers for extracting and decoding JWTs from gin.Context.
Index ¶
- func ExtractCookieJwtClaimsFromContext(c *gin.Context, secretKey []byte) (map[string]interface{}, error)
- func ExtractCookieJwtClaimsFromContextInto(c *gin.Context, secretKey []byte, out interface{}) error
- func ExtractJwtClaimsFromContext(c *gin.Context, secretKey []byte) (map[string]interface{}, error)
- func ExtractJwtClaimsFromContextInto(c *gin.Context, secretKey []byte, out interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractCookieJwtClaimsFromContext ¶
func ExtractCookieJwtClaimsFromContext(c *gin.Context, secretKey []byte) (map[string]interface{}, error)
ExtractCookieJwtClaimsFromContext retrieves JWT claims from a cookie named "cxjwt" in the provided Gin context. The JWT is validated and parsed using the provided secret key. It returns the claims as a map if successful, or an error if the process fails.
func ExtractCookieJwtClaimsFromContextInto ¶
ExtractCookieJwtClaimsFromContextInto retrieves a JWT from the "cxjwt" cookie in the provided gin.Context, validates it using the secretKey, and unmarshals the claims into the provided output struct. Returns an error if the cookie is not present or if validation/unmarshalling fails.
func ExtractJwtClaimsFromContext ¶
ExtractJwtClaimsFromContext extracts JWT claims from the request context by parsing the Authorization header and decoding the token using the provided secret key. Returns a map of claims or an error if token parsing fails.
func ExtractJwtClaimsFromContextInto ¶
ExtractJwtClaimsFromContextInto extracts JWT claims from the Authorization header of the given gin.Context, validates the token using the provided secretKey, and decodes the claims into the out parameter. An error is returned if the process fails at any step.
Types ¶
This section is empty.