Class: KubeMQ::Interceptors::AuthInterceptor Private

Inherits:
GRPC::ClientInterceptor
  • Object
show all
Defined in:
lib/kubemq/interceptors/auth_interceptor.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

gRPC client interceptor that injects a bearer authentication token into outbound request metadata.

Skips injection for Ping RPCs (which do not require authentication) and when no token is configured.

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(auth_token) ⇒ AuthInterceptor

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AuthInterceptor.

Parameters:

  • auth_token (String, nil)

    bearer token to inject into metadata



19
20
21
22
# File 'lib/kubemq/interceptors/auth_interceptor.rb', line 19

def initialize(auth_token)
  super()
  @auth_token = auth_token
end

Instance Method Details

#bidi_streamer(requests:, call:, method:, metadata:, &block) ⇒ Enumerator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns bidirectional response stream.

Parameters:

  • requests (Enumerator)

    the outbound request stream

  • call (GRPC::ActiveCall)

    the active gRPC call

  • method (String)

    the RPC method path

  • metadata (Hash)

    mutable request metadata

Returns:

  • (Enumerator)

    bidirectional response stream



59
60
61
62
# File 'lib/kubemq/interceptors/auth_interceptor.rb', line 59

def bidi_streamer(requests:, call:, method:, metadata:, &block)
  inject_auth!(, method)
  block.call(requests, call, method, )
end

#client_streamer(requests:, call:, method:, metadata:, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the RPC response.

Parameters:

  • requests (Enumerator)

    the outbound request stream

  • call (GRPC::ActiveCall)

    the active gRPC call

  • method (String)

    the RPC method path

  • metadata (Hash)

    mutable request metadata

Returns:

  • (Object)

    the RPC response



49
50
51
52
# File 'lib/kubemq/interceptors/auth_interceptor.rb', line 49

def client_streamer(requests:, call:, method:, metadata:, &block)
  inject_auth!(, method)
  block.call(requests, call, method, )
end

#request_response(request:, call:, method:, metadata:, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the RPC response.

Parameters:

  • request (Object)

    the outbound protobuf message

  • call (GRPC::ActiveCall)

    the active gRPC call

  • method (String)

    the RPC method path

  • metadata (Hash)

    mutable request metadata

Returns:

  • (Object)

    the RPC response



29
30
31
32
# File 'lib/kubemq/interceptors/auth_interceptor.rb', line 29

def request_response(request:, call:, method:, metadata:, &block)
  inject_auth!(, method)
  block.call(request, call, method, )
end

#server_streamer(request:, call:, method:, metadata:, &block) ⇒ Enumerator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns server response stream.

Parameters:

  • request (Object)

    the outbound protobuf message

  • call (GRPC::ActiveCall)

    the active gRPC call

  • method (String)

    the RPC method path

  • metadata (Hash)

    mutable request metadata

Returns:

  • (Enumerator)

    server response stream



39
40
41
42
# File 'lib/kubemq/interceptors/auth_interceptor.rb', line 39

def server_streamer(request:, call:, method:, metadata:, &block)
  inject_auth!(, method)
  block.call(request, call, method, )
end