Module: Setsuzoku::AuthStrategy

Extended by:
Forwardable, T::Helpers, T::Sig
Includes:
HasConfigContext
Included in:
Service::WebService::AuthStrategy
Defined in:
lib/setsuzoku/auth_strategy.rb

Overview

The API Authentication Interface definition. Any AuthStrategy that implements this interface must implement all abstract methods defined by AuthStrategy.

Defines all necessary methods for handling authentication for any authentication strategy.

Instance Attribute Summary collapse

Attributes included from HasConfigContext

#config_context

Instance Method Summary collapse

Methods included from HasConfigContext

#get_from_context

Instance Attribute Details

#credentialCredential

The getter method for a credential should retrieve dynamically if it’s a proc. We cannot assign this at initialize time, as it may not yet exist on the instance.

Returns:

  • (Credential)

    the credential to use for the current requests.



54
55
56
# File 'lib/setsuzoku/auth_strategy.rb', line 54

def credential
  @credential
end

#serviceObject

Returns the value of attribute service.



18
19
20
# File 'lib/setsuzoku/auth_strategy.rb', line 18

def service
  @service
end

Instance Method Details

#auth_credential_valid?Boolean

Returns:

  • (Boolean)


77
# File 'lib/setsuzoku/auth_strategy.rb', line 77

def auth_credential_valid?; end

#initialize(service:, **args) ⇒ AuthStrategy

Initialize the auth_strategy and provide reference to service.

Parameters:

  • service (Service)

    the new instance of service with its correct strategies.

Returns:



43
44
45
46
47
48
# File 'lib/setsuzoku/auth_strategy.rb', line 43

def initialize(service:, **args)
  self.service = service
  self.set_credential!(self.class.credential_class.stub_credential) unless self.plugin.registered_instance
  self.config_context = args
  self
end

#new_credential!(**args) ⇒ Object



84
# File 'lib/setsuzoku/auth_strategy.rb', line 84

def new_credential!(**args); end

#set_credential!(credential) ⇒ void

This method returns an undefined value.

Assign the credential to the auth_strategy.



65
66
67
68
69
70
# File 'lib/setsuzoku/auth_strategy.rb', line 65

def set_credential!(credential)
  if credential
    self.credential = credential
    credential.auth_strategy = self
  end
end