authentic-rb 1.5.0 → 1.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb2f7b5ad8a00dff35d176f3da8bcb7d8064d5f843eeda674f3fdd09be1a8e62
4
- data.tar.gz: '0468d1f9e132b58ece69b58b024ae44bd537194a5071f32142cec77388a04d2c'
3
+ metadata.gz: bb1a72bbd0adfdc4e710bc9cb998eed816b68c2d478ee69d7e891028249a9b78
4
+ data.tar.gz: a05603819fde73ff95e53a6c3feba89ddab1481bebf64a2fb2dffe6443231d62
5
5
  SHA512:
6
- metadata.gz: 86f68149c8764e0f38f284c336711eb12804c6d0b51515c2ed69df4d141bc36955e5ece42ba065d47177ed7a30129a522e9c6f449ed2e777298ba146883e06c2
7
- data.tar.gz: bf9cbced07b3c33500d6b491b49763ef9c93225b5a48fc0d18390cd96142030b44482753b9b5f19d05665b0e7c32b9b35edb196200b897ed57b28befe6c2b2ab
6
+ metadata.gz: ff375b3fa277837009eb7027a918d395a0aaebcd5eebc633b71070f02519407107112b6a1775143d0e3831441efe7e0188af0c3d1ae95de1866bf90e9b7a4660
7
+ data.tar.gz: 8f48caceb8e1302b4a54d2a41bf42af3df2b8c66f609f5d5621368305c5efe0867945c311b2c52423840d63288520ad1fa2ea94f12f176a8f61a82bd7c56cc37
@@ -19,4 +19,7 @@ module Authentic
19
19
 
20
20
  # Public: Represents a bad JWT.
21
21
  class InvalidToken < StandardError; end
22
+
23
+ # Public: Represents an expired JWT.
24
+ class ExpiredToken < StandardError; end
22
25
  end
@@ -25,7 +25,7 @@ module Authentic
25
25
  def valid?(token)
26
26
  ensure_valid(token)
27
27
  true
28
- rescue InvalidToken, InvalidKey, RequestError
28
+ rescue InvalidToken, ExpiredToken, InvalidKey, RequestError
29
29
  false
30
30
  end
31
31
 
@@ -41,16 +41,17 @@ module Authentic
41
41
 
42
42
  # Slightly more accurate to raise a key error here for nil key,
43
43
  # rather then verify raising an error that would lead to InvalidToken
44
- raise InvalidKey, 'invalid JWK' if key.nil?
44
+ raise InvalidKey if key.nil?
45
45
 
46
- raise InvalidToken, 'expired JWT' unless Time.at(jwt[:exp]) > Time.now
46
+ exp = Time.at(jwt[:exp])
47
+ raise ExpiredToken, "Token expired at #{exp}" unless exp > Time.now
47
48
 
48
49
  jwt.verify!(key)
49
50
  end
50
51
  rescue JSON::JWT::UnexpectedAlgorithm, JSON::JWT::VerificationFailed
51
- raise InvalidToken, 'failed to validate token against JWK'
52
+ raise InvalidToken, 'Failed to validate token against JWK'
52
53
  rescue OpenSSL::PKey::PKeyError
53
- raise InvalidKey, 'invalid JWK'
54
+ raise InvalidKey
54
55
  end
55
56
 
56
57
  # Decodes and does basic validation of JWT.
@@ -59,13 +60,13 @@ module Authentic
59
60
  #
60
61
  # Returns JSON::JWT
61
62
  def decode_jwt(token)
62
- raise InvalidToken, 'invalid nil JWT provided' unless token
63
+ raise InvalidToken, 'JWT was nil' unless token
63
64
 
64
65
  JSON::JWT.decode(token, :skip_verification).tap do |jwt|
65
66
  raise InvalidToken, 'JWT iss was not located in provided whitelist' unless iss_whitelist.include?(jwt[:iss])
66
67
  end
67
68
  rescue JSON::JWT::InvalidFormat
68
- raise InvalidToken, 'invalid JWT format'
69
+ raise InvalidToken, 'JWT was in an invalid format'
69
70
  end
70
71
  end
71
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authentic-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Articulate
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-25 00:00:00.000000000 Z
12
+ date: 2019-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json-jwt
@@ -35,14 +35,14 @@ dependencies:
35
35
  name: rest-client
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.0'
48
48
  description: Ruby toolkit for Auth0 API https://auth0.com.