Class: StatelyDB::Common::Auth::Interceptor
- Inherits:
-
GRPC::ClientInterceptor
- Object
- GRPC::ClientInterceptor
- StatelyDB::Common::Auth::Interceptor
- Defined in:
- lib/common/auth/interceptor.rb
Overview
GRPC interceptor to authenticate against Stately and append bearer tokens to outgoing requests
Instance Method Summary collapse
-
#add_jwt_to_grpc_request(metadata:) ⇒ void
private
Adds a JWT to the metadata hash.
-
#bidi_streamer(requests:, call:, method:, metadata:) ⇒ Enumerator
private
gRPC bidirectional streaming interceptor.
-
#client_streamer(requests:, call:, method:, metadata:) ⇒ Enumerator
private
gRPC client streaming interceptor.
-
#initialize(token_provider:) ⇒ Interceptor
constructor
This must have been started already.
-
#request_response(request:, call:, method:, metadata:) ⇒ Object
private
gRPC client unary interceptor.
-
#server_streamer(request:, call:, method:, metadata:) ⇒ Enumerator
private
gRPC server streaming interceptor.
Constructor Details
#initialize(token_provider:) ⇒ Interceptor
This must have been started already.
14 15 16 17 18 19 |
# File 'lib/common/auth/interceptor.rb', line 14 def initialize( token_provider: ) super() @token_provider = token_provider end |
Instance Method Details
#add_jwt_to_grpc_request(metadata:) ⇒ void
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.
This method returns an undefined value.
Adds a JWT to the metadata hash
77 78 79 |
# File 'lib/common/auth/interceptor.rb', line 77 def add_jwt_to_grpc_request(metadata:) ["authorization"] = "Bearer #{@token_provider.get_token}" end |
#bidi_streamer(requests:, call:, method:, metadata:) ⇒ 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.
gRPC bidirectional streaming interceptor
68 69 70 71 |
# File 'lib/common/auth/interceptor.rb', line 68 def bidi_streamer(requests:, call:, method:, metadata:) # rubocop:disable Lint/UnusedMethodArgument add_jwt_to_grpc_request(metadata:) yield end |
#client_streamer(requests:, call:, method:, metadata:) ⇒ 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.
gRPC client streaming interceptor
42 43 44 45 |
# File 'lib/common/auth/interceptor.rb', line 42 def client_streamer(requests:, call:, method:, metadata:) # rubocop:disable Lint/UnusedMethodArgument add_jwt_to_grpc_request(metadata:) yield end |
#request_response(request:, call:, method:, metadata:) ⇒ 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.
gRPC client unary interceptor
29 30 31 32 |
# File 'lib/common/auth/interceptor.rb', line 29 def request_response(request:, call:, method:, metadata:) # rubocop:disable Lint/UnusedMethodArgument add_jwt_to_grpc_request(metadata:) yield end |
#server_streamer(request:, call:, method:, metadata:) ⇒ 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.
gRPC server streaming interceptor
55 56 57 58 |
# File 'lib/common/auth/interceptor.rb', line 55 def server_streamer(request:, call:, method:, metadata:) # rubocop:disable Lint/UnusedMethodArgument add_jwt_to_grpc_request(metadata:) yield end |