mauth-client 4.1.1 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/mauth/client.rb +15 -14
- data/lib/mauth/version.rb +1 -1
- data/mauth-client.gemspec +4 -2
- metadata +55 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e197a763a48eeb58d88be12eab10dc6e2c7c104287b0371a41120bd920402db
|
4
|
+
data.tar.gz: 84ef6da779ededf897bfe7a44eb2581073c2404a1208ae3a233b2d84c1bc98eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f640994364eee25edcbbf611a611eb539efc96432de37daf78c0211f83e966154c5dcfb321fff6e25e067fdb53faae6af792665897a7ae4d295beada833282d2
|
7
|
+
data.tar.gz: 6270a48e063208842a1055d39814b96fe2cb4b8ceea04592eb94c62b533f110fe5510ca9060f321d5f4a309b96aaf9c99489ff28e068e5ddd6c04e20c1ae9bab
|
data/CHANGELOG.md
CHANGED
data/lib/mauth/client.rb
CHANGED
@@ -7,6 +7,8 @@ require 'mauth/core_ext'
|
|
7
7
|
require 'mauth/autoload'
|
8
8
|
require 'mauth/dice_bag/mauth_templates'
|
9
9
|
require 'mauth/version'
|
10
|
+
require 'faraday-http-cache'
|
11
|
+
require 'oj'
|
10
12
|
|
11
13
|
module MAuth
|
12
14
|
class Client
|
@@ -405,12 +407,7 @@ module MAuth
|
|
405
407
|
@security_token_cacher ||= SecurityTokenCacher.new(self)
|
406
408
|
end
|
407
409
|
class SecurityTokenCacher
|
408
|
-
|
409
|
-
CACHE_LIFE = 60
|
410
|
-
def expired?
|
411
|
-
create_time + CACHE_LIFE < Time.now
|
412
|
-
end
|
413
|
-
end
|
410
|
+
|
414
411
|
def initialize(mauth_client)
|
415
412
|
@mauth_client = mauth_client
|
416
413
|
# TODO: should this be UnableToSignError?
|
@@ -421,7 +418,7 @@ module MAuth
|
|
421
418
|
end
|
422
419
|
|
423
420
|
def get(app_uuid)
|
424
|
-
if !@cache[app_uuid]
|
421
|
+
if !@cache[app_uuid]
|
425
422
|
# url-encode the app_uuid to prevent trickery like escaping upward with ../../ in a malicious
|
426
423
|
# app_uuid - probably not exploitable, but this is the right way to do it anyway.
|
427
424
|
# use UNRESERVED instead of UNSAFE (the default) as UNSAFE doesn't include /
|
@@ -432,13 +429,8 @@ module MAuth
|
|
432
429
|
raise UnableToAuthenticateError, "mAuth service did not respond; received #{$!.class}: #{$!.message}"
|
433
430
|
end
|
434
431
|
if response.status == 200
|
435
|
-
begin
|
436
|
-
security_token = JSON.parse(response.body)
|
437
|
-
rescue JSON::ParserError
|
438
|
-
raise UnableToAuthenticateError, "mAuth service responded with unparseable json: #{response.body}\n#{$!.class}: #{$!.message}"
|
439
|
-
end
|
440
432
|
@cache_write_lock.synchronize do
|
441
|
-
@cache[app_uuid] =
|
433
|
+
@cache[app_uuid] = security_token_from(response.body)
|
442
434
|
end
|
443
435
|
elsif response.status == 404
|
444
436
|
# signing with a key mAuth doesn't know about is considered inauthentic
|
@@ -447,11 +439,19 @@ module MAuth
|
|
447
439
|
@mauth_client.send(:mauth_service_response_error, response)
|
448
440
|
end
|
449
441
|
end
|
450
|
-
@cache[app_uuid]
|
442
|
+
@cache[app_uuid]
|
451
443
|
end
|
452
444
|
|
453
445
|
private
|
454
446
|
|
447
|
+
def security_token_from(response_body)
|
448
|
+
JSON.parse response_body
|
449
|
+
rescue JSON::ParserError => e
|
450
|
+
msg = "mAuth service responded with unparseable json: #{response_body}\n#{e.class}: #{e.message}"
|
451
|
+
@mauth_client.logger.error("Unable to authenticate with MAuth. Exception #{msg}")
|
452
|
+
raise UnableToAuthenticateError, msg
|
453
|
+
end
|
454
|
+
|
455
455
|
def signed_mauth_connection
|
456
456
|
require 'faraday'
|
457
457
|
require 'mauth/faraday'
|
@@ -459,6 +459,7 @@ module MAuth
|
|
459
459
|
@signed_mauth_connection ||= ::Faraday.new(@mauth_client.mauth_baseurl, @mauth_client.faraday_options) do |builder|
|
460
460
|
builder.use MAuth::Faraday::MAuthClientUserAgent
|
461
461
|
builder.use MAuth::Faraday::RequestSigner, 'mauth_client' => @mauth_client
|
462
|
+
builder.use :http_cache, serializer: Oj, logger: MAuth::Client.new.logger, shared_cache: false
|
462
463
|
builder.adapter ::Faraday.default_adapter
|
463
464
|
end
|
464
465
|
end
|
data/lib/mauth/version.rb
CHANGED
data/mauth-client.gemspec
CHANGED
@@ -18,8 +18,10 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'faraday', '
|
22
|
-
spec.add_dependency 'faraday_middleware', '
|
21
|
+
spec.add_dependency 'faraday', '>= 0.17', '< 1.0'
|
22
|
+
spec.add_dependency 'faraday_middleware', '>= 0.9', '< 2.0'
|
23
|
+
spec.add_dependency 'faraday-http-cache', '>= 2.0', '< 3.0'
|
24
|
+
spec.add_dependency 'oj', '~> 3.0'
|
23
25
|
spec.add_dependency 'term-ansicolor', '~> 1.0'
|
24
26
|
spec.add_dependency 'coderay', '~> 1.0'
|
25
27
|
spec.add_dependency 'rack'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mauth-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Szenher
|
@@ -11,36 +11,82 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2021-06-16 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
|
-
- - "
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0.17'
|
23
|
+
- - "<"
|
21
24
|
- !ruby/object:Gem::Version
|
22
|
-
version: '0
|
25
|
+
version: '1.0'
|
23
26
|
type: :runtime
|
24
27
|
prerelease: false
|
25
28
|
version_requirements: !ruby/object:Gem::Requirement
|
26
29
|
requirements:
|
27
|
-
- - "
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.17'
|
33
|
+
- - "<"
|
28
34
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0
|
35
|
+
version: '1.0'
|
30
36
|
- !ruby/object:Gem::Dependency
|
31
37
|
name: faraday_middleware
|
32
38
|
requirement: !ruby/object:Gem::Requirement
|
33
39
|
requirements:
|
34
|
-
- - "
|
40
|
+
- - ">="
|
35
41
|
- !ruby/object:Gem::Version
|
36
42
|
version: '0.9'
|
43
|
+
- - "<"
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.0'
|
37
46
|
type: :runtime
|
38
47
|
prerelease: false
|
39
48
|
version_requirements: !ruby/object:Gem::Requirement
|
40
49
|
requirements:
|
41
|
-
- - "
|
50
|
+
- - ">="
|
42
51
|
- !ruby/object:Gem::Version
|
43
52
|
version: '0.9'
|
53
|
+
- - "<"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: faraday-http-cache
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '2.0'
|
63
|
+
- - "<"
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '3.0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '2.0'
|
73
|
+
- - "<"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: oj
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
44
90
|
- !ruby/object:Gem::Dependency
|
45
91
|
name: term-ansicolor
|
46
92
|
requirement: !ruby/object:Gem::Requirement
|
@@ -270,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
316
|
- !ruby/object:Gem::Version
|
271
317
|
version: '0'
|
272
318
|
requirements: []
|
273
|
-
rubygems_version: 3.0.
|
319
|
+
rubygems_version: 3.0.8
|
274
320
|
signing_key:
|
275
321
|
specification_version: 4
|
276
322
|
summary: Sign and authenticate requests and responses with mAuth authentication.
|