Documentation
¶
Index ¶
- func GetHeadersFromRequestContext(ctx context.Context) (http.Header, error)
- type DefaultInterceptor
- func (i DefaultInterceptor) CreateClientContextFromRequestContext(originalCtx context.Context, headers ...string) (ctx context.Context, callInfo connect.CallInfo, err error)
- func (i DefaultInterceptor) InjectAccessAndRefreshTokens(ctx context.Context, refreshToken, accessToken string) error
- func (i DefaultInterceptor) InjectHeadersFromCallInfo(ctx context.Context, callInfo connect.CallInfo) error
- func (i DefaultInterceptor) InjectRefreshAndAccessTokensFromContext(ctx context.Context) error
- type Injector
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHeadersFromRequestContext ¶
GetHeadersFromRequestContext tries to get the response headers from the context
Parameters:
- ctx: The context to get the response headers from
Returns:
- http.Header: The response headers - error: If there was an error getting the response headers
Types ¶
type DefaultInterceptor ¶
type DefaultInterceptor struct {
// contains filtered or unexported fields
}
DefaultInterceptor is the default tokens response headers interceptor
func NewDefaultInterceptor ¶
func NewDefaultInterceptor( options *Options, ) *DefaultInterceptor
NewDefaultInterceptor creates a new default tokens response headers interceptor
Parameters:
- options: the options for the interceptor
Returns:
- *DefaultInterceptor: the default tokens response headers interceptor
func (DefaultInterceptor) CreateClientContextFromRequestContext ¶
func (i DefaultInterceptor) CreateClientContextFromRequestContext( originalCtx context.Context, headers ...string, ) (ctx context.Context, callInfo connect.CallInfo, err error)
CreateClientContextFromRequestContext creates a client context from the request context, injecting specified headers
Parameters:
- originalCtx: the request context - headers: the headers to inject
Returns:
- context.Context: the client context - error: if there was an error creating the client context
func (DefaultInterceptor) InjectAccessAndRefreshTokens ¶
func (i DefaultInterceptor) InjectAccessAndRefreshTokens( ctx context.Context, refreshToken, accessToken string, ) error
InjectAccessAndRefreshToken injects the access and refresh tokens into the response headers
Parameters:
- ctx: the context - refreshToken: the refresh token - accessToken: the access token
Returns:
- error: if there was an error injecting the tokens into the response headers
func (DefaultInterceptor) InjectHeadersFromCallInfo ¶
func (i DefaultInterceptor) InjectHeadersFromCallInfo( ctx context.Context, callInfo connect.CallInfo, ) error
InjectHeadersFromCallInfo injects headers from the call info into the response headers
Parameters:
- ctx: the context - callInfo: the call info
Returns:
- error: if there was an error injecting the headers
func (DefaultInterceptor) InjectRefreshAndAccessTokensFromContext ¶
func (i DefaultInterceptor) InjectRefreshAndAccessTokensFromContext( ctx context.Context, ) error
InjectRefreshAndAccessTokensFromContext injects the refresh and access tokens from the context into the response headers
Parameters:
- ctx: the context
Returns:
- error: if there was an error injecting the tokens into the response headers
type Injector ¶
type Injector interface {
InjectAccessAndRefreshTokens(
ctx context.Context,
refreshToken,
accessToken string,
) error
InjectAccessAndRefreshTokensFromContext(
ctx context.Context,
) error
CreateClientContextFromRequestContext(
ctx context.Context, headers ...string,
) (context.Context, error)
InjectHeadersFromCallInfo(
ctx context.Context,
callInfo connect.CallInfo,
) error
}
Injector is used to inject headers into the response headers
type Options ¶
type Options struct {
// CustomRefreshTokenName is the custom refresh token name to use in the response headers
CustomRefreshTokenName *string
// CustomAccessTokenName is the custom access token name to use in the response headers
CustomAccessTokenName *string
// CookieAttributes is a map of cookie attributes to use for the tokens
CookieAttributes map[string]http.Cookie
// CookieRefreshTokenDuration is the duration to set for the refresh token cookie
CookieRefreshTokenDuration *time.Duration
// CookieAccessTokenDuration is the duration to set for the access token cookie
CookieAccessTokenDuration *time.Duration
}
Options are the options for the tokens response headers interceptor