class Nucleus::Adapters::AuthClient

Attributes

verify_ssl[R]

Public Class Methods

new(check_certificates = true) click to toggle source

Create a new instance of an {AuthClient}. @param [Boolean] check_certificates true if SSL certificates are to be validated, false if they are to be ignored (e.g. when using self-signed certificates in development environments)

# File lib/nucleus/core/adapter_extensions/auth/auth_client.rb, line 9
def initialize(check_certificates = true)
  @verify_ssl = check_certificates
end

Public Instance Methods

auth_header() click to toggle source

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

# File lib/nucleus/core/adapter_extensions/auth/auth_client.rb, line 29
def auth_header
  raise Errors::EndpointAuthenticationError,
        'Authentication client does not support to create the authentication header'
end
authenticate(username, password) click to toggle source

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

# File lib/nucleus/core/adapter_extensions/auth/auth_client.rb, line 20
def authenticate(username, password)
  raise Errors::EndpointAuthenticationError, 'Authentication client does not support authentication'
end
refresh() click to toggle source

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. @raise [Nucleus::Errors::EndpointAuthenticationError] if token refresh failed or authentication never succeeded @return [Nucleus::Adapters::AuthClient] current AuthClient instance

# File lib/nucleus/core/adapter_extensions/auth/auth_client.rb, line 39
def refresh
  raise Errors::EndpointAuthenticationError, 'Authentication client does not support refresh'
end