Class: Gruf::Authentication::Base

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/gruf/authentication/base.rb

Overview

Base interface for Authentication strategies

Direct Known Subclasses

Basic, None

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Loggable

#logger

Constructor Details

#initialize(credentials, options = {}) ⇒ Base

Returns a new instance of Base.

Parameters:

  • credentials (String)


31
32
33
34
35
# File 'lib/gruf/authentication/base.rb', line 31

def initialize(credentials, options = {})
  opts = Gruf.authentication_options || {}
  @credentials = credentials
  @options = opts.merge(options)
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



25
26
27
# File 'lib/gruf/authentication/base.rb', line 25

def credentials
  @credentials
end

#optionsObject (readonly)

Returns the value of attribute options.



25
26
27
# File 'lib/gruf/authentication/base.rb', line 25

def options
  @options
end

Class Method Details

.verify(call, credentials = '', options = {}) ⇒ Object

Verify the credentials. Helper class method.

Parameters:

  • call (GRPC::ActiveCall)
  • credentials (String) (defaults to: '')
  • options (Hash) (defaults to: {})


44
45
46
# File 'lib/gruf/authentication/base.rb', line 44

def self.verify(call, credentials = '', options = {})
  new(credentials, options).valid?(call)
end

Instance Method Details

#valid?(_call) ⇒ Boolean

Parameters:

  • _call (GRPC::ActiveCall)

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


52
53
54
# File 'lib/gruf/authentication/base.rb', line 52

def valid?(_call)
  raise NotImplementedError
end