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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fac4f1891d7675a09081e34baeba18381934055394ef4ac234d1108eeed810e
4
- data.tar.gz: f37541b94928f6d996f1684d011d1cc21d0a404908c253aea071bfd9816e53f8
3
+ metadata.gz: 177475ce9c6adc854659629d205b95a4d3c78edf1886dc46171295e751a37e3d
4
+ data.tar.gz: 6f01099bd3c81e69822f6c7033d9d965061a2ba877cc21c1726d0a1d843ddf40
5
5
  SHA512:
6
- metadata.gz: d810a8a3f64f9e3b8434617c71e4cc6a7199cd2c748338a0a7a8de556f7ca6f972d1716be53c62ee31ff28983ae53d6d0b0171e0d9150a26a274437f55c71927
7
- data.tar.gz: 7f09b1ac89cf1d408f8b97bcd47100c69d960e28fa92c4d910304ea8d12d33a497062cea0ed649e593a6529f75fdad5281072e5952bbe808ef36d28d5baf906d
6
+ metadata.gz: 79b3f5812265befdede9ace1f907616caf24bcbbce23b95fb0d7f5f10600f53498918a701c3077298c93a59836689a3f95ff6436ff88c1b60b15d8e6e2be9eba
7
+ data.tar.gz: bd3d82b323ff8e54adb376e53f90f6154206bc57d1302b9ee03ce8275646817b0498322d7f60bda5421eb9f5948260c55e4b8a9a7d931dbc2fb7216d29c22376
@@ -1,5 +1,5 @@
1
- require 'jwt'
2
- require 'json/jwt'
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
- JWT.decode token, jwk_set.first.to_key, true, { algorithm: 'RS256' } rescue ""
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
@@ -1,3 +1,3 @@
1
1
  module ServerlessHub
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  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
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-21 00:00:00.000000000 Z
11
+ date: 2019-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler