context

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingToken              = errors.New("missing token")
	ErrUnexpectedTokenType       = errors.New("unexpected type")
	ErrMissingTokenClaims        = errors.New("missing token claims")
	ErrMissingTokenClaimsSubject = errors.New("missing token claims subject")
	ErrMissingTokenClaimsID      = errors.New("missing token claims id")
	ErrUnexpectedTokenClaimsType = errors.New("unexpected token claims type")
)

Functions

func GetCtxToken added in v0.5.3

func GetCtxToken(ctx context.Context) (string, error)

GetCtxToken gets the raw token from the context

Parameters:

  • ctx: The context to get the raw token from

Returns:

  • string: The raw token
  • error: An error if the raw token is not found or is of an unexpected type

func GetCtxTokenClaims

func GetCtxTokenClaims(ctx context.Context) (jwt.MapClaims, error)

GetCtxTokenClaims gets the token claims from the context

Parameters:

  • ctx: The context to get the token claims from

Returns:

  • jwt.MapClaims: The token claims
  • error: An error if the token claims are not found or are of an unexpected type

func GetCtxTokenClaimsJwtID added in v0.5.3

func GetCtxTokenClaimsJwtID(ctx context.Context) (string, error)

GetCtxTokenClaimsJwtID gets the token claims JWT ID from the context

Parameters:

  • ctx: The context to get the token claims JWT ID from

Returns:

  • string: The token claims JWT ID
  • error: An error if the token claims JWT ID is not found or is of an unexpected type

func GetCtxTokenClaimsSubject

func GetCtxTokenClaimsSubject(ctx context.Context) (string, error)

GetCtxTokenClaimsSubject gets the token claims subject from the context

Parameters:

  • ctx: The context to get the token claims subject from

Returns:

  • string: The token claims subject
  • error: An error if the token claims subject is not found or is of an unexpected type

func SetCtxToken added in v0.5.3

func SetCtxToken(ctx context.Context, token string) context.Context

SetCtxToken sets the raw token to the context

Parameters:

  • ctx: The context to set the raw token to
  • token: The raw token to set

Returns:

  • context.Context: The context with the raw token set

func SetCtxTokenClaims

func SetCtxTokenClaims(
	ctx context.Context,
	claims jwt.MapClaims,
) context.Context

SetCtxTokenClaims sets the token claims to the context

Parameters:

  • ctx: The context to set the token claims to
  • claims: The token claims to set

Returns:

  • context.Context: The context with the token claims set

Types

This section is empty.

Jump to

Keyboard shortcuts

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