safety_net_attestation 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 +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/lib/safety_net_attestation.rb +4 -3
- data/lib/safety_net_attestation/statement.rb +8 -8
- data/lib/safety_net_attestation/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: 5116645ce8afe8172658cd294571bb6cef9921579f86ca8b8b8e9cb9d44620d4
|
4
|
+
data.tar.gz: 9cbf7c06202bc80ffa7e2f151c354f3a89ab75048cec8b064096840ece5a68e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 359e37de75eebdf4198e79996f15ab7cc5d24e34cd664e34136b8a0d6f385729b696f541c40ca4dce14f2f2848082ef4ad4779d0a3c97386b91e291c1913339a
|
7
|
+
data.tar.gz: d2467423824192b293507131a2957e512a9c412ed762c6444359d1605edfe3f3cb837ed167245994d367ba2b37774cfac112018e1a998c39298d06ef279e51bb
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,13 @@ 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-29
|
10
|
+
### Fixed
|
11
|
+
- Root certificate loading when this gem is used as a dependency
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
- Rename `Statement#certificates` to `Statement#certificate_chain`
|
15
|
+
|
9
16
|
## [0.3.0] - 2019-12-29
|
10
17
|
### Added
|
11
18
|
- `Statement#certificates` exposes the certificate chain used during verification
|
@@ -21,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
21
28
|
- Extracted from [webauthn-ruby](https://github.com/cedarcode/webauthn-ruby) after discussion with the maintainers. Thanks for the feedback @grzuy and @brauliomartinezlm!
|
22
29
|
|
23
30
|
[Unreleased]: https://github.com/bdewater/safety_net_attestation/compare/v0.1.0...HEAD
|
31
|
+
[0.4.0]: https://github.com/bdewater/safety_net_attestation/compare/v0.3.0...v0.4.0
|
24
32
|
[0.3.0]: https://github.com/bdewater/safety_net_attestation/compare/v0.2.0...v0.3.0
|
25
33
|
[0.2.0]: https://github.com/bdewater/safety_net_attestation/compare/v0.1.0...v0.2.0
|
26
34
|
[0.1.0]: https://github.com/bdewater/safety_net_attestation/releases/tag/v0.1.0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "safety_net_attestation/statement"
|
4
|
-
require_relative "safety_net_attestation/version"
|
5
|
-
|
6
3
|
module SafetyNetAttestation
|
4
|
+
GEM_ROOT = File.expand_path(__dir__)
|
7
5
|
end
|
6
|
+
|
7
|
+
require_relative "safety_net_attestation/statement"
|
8
|
+
require_relative "safety_net_attestation/version"
|
@@ -10,7 +10,7 @@ require_relative "x5c_key_finder"
|
|
10
10
|
module SafetyNetAttestation
|
11
11
|
class Statement
|
12
12
|
GOOGLE_ROOT_CERTIFICATES = Dir.glob(
|
13
|
-
File.join(
|
13
|
+
File.join(SafetyNetAttestation::GEM_ROOT, "safety_net_attestation", "certificates", "*.*")
|
14
14
|
).map do |path|
|
15
15
|
file = File.binread(path)
|
16
16
|
OpenSSL::X509::Certificate.new(file)
|
@@ -25,22 +25,22 @@ module SafetyNetAttestation
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def verify(nonce, timestamp_leeway: 60, trusted_certificates: GOOGLE_ROOT_CERTIFICATES, time: Time.now)
|
28
|
-
|
28
|
+
certificate_chain = nil
|
29
29
|
response, _ = JWT.decode(@jws_result, nil, true, algorithms: ["ES256", "RS256"]) do |headers|
|
30
30
|
x5c_certificates = headers["x5c"].map do |encoded|
|
31
31
|
OpenSSL::X509::Certificate.new(Base64.strict_decode64(encoded))
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
certificate_chain = X5cKeyFinder.from(x5c_certificates, trusted_certificates, time: time)
|
35
|
+
certificate_chain.first.public_key
|
36
36
|
end
|
37
37
|
|
38
|
-
verify_certificate_subject(
|
38
|
+
verify_certificate_subject(certificate_chain.first)
|
39
39
|
verify_nonce(response, nonce)
|
40
40
|
verify_timestamp(response, timestamp_leeway, time)
|
41
41
|
|
42
42
|
@json = response
|
43
|
-
@
|
43
|
+
@certificate_chain = certificate_chain
|
44
44
|
self
|
45
45
|
end
|
46
46
|
|
@@ -80,10 +80,10 @@ module SafetyNetAttestation
|
|
80
80
|
json["advice"]&.split(",")
|
81
81
|
end
|
82
82
|
|
83
|
-
def
|
83
|
+
def certificate_chain
|
84
84
|
raise NotVerifiedError unless json
|
85
85
|
|
86
|
-
@
|
86
|
+
@certificate_chain
|
87
87
|
end
|
88
88
|
|
89
89
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safety_net_attestation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 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-12-
|
11
|
+
date: 2019-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|