Class: Nucleus::Adapters::AuthClient
- Inherits:
-
Object
- Object
- Nucleus::Adapters::AuthClient
- Defined in:
- lib/nucleus/core/adapter_extensions/auth/auth_client.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#verify_ssl ⇒ Object
readonly
Returns the value of attribute verify_ssl.
Instance Method Summary collapse
-
#auth_header ⇒ Object
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. -
#authenticate(username, password) ⇒ Object
Perform authentication with the given username and password at the desired endpoint.
-
#initialize(check_certificates = true) ⇒ AuthClient
constructor
Create a new instance of an AuthClient.
-
#refresh ⇒ Nucleus::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.
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)
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_ssl ⇒ Object (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_header ⇒ Object
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 |
#refresh ⇒ Nucleus::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.
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 |