serverless_hub 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/serverless_hub/authorizer.rb +10 -12
- data/lib/serverless_hub/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: 177475ce9c6adc854659629d205b95a4d3c78edf1886dc46171295e751a37e3d
|
4
|
+
data.tar.gz: 6f01099bd3c81e69822f6c7033d9d965061a2ba877cc21c1726d0a1d843ddf40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79b3f5812265befdede9ace1f907616caf24bcbbce23b95fb0d7f5f10600f53498918a701c3077298c93a59836689a3f95ff6436ff88c1b60b15d8e6e2be9eba
|
7
|
+
data.tar.gz: bd3d82b323ff8e54adb376e53f90f6154206bc57d1302b9ee03ce8275646817b0498322d7f60bda5421eb9f5948260c55e4b8a9a7d931dbc2fb7216d29c22376
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "jwt"
|
2
|
+
require "json/jwt"
|
3
3
|
require "rest-client"
|
4
4
|
|
5
5
|
module ServerlessHub
|
@@ -17,7 +17,7 @@ module ServerlessHub
|
|
17
17
|
|
18
18
|
env["lambda.event"]["requestContext"]["authorizer"] = {
|
19
19
|
"principalId" => claims["sub"],
|
20
|
-
"claims" => claims
|
20
|
+
"claims" => claims,
|
21
21
|
}
|
22
22
|
end
|
23
23
|
end
|
@@ -26,16 +26,14 @@ module ServerlessHub
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.jwks
|
29
|
-
RestClient.get(ENV["JWKS_URL"] ||
|
29
|
+
RestClient.get(ENV["JWKS_URL"] || "")
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
33
|
-
def decoded_token(token)
|
34
|
-
if token.present? && token.starts_with?("Bearer ")
|
35
|
-
token = token[7, token.length]
|
36
|
-
end
|
37
33
|
|
38
|
-
|
34
|
+
def decoded_token(token)
|
35
|
+
token = token.split(" ").last
|
36
|
+
JWT.decode token, jwk_set.first.to_key, true, { algorithm: "RS256" } rescue ""
|
39
37
|
end
|
40
38
|
|
41
39
|
def jwk_set
|
@@ -46,17 +44,17 @@ module ServerlessHub
|
|
46
44
|
)
|
47
45
|
end
|
48
46
|
end
|
49
|
-
|
47
|
+
|
50
48
|
class Authorizer
|
51
49
|
def initialize(app)
|
52
50
|
@app = app
|
53
51
|
end
|
54
|
-
|
52
|
+
|
55
53
|
def call(env)
|
56
54
|
if env["lambda.event"] && env["lambda.event"]["requestContext"]
|
57
55
|
env["authorizer"] = env["lambda.event"]["requestContext"]["authorizer"]
|
58
56
|
end
|
59
|
-
|
57
|
+
|
60
58
|
return @app.call(env)
|
61
59
|
end
|
62
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverless_hub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11
|
11
|
+
date: 2019-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|