context

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2025 License: GPL-3.0 Imports: 4 Imported by: 0

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 ClearCtxAccessToken added in v0.5.3

func ClearCtxAccessToken(ctx context.Context) (context.Context, error)

ClearCtxAccessToken clears the raw access token from the context

Parameters:

  • ctx: The context to clear the raw access token from

Returns:

  • context.Context: The context with the raw access token cleared
  • error: An error if the context is nil

func ClearCtxAccessTokenClaims added in v0.5.3

func ClearCtxAccessTokenClaims(ctx context.Context) (context.Context, error)

ClearCtxAccessTokenClaims clears the access token claims from the context

Parameters:

  • ctx: The context to clear the access token claims from

Returns:

  • context.Context: The context with the access token claims cleared
  • error: An error if the context is nil

func ClearCtxAll added in v0.5.3

func ClearCtxAll(ctx context.Context) (context.Context, error)

ClearCtxAll clears all tokens and claims from the context

Parameters:

  • ctx: The context to clear the tokens and claims from

Returns:

  • context.Context: The context with the tokens and claims cleared
  • error: An error if the context is nil

func ClearCtxRefreshToken added in v0.5.3

func ClearCtxRefreshToken(ctx context.Context) (context.Context, error)

ClearCtxRefreshToken clears the raw refresh token from the context

Parameters:

  • ctx: The context to clear the raw refresh token from

Returns:

  • context.Context: The context with the raw refresh token cleared
  • error: An error if the context is nil

func ClearCtxRefreshTokenClaims added in v0.5.3

func ClearCtxRefreshTokenClaims(ctx context.Context) (context.Context, error)

ClearCtxRefreshTokenClaims clears the refresh token claims from the context

Parameters:

  • ctx: The context to clear the refresh token claims from

Returns:

  • context.Context: The context with the refresh token claims cleared
  • error: An error if the context is nil

func ClearCtxToken added in v0.5.3

func ClearCtxToken(ctx context.Context, key string) (context.Context, error)

ClearCtxToken clears the raw token from the context

Parameters:

  • ctx: The context to clear the raw token from
  • key: The key to clear the token from

Returns:

  • context.Context: The context with the raw token cleared
  • error: An error if the context is nil

func ClearCtxTokenClaims added in v0.5.2

func ClearCtxTokenClaims(ctx context.Context, key string) (
	context.Context,
	error,
)

ClearCtxTokenClaims clears the token claims from the context

Parameters:

  • ctx: The context to clear the token claims from
  • key: The key to clear the claims from

Returns:

  • context.Context: The context with the token claims cleared
  • error: An error if the context is nil

func ClearCtxTokens added in v0.5.3

func ClearCtxTokens(ctx context.Context) (context.Context, error)

ClearCtxTokens clears all tokens from the context

Parameters:

  • ctx: The context to clear the tokens from

Returns:

  • context.Context: The context with the tokens cleared
  • error: An error if the context is nil

func ClearCtxTokensClaims added in v0.5.3

func ClearCtxTokensClaims(ctx context.Context) (context.Context, error)

ClearCtxTokensClaims clears all tokens claims from the context

Parameters:

  • ctx: The context to clear the tokens claims from

Returns:

  • context.Context: The context with the tokens claims cleared
  • error: An error if the context is nil

func GetCtxAccessToken added in v0.5.3

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

GetCtxAccessToken gets the raw access token from the context

Parameters:

  • ctx: The context to get the raw access token from

Returns:

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

func GetCtxAccessTokenClaims added in v0.5.3

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

GetCtxAccessTokenClaims gets the access token claims from the context

Parameters:

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

Returns:

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

func GetCtxAccessTokenClaimsJwtID added in v0.5.3

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

GetCtxAccessTokenClaimsJwtID gets the access token claims JWT ID from the context

Parameters:

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

Returns:

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

func GetCtxAccessTokenClaimsSubject added in v0.5.3

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

GetCtxAccessTokenClaimsSubject gets the access token claims subject from the context

Parameters:

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

Returns:

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

func GetCtxRefreshToken added in v0.5.3

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

GetCtxRefreshToken gets the raw refresh token from the context

Parameters:

  • ctx: The context to get the raw refresh token from

Returns:

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

func GetCtxRefreshTokenClaims added in v0.5.3

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

GetCtxRefreshTokenClaims gets the refresh token claims from the context

Parameters:

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

Returns:

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

func GetCtxRefreshTokenClaimsJwtID added in v0.5.3

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

GetCtxRefreshTokenClaimsJwtID gets the refresh token claims JWT ID from the context

Parameters:

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

Returns:

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

func GetCtxRefreshTokenClaimsSubject added in v0.5.3

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

GetCtxRefreshTokenClaimsSubject gets the refresh token claims subject from the context

Parameters:

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

Returns:

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

func GetCtxToken added in v0.5.3

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

GetCtxToken gets the raw token from the context

Parameters:

  • ctx: The context to get the raw token from
  • key: The key to get the 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, key string) (jwt.MapClaims, error)

GetCtxTokenClaims gets the token claims from the context

Parameters:

  • ctx: The context to get the token claims from
  • key: The key to get the 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, key string) (string, error)

GetCtxTokenClaimsJwtID gets the token claims JWT ID from the context

Parameters:

  • ctx: The context to get the token claims JWT ID from
  • key: The key to get the claims 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, key string) (string, error)

GetCtxTokenClaimsSubject gets the token claims subject from the context

Parameters:

  • ctx: The context to get the token claims subject from
  • key: The key to get the claims 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 SetCtxAccessToken added in v0.5.3

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

SetCtxAccessToken sets the raw access token to the context

Parameters:

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

Returns:

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

func SetCtxAccessTokenClaims added in v0.5.3

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

SetCtxAccessTokenClaims sets the access token claims to the context

Parameters:

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

Returns:

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

func SetCtxRefreshToken added in v0.5.3

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

SetCtxRefreshToken sets the raw refresh token to the context

Parameters:

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

Returns:

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

func SetCtxRefreshTokenClaims added in v0.5.3

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

SetCtxRefreshTokenClaims sets the refresh token claims to the context

Parameters:

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

Returns:

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

func SetCtxToken added in v0.5.3

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

SetCtxToken sets the raw token to the context

Parameters:

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

Returns:

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

func SetCtxTokenClaims

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

SetCtxTokenClaims sets the token claims to the context

Parameters:

  • ctx: The context to set the token claims to
  • key: The key to set the claims under
  • 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