Module: Remotus::Auth

Defined in:
lib/remotus/auth.rb,
lib/remotus/auth/store.rb,
lib/remotus/auth/credential.rb,
lib/remotus/auth/hash_store.rb

Overview

Module containing remote authentication classes and modules

Defined Under Namespace

Classes: Credential, HashStore, Store

Class Method Summary collapse

Class Method Details

.cacheHash{String => Remotus::Auth::Credential}

Gets the credential cache

Returns:



35
36
37
# File 'lib/remotus/auth.rb', line 35

def self.cache
  @cache ||= {}
end

.clear_cacheObject

Clears all entries in the credential cache



42
43
44
# File 'lib/remotus/auth.rb', line 42

def self.clear_cache
  @cache = {}
end

.credential(connection, **options) ⇒ Remotus::Auth::Credential

Gets authentication credentials for the given connection and options

Parameters:

Returns:

Raises:



20
21
22
23
24
25
26
27
28
# File 'lib/remotus/auth.rb', line 20

def self.credential(connection, **options)
  # Only return cached credentials that have a populated user and password, otherwise attempt retrieval
  return cache[connection.host] if cache.key?(connection.host) && cache[connection.host].user && cache[connection.host].password

  found_credential = credential_from_stores(connection, **options)
  return found_credential if found_credential

  raise Remotus::MissingCredential, "Could not find credential for #{connection.host} in any credential store (#{stores.join(", ")})."
end

.storesArray<Remotus::Auth::Store>

Gets the list of associated credential stores

Returns:



51
52
53
# File 'lib/remotus/auth.rb', line 51

def self.stores
  @stores ||= []
end

.stores=(stores) ⇒ Object

Sets the list of associated credential stores

Parameters:



60
61
62
# File 'lib/remotus/auth.rb', line 60

def self.stores=(stores)
  @stores = stores
end