lib/serverless_hub/authorizer.rb in serverless_hub-1.0.10 vs lib/serverless_hub/authorizer.rb in serverless_hub-1.1.1

- old
+ new

@@ -30,11 +30,20 @@ end private def decoded_token(token) - token = token.split(" ").last - JWT.decode token, jwk_set.first.to_key, true, { algorithm: "RS256" } rescue "" + token = token.strip + if token.include? ' ' + token = token.split(" ").last + end + decoded = JWT.decode token, jwk_set.first.to_key, false, { algorithm: "RS256" } + key_id = decoded[1]['kid'] + key = jwk_set.find { |key_obj| key_obj['kid'] == key_id } + if key == nil + return "" + end + JWT.decode token, key.to_key, true, { algorithm: "RS256" } rescue "" end def jwk_set @jwk_set ||= JSON::JWK::Set.new( JSON.parse(