remotus 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46a1f303af4c352742c56801aee8d5ab8ec801361bf26761d49f8726b6e57f9a
4
- data.tar.gz: 189b4526eb5c2b76834616d9a399cc601366f4bda6ceffe0d1b8387678d2acd7
3
+ metadata.gz: 46da915bc63af444b4bed497e154bec84c780f20bb92be17618f22444fd26889
4
+ data.tar.gz: 43f29167c6c4a9c264208f8c2454278b884edb78ea596cb00d1439db05a846ea
5
5
  SHA512:
6
- metadata.gz: 475123658ca6e1aff45ddbefc328405dbaf2a163c5d0d5e28f3e4aba66ea0b4685665311f5218d797cda917a35648509b4dd6e17c760212c7722d6a45e00ebb6
7
- data.tar.gz: a27f990ea488f4fb6e163dae3478855c2ef9298626936792eda57b0f9eb2f0ed3fc60602d779f9a2fc977a8bece2e8894718116d5b308bdad947f331c686cc7c
6
+ metadata.gz: e4421747e84af73d3c2648430ccb4717b9ecb01eef6044560a1d28e101f1f2082d357c4d1827c7921aace92b513123c4097419a587d31425d62d3ccbbf0e6d2f
7
+ data.tar.gz: 40dffbc5f8fa8db04fd9a803d73d3396ce31084da733b653c6636de73eb5e03c644f130b1f51baa6672f94955fb2a5b29fcd6def0b5ec3c8cb59afbc5319453c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.2] - 2021-03-23
4
+ * Ensure both user and password are populated before using a cached credential
5
+
3
6
  ## [0.2.1] - 2021-03-15
4
7
  * Fix connection pooling metadata sharing
5
8
  * Fix caching of pooled metadata
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- remotus (0.2.1)
4
+ remotus (0.2.2)
5
5
  connection_pool (~> 2.2)
6
6
  net-scp (~> 3.0)
7
7
  net-ssh (~> 6.1)
data/lib/remotus/auth.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "remotus"
3
4
  require "remotus/auth/credential"
4
5
  require "remotus/auth/store"
5
6
  require "remotus/auth/hash_store"
@@ -17,15 +18,12 @@ module Remotus
17
18
  # @return [Remotus::Auth::Credential] found credential
18
19
  #
19
20
  def self.credential(connection, **options)
20
- return cache[connection.host] if cache.key?(connection.host)
21
+ # Only return cached credentials that have a populated user and password, otherwise attempt retrieval
22
+ return cache[connection.host] if cache.key?(connection.host) && cache[connection.host].user && cache[connection.host].password
23
+
24
+ found_credential = credential_from_stores(connection, **options)
25
+ return found_credential if found_credential
21
26
 
22
- stores.each do |store|
23
- host_cred = store.credential(connection, **options)
24
- if host_cred
25
- cache[connection.host] = host_cred
26
- return host_cred
27
- end
28
- end
29
27
  raise Remotus::MissingCredential, "Could not find credential for #{connection.host} in any credential store (#{stores.join(", ")})."
30
28
  end
31
29
 
@@ -62,5 +60,31 @@ module Remotus
62
60
  def self.stores=(stores)
63
61
  @stores = stores
64
62
  end
63
+
64
+ class << self
65
+ private
66
+
67
+ #
68
+ # Gets authentication credentials for the given connection and options from one of the credential stores
69
+ #
70
+ # @param [Remotus::SshConnection, Remotus::WinrmConnection, #host] connection remote connection
71
+ # @param [Hash] options options hash
72
+ # options may be used by different credential stores.
73
+ #
74
+ # @return [Remotus::Auth::Credential, nil] found credential or nil if the credential cannot be found
75
+ #
76
+ def credential_from_stores(connection, **options)
77
+ stores.each do |store|
78
+ Remotus.logger.debug { "Gathering #{connection.host} credentials from #{store} credential store" }
79
+ host_cred = store.credential(connection, **options)
80
+ next unless host_cred
81
+
82
+ Remotus.logger.debug { "#{connection.host} credentials found in #{store} credential store" }
83
+ cache[connection.host] = host_cred
84
+ return host_cred
85
+ end
86
+ nil
87
+ end
88
+ end
65
89
  end
66
90
  end
@@ -15,7 +15,7 @@ module Remotus
15
15
  #
16
16
  # Retrieves a credential from the hash store
17
17
  #
18
- # @param [Remotus::SshConnection, Remotus::WinrmConnection, #host] connection <description>
18
+ # @param [Remotus::SshConnection, Remotus::WinrmConnection, #host] connection associated connection
19
19
  # @param [Hash] _options unused options hash
20
20
  #
21
21
  # @return [Remotus::Auth::Credential, nil] found credential or nil
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Remotus
4
4
  # Remotus gem version
5
- VERSION = "0.2.1"
5
+ VERSION = "0.2.2"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remotus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Newell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2021-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool