fido_metadata 0.3.0 → 0.4.0

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: '08330439dce6050e6e099e11620382b947e17777a40744f72283a1be18a07c3e'
4
- data.tar.gz: 2377b8900e5593832e965d53c41cac920d23bc846eb0be698b42f8d499f0d976
3
+ metadata.gz: 0c6e9096d99e10cec5ea15b15be0d472ef3ec60e58378505af0bae9851b6292a
4
+ data.tar.gz: 8d2221965bf30f01241fad4753a76cf7889ac61262a1af9b2e68bb93837afc48
5
5
  SHA512:
6
- metadata.gz: 1122f49d0fe46db1464763d37db667c09e7794b2acdac868effc6a5bac03c1ec9f38a6b2a4beb87b419f2f9028cd84021aaab6b858a8e645ff452c4c4b53f595
7
- data.tar.gz: c60c889a0e9c3088d27530be2fa9f3a97ead8dbbdf638d18909ed66d78431fc969548282b4b6a41e030b5160abd42f171860c455aabbf993ed4fa0faeaabe189
6
+ metadata.gz: fb89e5eec3d127872bfd90663f5a25e14554aff9bed9cdc058fed1b394d148f6a6057a7148aa40271360f217b2efb150c1f8525ee041ae19f7acaa3ad0eadc86
7
+ data.tar.gz: 8a708a7fa370ad71a29bb42517061d95d2608b20ce92514e58004216e6b826d5d8fdc3ffb45e433197c5699f05b9a6746363f64e476b7ad936380aae0dea753c
@@ -7,6 +7,7 @@ AllCops:
7
7
  DisabledByDefault: true
8
8
  Exclude:
9
9
  - "gemfiles/**/*"
10
+ - "vendor/**/*"
10
11
 
11
12
  Bundler:
12
13
  Enabled: true
@@ -1,7 +1,18 @@
1
1
  ---
2
- sudo: false
3
2
  language: ruby
4
3
  cache: bundler
5
4
  rvm:
6
5
  - 2.6.5
7
- before_install: gem install bundler -v 1.17.3
6
+ - 2.5.7
7
+ - 2.4.9
8
+ - 2.3.8
9
+ script:
10
+ - bin/rspec
11
+ jobs:
12
+ fast_finish: true
13
+ include:
14
+ - rvm: 2.6.5
15
+ name: Rubocop
16
+ script:
17
+ - bundle info rubocop
18
+ - bin/rubocop
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.4.0] - 2019-12-28
10
+ ### Added
11
+ - Set `expires_in` and `race_condition_ttl` options during caching.
12
+
9
13
  ## [0.3.0] - 2019-11-24
10
14
  ### Changed
11
15
  - Made `FidoMetada::TestCacheStore` available for gem users. It is not required by default.
