Class: Authzed::GrpcUtil::BearerToken

Inherits:
GRPC::ClientInterceptor
  • Object
show all
Defined in:
lib/grpcutil/bearer_token.rb

Constant Summary collapse

AUTHORIZATION_HEADER =
'authorization'
SCHEMA =
'Bearer'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:) ⇒ BearerToken

Returns a new instance of BearerToken.



12
13
14
# File 'lib/grpcutil/bearer_token.rb', line 12

def initialize(token:)
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



10
11
12
# File 'lib/grpcutil/bearer_token.rb', line 10

def token
  @token
end

Instance Method Details

#bidi_streamer(requests: nil, call: nil, method: nil, metadata: nil) ⇒ Object

Intercept a BiDi streaming call

Parameters:

  • requests (Enumerable) (defaults to: nil)
  • call (GRPC::ActiveCall) (defaults to: nil)
  • method (String) (defaults to: nil)
  • metadata (Hash) (defaults to: nil)


63
64
65
66
# File 'lib/grpcutil/bearer_token.rb', line 63

def bidi_streamer(requests: nil, call: nil, method: nil, metadata: nil)
  [AUTHORIZATION_HEADER] = bearer_token_header
  yield
end

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

Intercept a client streaming call

Parameters:

  • requests (Enumerable) (defaults to: nil)
  • call (GRPC::ActiveCall) (defaults to: nil)
  • method (String) (defaults to: nil)
  • metadata (Hash) (defaults to: nil)


37
38
39
40
# File 'lib/grpcutil/bearer_token.rb', line 37

def client_streamer(requests: nil, call: nil, method: nil, metadata: nil)
  [AUTHORIZATION_HEADER] = bearer_token_header
  yield
end

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

Intercept a unary request response call

Parameters:

  • request (Object) (defaults to: nil)
  • call (GRPC::ActiveCall) (defaults to: nil)
  • method (String) (defaults to: nil)
  • metadata (Hash) (defaults to: nil)


24
25
26
27
# File 'lib/grpcutil/bearer_token.rb', line 24

def request_response(request: nil, call: nil, method: nil, metadata: nil)
  [AUTHORIZATION_HEADER] = bearer_token_header
  yield
end

#server_streamer(request: nil, call: nil, method: nil, metadata: nil) ⇒ Object

Intercept a server streaming call

Parameters:

  • request (Object) (defaults to: nil)
  • call (GRPC::ActiveCall) (defaults to: nil)
  • method (String) (defaults to: nil)
  • metadata (Hash) (defaults to: nil)


50
51
52
53
# File 'lib/grpcutil/bearer_token.rb', line 50

def server_streamer(request: nil, call: nil, method: nil, metadata: nil)
  [AUTHORIZATION_HEADER] = bearer_token_header
  yield
end