campact_user_service 4.3.2 → 4.3.3
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/VERSION +1 -1
- data/lib/campact_user_service/client.rb +3 -24
- metadata +1 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ccee2822757c5f73bfa2498d203f4a6b25b829e290483bb6e4f3655889a71bbd
|
|
4
|
+
data.tar.gz: 64191ea8a3fb5a6e9eda59c4344fdd87267fc1d9273c0d2a910f14f9c3274283
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fbbafb3eba15a8032d0f8f44e4083b90f7bc520af25e519f5b52d4bf5a0716656667383dbdc776481b5ba2e2ce51e1b7939a9b7cc1e86450740722eda86f3f8c
|
|
7
|
+
data.tar.gz: e4a49a6f9de2452ab0aee37c4288181e754e9098e2fc7c78eb0443bb43529a4475c86c8fe2305b1f41fa8b58891ee1d54484631dc4f4786b60495725c878d5e7
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.3.
|
|
1
|
+
4.3.3
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require 'faraday'
|
|
2
2
|
require 'json'
|
|
3
|
-
require 'rotp'
|
|
4
3
|
require 'campact_user_service/response_error'
|
|
5
4
|
|
|
6
5
|
module CampactUserService
|
|
@@ -8,18 +7,19 @@ module CampactUserService
|
|
|
8
7
|
TIMEOUT = 60.freeze
|
|
9
8
|
OPEN_TIMEOUT = 20.freeze
|
|
10
9
|
|
|
11
|
-
attr_reader :connection, :host, :port, :
|
|
10
|
+
attr_reader :connection, :host, :port, :basic_auth
|
|
12
11
|
|
|
13
12
|
def initialize(options)
|
|
14
13
|
@host = options.fetch(:host)
|
|
15
14
|
@port = options[:port]
|
|
16
|
-
@
|
|
15
|
+
@basic_auth = options[:basic_auth]
|
|
17
16
|
faraday_options = default_faraday_options.merge(options.delete(:faraday) || {})
|
|
18
17
|
adapter = faraday_options.delete(:adapter) || Faraday.default_adapter
|
|
19
18
|
|
|
20
19
|
@connection = Faraday.new(endpoint, faraday_options) do |faraday|
|
|
21
20
|
faraday.adapter adapter
|
|
22
21
|
faraday.request :json
|
|
22
|
+
faraday.request :authorization, :basic, basic_auth[:user], basic_auth[:password] if basic_auth
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -44,9 +44,6 @@ module CampactUserService
|
|
|
44
44
|
req.body = options[:body]
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
if topt_authorization
|
|
48
|
-
req.headers['authorization'] = authorization(topt_authorization)
|
|
49
|
-
end
|
|
50
47
|
end
|
|
51
48
|
|
|
52
49
|
case response.status
|
|
@@ -93,23 +90,5 @@ module CampactUserService
|
|
|
93
90
|
end
|
|
94
91
|
end
|
|
95
92
|
|
|
96
|
-
def authorization(totp_options)
|
|
97
|
-
user = totp_options.fetch(:user)
|
|
98
|
-
secret = totp_options.fetch(:secret)
|
|
99
|
-
|
|
100
|
-
token = [user, auth_pass(secret)].join(':')
|
|
101
|
-
|
|
102
|
-
"Token #{token}"
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def auth_pass(secret)
|
|
106
|
-
totp_secret = ROTP::Base32.encode(secret)
|
|
107
|
-
|
|
108
|
-
ROTP::TOTP.new(totp_secret, {
|
|
109
|
-
digest: 'sha256',
|
|
110
|
-
digits: 8,
|
|
111
|
-
interval: 30
|
|
112
|
-
}).now
|
|
113
|
-
end
|
|
114
93
|
end
|
|
115
94
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: campact_user_service
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.3.
|
|
4
|
+
version: 4.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ControlShift
|
|
@@ -37,20 +37,6 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '2.1'
|
|
40
|
-
- !ruby/object:Gem::Dependency
|
|
41
|
-
name: rotp
|
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - "~>"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '6'
|
|
47
|
-
type: :runtime
|
|
48
|
-
prerelease: false
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '6'
|
|
54
40
|
- !ruby/object:Gem::Dependency
|
|
55
41
|
name: byebug
|
|
56
42
|
requirement: !ruby/object:Gem::Requirement
|