@@ -26,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
26
30
  - Extracted from [webauthn-ruby PR 208](https://github.com/cedarcode/webauthn-ruby/pull/208) after discussion with the maintainers. Thanks for the feedback @grzuy and @brauliomartinezlm!
27
31
 
28
32
  [Unreleased]: https://github.com/bdewater/fido_metadata/compare/v0.2.0...HEAD
33
+ [0.4.0]: https://github.com/bdewater/fido_metadata/compare/v0.3.0...v0.4.0
29
34
  [0.3.0]: https://github.com/bdewater/fido_metadata/compare/v0.2.0...v0.3.0
30
35
  [0.2.0]: https://github.com/bdewater/fido_metadata/compare/v0.1.0...v0.2.0
31
36
  [0.1.0]: https://github.com/bdewater/fido_metadata/releases/tag/v0.1.0
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fido_metadata (0.3.0)
4
+ fido_metadata (0.4.0)
5
5
  jwt (~> 2.0)
6
6
 
7
7
  GEM
@@ -5,7 +5,11 @@ require "fido_metadata/version"
5
5
 
6
6
  module FidoMetadata
7
7
  def self.configuration
8
- @configuration ||= Configuration.new
8
+ @configuration ||= begin
9
+ c = Configuration.new
10
+ c.race_condition_ttl = 1
11
+ c
12
+ end
9
13
  end
10
14
 
11
15
  def self.configure
@@ -15,5 +19,6 @@ module FidoMetadata
15
19
  class Configuration
16
20
  attr_accessor :metadata_token
17
21
  attr_accessor :cache_backend
22
+ attr_accessor :race_condition_ttl
18
23
  end
19
24
  end
@@ -89,7 +89,7 @@ module FidoMetadata
89
89
  crls = uris.compact.uniq.map do |uri|
90
90
  begin
91
91
  get(uri)
92
- rescue Net::ProtoServerError
92
+ rescue Net::ProtocolError
93
93
  # TODO: figure out why test endpoint specifies a missing and unused CRL in the cert chain, and see if this
94
94
  # rescue can be removed. If the CRL is used, OpenSSL error 3 (unable to get certificate CRL) will raise.
95
95
  nil
@@ -7,16 +7,18 @@ require "fido_metadata/statement"
7
7
  module FidoMetadata
8
8
  class Store
9
9
  METADATA_ENDPOINT = URI("https://mds2.fidoalliance.org/")
10
+ TOC_CACHE_KEY = "metadata_toc"
11
+ STATEMENT_CACHE_KEY = "statement_%s"
10
12
 
11
13
  def table_of_contents
12
14
  @table_of_contents ||= begin
13
- key = "metadata_toc"
15
+ key = TOC_CACHE_KEY
14
16
  toc = cache_backend.read(key)
15
17
  return toc if toc
16
18
 
17
19
  json = client.download_toc(METADATA_ENDPOINT)
18
20
  toc = FidoMetadata::TableOfContents.from_json(json)
19
- cache_backend.write(key, toc)
21
+ cache_backend.write(key, toc, expires_in: toc.expires_in, race_condition_ttl: race_condition_ttl)
20
22
  toc
21
23
  end
22
24
  end
@@ -38,7 +40,7 @@ module FidoMetadata
38
40
  def fetch_statement(aaguid: nil, attestation_certificate_key_id: nil)
39
41
  verify_arguments(aaguid: aaguid, attestation_certificate_key_id: attestation_certificate_key_id)
40
42
 
41
- key = "statement_#{aaguid || attestation_certificate_key_id}"
43
+ key = STATEMENT_CACHE_KEY % (aaguid || attestation_certificate_key_id)
42
44
  statement = cache_backend.read(key)
43
45
  return statement if statement
44
46
 
@@ -51,7 +53,12 @@ module FidoMetadata
51
53
 
52
54
  json = client.download_entry(entry.url, expected_hash: entry.hash)
53
55
  statement = FidoMetadata::Statement.from_json(json)
54
- cache_backend.write(key, statement)
56
+ cache_backend.write(
57
+ key,
58
+ statement,
59
+ expires_in: table_of_contents.expires_in,
60
+ race_condition_ttl: race_condition_ttl
61
+ )
55
62
  statement
56
63
  end
57
64
 
@@ -75,6 +82,10 @@ module FidoMetadata
75
82
  FidoMetadata.configuration.metadata_token || raise("no metadata_token configured")
76
83
  end
77
84
 
85
+ def race_condition_ttl
86
+ FidoMetadata.configuration.race_condition_ttl
87
+ end
88
+
78
89
  def client
79
90
  @client ||= FidoMetadata::Client.new(metadata_token)
80
91
  end
@@ -13,5 +13,9 @@ module FidoMetadata
13
13
  json_accessor("nextUpdate", Coercer::Date)
14
14
  json_accessor("entries", Coercer::Objects.new(Entry))
15
15
  json_accessor("no")
16
+
17
+ def expires_in
18
+ next_update.to_time.to_i - Time.now.to_i
19
+ end
16
20
  end
17
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FidoMetadata
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fido_metadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bart de Water
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-24 00:00:00.000000000 Z
11
+ date: 2019-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  requirements: []
182
- rubygems_version: 3.0.3
182
+ rubygems_version: 3.1.2
183
183
  signing_key:
184
184
  specification_version: 4
185
185
  summary: FIDO Alliance Metadata Service client