Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func FindAuthorizationToken ¶
func FindAuthorizationToken(header http.Header, customName, cookieName *string) (token string, err error)
FindAuthorizationToken extracts the authorization token from the HTTP headers.
Parameters:
- header: the HTTP headers to extract the token from
- customName: optional custom header name to check for the token
- cookieName: the name of the cookie to check for the token
Returns:
- string: the extracted authorization token, or an empty string if not found - error: if there was an error during extraction
Types ¶
type Authenticator ¶
type Authenticator interface {
Authenticate() connect.UnaryInterceptorFunc
}
Authenticator interface
type Interceptor ¶
type Interceptor struct {
// contains filtered or unexported fields
}
Interceptor is the authentication interceptor
func NewInterceptor ¶
func NewInterceptor( validator gojwtvalidator.Validator, interceptions map[string]*gojwttoken.Token, options *Options, logger *slog.Logger, ) (*Interceptor, error)
NewInterceptor creates a new authentication interceptor
Parameters:
- validator: The JWT validator service (if nil, no validation will be done, can be used for gRPC gateways)
- interceptions: The map of method names to token types to intercept
- options: The options for the authentication interceptor (can be nil)
- logger: The logger for the interceptor (can be nil)
Returns:
- *Interceptor: The authentication middleware
func (Interceptor) Authenticate ¶
func (i Interceptor) Authenticate() connect.UnaryInterceptorFunc
Authenticate is a unary server interceptor that extracts an authentication token
type Options ¶
type Options struct {
CustomRefreshTokenName *string
CustomAccessTokenName *string
RefreshTokenFn RefreshTokenFn
}
Options is the options for the authentication interceptor
Click to show internal directories.
Click to hide internal directories.