Module: Setsuzoku::AuthStrategy

Extended by:
Forwardable, T::Helpers, T::Sig
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

Instance Method Summary collapse

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.



16
17
18
# File 'lib/setsuzoku/auth_strategy.rb', line 16

def service
  @service
end

Instance Method Details

#auth_credential_valid?Boolean

Returns:

  • (Boolean)


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

def auth_credential_valid?; end

#finalAuthStrategy

Initialize the auth_strategy and provide reference to service.

Parameters:

  • service (Service)

    the new instance of service with its correct strategies.

Returns:



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/setsuzoku/auth_strategy.rb', line 25

sig(:final) do
  params(
      service: T.any(
          Setsuzoku::Service::WebService::Service,
          T.untyped
      ),
      args: T.untyped
  ).returns(T.any(
      Setsuzoku::Service::WebService::AuthStrategies::BasicAuthStrategy,
      Setsuzoku::Service::WebService::AuthStrategies::OAuthStrategy,
      T.untyped
  ))
end

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



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

def initialize(service:, **args)
  self.service = service
  credential = args[:credential]
  self.credential = if self.plugin.registered_instance
                      credential
                    else
                      self.class.credential_class.stub_credential
                    end
  self
end

#new_credential!(**args) ⇒ Object



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

def new_credential!(**args); end