remotus 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/remotus/auth.rb +32 -8
- data/lib/remotus/auth/hash_store.rb +1 -1
- data/lib/remotus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46da915bc63af444b4bed497e154bec84c780f20bb92be17618f22444fd26889
|
4
|
+
data.tar.gz: 43f29167c6c4a9c264208f8c2454278b884edb78ea596cb00d1439db05a846ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4421747e84af73d3c2648430ccb4717b9ecb01eef6044560a1d28e101f1f2082d357c4d1827c7921aace92b513123c4097419a587d31425d62d3ccbbf0e6d2f
|
7
|
+
data.tar.gz: 40dffbc5f8fa8db04fd9a803d73d3396ce31084da733b653c6636de73eb5e03c644f130b1f51baa6672f94955fb2a5b29fcd6def0b5ec3c8cb59afbc5319453c
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
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
|
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
|
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
|
data/lib/remotus/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|