fb-jwt-auth 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fb/jwt/auth.rb +10 -2
- data/lib/fb/jwt/auth/service_token_client.rb +9 -2
- data/lib/fb/jwt/auth/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: 809db265860e3142598f429c53482e4b642543717c83cab5c6fbe46fd4834ee5
|
4
|
+
data.tar.gz: a26191f1f776d29b42f3095f4ae9c9dca20d032ab31f8add3efd7dbca99239a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c86735004359b8c7b0261808d0bf90ed5b7ebd56cca83f83dcbb950c1894825df06051c8fc85f23ceef3c6cc79c16a05fd1cd293676d80832dd3e2c3843e1f6
|
7
|
+
data.tar.gz: 318864900ac94c5f51c1e781ba5aa9b990604acb85084db810144963cb93941465b7428931dafd71d0918343d4cb925778b16b3a5c8bc48899373923332d6317
|
data/lib/fb/jwt/auth.rb
CHANGED
@@ -44,8 +44,7 @@ module Fb
|
|
44
44
|
application_details = find_application_info
|
45
45
|
|
46
46
|
begin
|
47
|
-
|
48
|
-
payload, _header = decode(hmac_secret: hmac_secret)
|
47
|
+
payload, _header = retrieve_and_decode_public_key(application_details)
|
49
48
|
rescue StandardError => e
|
50
49
|
error_message = "Token is not valid: error #{e}"
|
51
50
|
logger.debug(error_message)
|
@@ -67,6 +66,15 @@ module Fb
|
|
67
66
|
payload
|
68
67
|
end
|
69
68
|
|
69
|
+
def retrieve_and_decode_public_key(application_details)
|
70
|
+
hmac_secret = public_key(application_details)
|
71
|
+
decode(hmac_secret: hmac_secret)
|
72
|
+
rescue JWT::VerificationError
|
73
|
+
logger.debug('First validation failed. Requesting non cached public key')
|
74
|
+
hmac_secret = public_key(application_details.merge(ignore_cache: true))
|
75
|
+
decode(hmac_secret: hmac_secret)
|
76
|
+
end
|
77
|
+
|
70
78
|
def decode(verify: true, hmac_secret: nil)
|
71
79
|
JWT.decode(
|
72
80
|
token,
|
@@ -12,9 +12,10 @@ class Fb::Jwt::Auth::ServiceTokenClient
|
|
12
12
|
|
13
13
|
attr_accessor :application, :namespace, :root_url, :api_version
|
14
14
|
|
15
|
-
def initialize(application:, namespace: nil)
|
15
|
+
def initialize(application:, namespace: nil, ignore_cache: false)
|
16
16
|
@application = application
|
17
17
|
@namespace = namespace
|
18
|
+
@ignore_cache = ignore_cache
|
18
19
|
@root_url = Fb::Jwt::Auth.service_token_cache_root_url
|
19
20
|
@api_version = Fb::Jwt::Auth.service_token_cache_api_version || :v2
|
20
21
|
end
|
@@ -38,8 +39,14 @@ class Fb::Jwt::Auth::ServiceTokenClient
|
|
38
39
|
|
39
40
|
private
|
40
41
|
|
42
|
+
attr_reader :ignore_cache
|
43
|
+
|
41
44
|
def public_key_uri
|
42
|
-
URI.join(root_url, version_url)
|
45
|
+
URI.join(root_url, "#{version_url}#{query_param}")
|
46
|
+
end
|
47
|
+
|
48
|
+
def query_param
|
49
|
+
ignore_cache ? '?ignore_cache=true' : ''
|
43
50
|
end
|
44
51
|
|
45
52
|
def version_url
|
data/lib/fb/jwt/auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb-jwt-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Form builder developers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|