Thanks to visit codestin.com
Credit goes to pkg.go.dev

ginutils

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ginutils provides helpers for extracting and decoding JWTs from gin.Context.

Index

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

func ExtractCookieJwtClaimsFromContextInto(c *gin.Context, secretKey []byte, out interface{}) error

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

func ExtractJwtClaimsFromContext(c *gin.Context, secretKey []byte) (map[string]interface{}, error)

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

func ExtractJwtClaimsFromContextInto(c *gin.Context, secretKey []byte, out interface{}) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL