Class: Nucleus::Adapters::AuthClient

Inherits:
Object
  • Object
show all
Defined in:
lib/nucleus/core/adapter_extensions/auth/auth_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(check_certificates = true) ⇒ AuthClient

Create a new instance of an Nucleus::Adapters::AuthClient. false if they are to be ignored (e.g. when using self-signed certificates in development environments)

Parameters:

  • check_certificates (Boolean) (defaults to: true)

    true if SSL certificates are to be validated,



9
10
11
# File 'lib/nucleus/core/adapter_extensions/auth/auth_client.rb', line 9

def initialize(check_certificates = true)
  @verify_ssl = check_certificates
end

Instance Attribute Details

#verify_sslObject (readonly)

Returns the value of attribute verify_ssl.



4
5
6
# File 'lib/nucleus/core/adapter_extensions/auth/auth_client.rb', line 4

def verify_ssl
  @verify_ssl
end

Instance Method Details

#auth_headerObject

Get the authentication header for the current AuthClient instance that must be used to execute requests against the endpoint.
If the authentication is known to be expired, a refresh will be made first. @raise if the refresh failed @return[Hash<String, String>] authentication header that enables requests against the endpoint



29
30
31
32
# File 'lib/nucleus/core/adapter_extensions/auth/auth_client.rb', line 29

def auth_header
  fail Errors::EndpointAuthenticationError,
       'Authentication client does not support to create the authentication header'
end

#authenticate(username, password) ⇒ Object

Perform authentication with the given username and password at the desired endpoint. @param username username to use for authentication @param password password to the username, which is to be used for authentication @raise if authentication failed @raise if the generic AuthClient did expect the endpoint to behave differently, usually indicates implementation issues @return current AuthClient instance



20
21
22
# File 'lib/nucleus/core/adapter_extensions/auth/auth_client.rb', line 20

def authenticate(username, password)
  fail Errors::EndpointAuthenticationError, 'Authentication client does not support authentication'
end

#refreshNucleus::Adapters::AuthClient

Refresh a rejected authentication and generate a new authentication header.
Should be called if the authentication is known to be expired, or when a request is rejected with an authentication header that used to be accepted.

Returns:

Raises:



39
40
41
# File 'lib/nucleus/core/adapter_extensions/auth/auth_client.rb', line 39

def refresh
  fail Errors::EndpointAuthenticationError, 'Authentication client does not support refresh'
end