context

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoTokenInContext                   = errors.New("no token in context")
	ErrInvalidTokenInContext              = errors.New("invalid token in context")
	ErrNoTokenClaimsInContext             = errors.New("no token claims in context")
	ErrInvalidTokenClaimsInContext        = errors.New("invalid token claims in context")
	ErrNoIssuedAccessTokenInContext       = errors.New("no issued access token in context")
	ErrInvalidIssuedAccessTokenInContext  = errors.New("invalid issued access token in context")
	ErrNoIssuedRefreshTokenInContext      = errors.New("no issued refresh token in context")
	ErrInvalidIssuedRefreshTokenInContext = errors.New("invalid issued refresh token in context")
)

Functions

func GetClientIP added in v0.2.11

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

GetClientIP retrieves the client IP address from the HTTP headers.

Parameters:

- ctx: The HTTP headers to extract the client IP from

Returns:

- string: The client IP address, or an empty string if not found - error: If there was an error during extraction

func GetCtxIssuedAccessToken

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

GetCtxIssuedAccessToken retrieves the issued access token from the context

Parameters:

  • ctx: the context

Returns:

  • string: the issued access token
  • error: if there was an error retrieving the issued access token

func GetCtxIssuedRefreshToken

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

GetCtxIssuedRefreshToken retrieves the issued refresh token from the context

Parameters:

- ctx: the context

Returns:

- string: the issued refresh token - error: if there was an error retrieving the issued refresh token

func SetCtxIssuedAccessToken

func SetCtxIssuedAccessToken(
	ctx context.Context,
	issuedAccessToken string,
) context.Context

SetCtxIssuedAccessToken sets the issued access token flag in the context

Parameters:

- ctx: the context - issuedAccessToken: the issued access token

Returns:

- context.Context: the context with the issued access token set

func SetCtxIssuedRefreshToken

func SetCtxIssuedRefreshToken(
	ctx context.Context,
	issuedRefreshToken string,
) context.Context

SetCtxIssuedRefreshToken sets the issued refresh token flag in the context

Parameters:

- ctx: the context - issuedRefreshToken: the issued refresh token

Returns:

- context.Context: the context with the issued refresh token set

Types

type ContextKey

type ContextKey string

ContextKey is the type for context keys

const (
	// CtxIssuedAccessTokenKey is the context key for the issued access token
	CtxIssuedAccessTokenKey ContextKey = "issued_access_token"

	// CtxIssuedRefreshTokenKey is the context key for the issued refresh token
	CtxIssuedRefreshTokenKey ContextKey = "issued_refresh_token"
)

Jump to

Keyboard shortcuts

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