Documentation
¶
Overview ¶
Package authforwarder is a combination of http middleware and grpc injectors that passes the content of the "Authorization" header from the incoming http request to any outgoing grpc calls.
Index ¶
- func ExtractAuthorization(ctx context.Context) string
- func HTTPMiddleware(next http.Handler) http.Handler
- func StreamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, ...) (grpc.ClientStream, error)
- func StreamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, ...) error
- func UnaryClientInterceptor(ctx context.Context, method string, req interface{}, reply interface{}, ...) error
- func UnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, ...) (any, error)
- type AuthRoundTripper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractAuthorization ¶
ExtractAuthorization shouldn't be public, but it temporarily is to keep things working.
func HTTPMiddleware ¶
HTTPMiddleware injects the authorization header into the context.
func StreamClientInterceptor ¶
func StreamClientInterceptor( ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption, ) (grpc.ClientStream, error)
StreamClientInterceptor does the same for streaming requests. Note that we don't try to intercept the streaming messages.
func StreamInterceptor ¶
func StreamInterceptor( srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler, ) error
StreamInterceptor will process the authorization header, convert it to a prefix, and then inject it into the context, but for streams.
func UnaryClientInterceptor ¶
func UnaryClientInterceptor( ctx context.Context, method string, req interface{}, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption, ) error
UnaryClientInterceptor extracts the auth header value from the context and appends it to the outgoing metadata.
func UnaryInterceptor ¶
func UnaryInterceptor( ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (any, error)
Types ¶
type AuthRoundTripper ¶
type AuthRoundTripper struct {
Proxied http.RoundTripper
}
AuthRoundTripper is a http client "middleware" that extracts the auth middleware out of the context and injects it into the request.