Documentation ¶
Index ¶
- Constants
- func ContextWithBearerToken(ctx context.Context, token string) context.Context
- func GetBearerToken(ctx context.Context) (string, bool)
- func NewStreamClientInterceptor() grpc.StreamClientInterceptor
- func NewStreamServerInterceptor() grpc.StreamServerInterceptor
- func NewUnaryClientInterceptor() grpc.UnaryClientInterceptor
- func NewUnaryServerInterceptor() grpc.UnaryServerInterceptor
- func PropagationHandler(logger *zap.Logger, h http.Handler) http.Handler
- func ValidTokenFromGRPCMetadata(ctx context.Context, bearerHeader string) (string, error)
- type RoundTripper
Constants ¶
const Key = "bearer.token"
const StoragePropagationKey = "storage.propagate.token"
StoragePropagationKey is a key for viper configuration to pass this option to storage plugins.
Variables ¶
This section is empty.
Functions ¶
func ContextWithBearerToken ¶
ContextWithBearerToken set bearer token in context.
func GetBearerToken ¶
GetBearerToken from context, or empty string if there is no token.
func NewStreamClientInterceptor ¶ added in v1.63.0
func NewStreamClientInterceptor() grpc.StreamClientInterceptor
NewStreamClientInterceptor injects the bearer token header into gRPC request metadata.
func NewStreamServerInterceptor ¶ added in v1.63.0
func NewStreamServerInterceptor() grpc.StreamServerInterceptor
NewStreamServerInterceptor creates a new stream interceptor that injects the bearer token into the context if available.
func NewUnaryClientInterceptor ¶ added in v1.63.0
func NewUnaryClientInterceptor() grpc.UnaryClientInterceptor
NewUnaryClientInterceptor injects the bearer token header into gRPC request metadata.
func NewUnaryServerInterceptor ¶ added in v1.63.0
func NewUnaryServerInterceptor() grpc.UnaryServerInterceptor
NewUnaryServerInterceptor creates a new unary interceptor that injects the bearer token into the context if available.
func PropagationHandler ¶
PropagationHandler returns a http.Handler containing the logic to extract the Bearer token from the Authorization header of the http.Request and insert it into request.Context for propagation. The token can be accessed via GetBearerToken.
Types ¶
type RoundTripper ¶
type RoundTripper struct { // Transport is the underlying http.RoundTripper being wrapped. Required. Transport http.RoundTripper // StaticToken is the pre-configured bearer token. Optional. StaticToken string // OverrideFromCtx enables reading bearer token from Context. OverrideFromCtx bool }
RoundTripper wraps another http.RoundTripper and injects an authentication header with bearer token into requests.