ruby_jwt 1.0.9 → 1.1.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
  SHA1:
3
- metadata.gz: c4cbb15c0565682d76db4fe78a7fe3319880f18c
4
- data.tar.gz: f5048fdf0dc03828571897565c1b04f430eefe74
3
+ metadata.gz: 7e38ce66749c2472c721f6a21231267f4cae483a
4
+ data.tar.gz: 7fee6ca4a796980f08c810df27d8e7677b8515ed
5
5
  SHA512:
6
- metadata.gz: cba160295a71a7c82d1c05f1f8989cff38e738092e4dd1d56b240a27342e134051f64c50e68b08a756960518bdfe3a54be8f36b854d99a0c61c8312b0669d7d5
7
- data.tar.gz: 5febbbe81750d6837c1187673d67ca0c2fc531701a0b2af28ed4d2feee1f3f5d17dd32584cd7f58c7ae7d4f2bb7fb414734c53191716cb17526ff8be064ee1a7
6
+ metadata.gz: 110764e7fa85906de5db32fad455dc4351fccb63baff36f7b942ffb2e0611f746aca0e8a93f916ae071d43e6a70b59820c7e35080f0cd94f2fddf31368f5203b
7
+ data.tar.gz: 0d0b9cbc8a5137209e9e90937c26b2fb4fe39e69d971066bffc823a4f09988ec6a98fa286b1caf8abbf7782da3f95ac1c2bf7e6d289cee6877f332cce4ded671
@@ -1,3 +1,3 @@
1
1
  module RubyJwt
2
- VERSION = "1.0.9"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/ruby_jwt.rb CHANGED
@@ -65,10 +65,11 @@ module JWT
65
65
  def verify(token,secret,options={})
66
66
  return VerificationResponse.new(false, "JWT cannot be blank") if !token or token.empty?
67
67
  jwt_parts = token.split(".")
68
- alg = json_decode_data(jwt_parts[0])[:alg]
68
+ jwt = decode(token)
69
+ alg = jwt.header[:alg]
69
70
  return VerificationResponse.new(false,"Key cannot be blank if algorithm is not 'none'") if(alg != "none" and !secret)
70
- payload = json_decode_data(jwt_parts[1])
71
- signature = base64urldecode(jwt_parts[2]) if alg != "none"
71
+ payload = jwt.payload
72
+ signature = base64urldecode(jwt.signature) if alg != "none"
72
73
  current_time = Time.now.to_i
73
74
  if(payload[:exp] and current_time >= payload[:exp])
74
75
  return VerificationResponse.new(false,"JWT is expired.")
@@ -89,7 +90,7 @@ module JWT
89
90
 
90
91
  return VerificationResponse.new(false,"JWT signature is invalid.") if !verify_signature(alg,secret,jwt_parts[0..1].join("."),signature)
91
92
 
92
- return VerificationResponse.new(true,"JWT is valid.",decode(token))
93
+ return VerificationResponse.new(true,"JWT is valid.",jwt)
93
94
  end
94
95
 
95
96
 
@@ -3936,5 +3936,135 @@ RubyJwtTest: test_should_encode_and_decode_and_verify_hmac
3936
3936
   (0.0ms) begin transaction
3937
3937
  -----------------------------------------------
3938
3938
  RubyJwtTest: test_should_encode_and_decode_none
3939
+ -----------------------------------------------
3940
+  (0.0ms) rollback transaction
3941
+  (0.1ms) begin transaction
3942
+ -----------------------------------------------------
3943
+ RubyJwtTest: test_decodes_and_verifies_existing_token
3944
+ -----------------------------------------------------
3945
+  (0.0ms) rollback transaction
3946
+  (0.0ms) begin transaction
3947
+ ---------------------------------------------------------
3948
+ RubyJwtTest: test_returns_decode_error_for_invalid_base64
3949
+ ---------------------------------------------------------
3950
+  (0.0ms) rollback transaction
3951
+  (0.0ms) begin transaction
3952
+ ---------------------------------------------
3953
+ RubyJwtTest: test_returns_false_if_before_nbf
3954
+ ---------------------------------------------
3955
+  (0.0ms) rollback transaction
3956
+  (0.0ms) begin transaction
3957
+ ------------------------------------------
3958
+ RubyJwtTest: test_returns_false_if_expired
3959
+ ------------------------------------------
3960
+  (0.0ms) rollback transaction
3961
+  (0.0ms) begin transaction
3962
+ ----------------------------------------------------
3963
+ RubyJwtTest: test_returns_false_if_invalid_signature
3964
+ ----------------------------------------------------
3965
+  (0.0ms) rollback transaction
3966
+  (0.0ms) begin transaction
3967
+ -------------------------------------------------
3968
+ RubyJwtTest: test_returns_false_if_wrong_audience
3969
+ -------------------------------------------------
3970
+  (0.0ms) rollback transaction
3971
+  (0.0ms) begin transaction
3972
+ -----------------------------------------------
3973
+ RubyJwtTest: test_returns_false_if_wrong_issuer
3974
+ -----------------------------------------------
3975
+  (0.0ms) rollback transaction
3976
+  (0.0ms) begin transaction
3977
+ -------------------------------------------------------------------------
3978
+ RubyJwtTest: test_returns_not_implemented_error_for_unsupported_algorithm
3979
+ -------------------------------------------------------------------------
3980
+  (0.0ms) rollback transaction
3981
+  (0.0ms) begin transaction
3982
+ -----------------------------------------------
3983
+ RubyJwtTest: test_returns_sign_error_for_no_key
3984
+ -----------------------------------------------
3985
+  (0.0ms) rollback transaction
3986
+  (0.0ms) begin transaction
3987
+ ------------------------------------------------
3988
+ RubyJwtTest: test_should_encode_and_decode_ECDSA
3989
+ ------------------------------------------------
3990
+  (0.0ms) rollback transaction
3991
+  (0.0ms) begin transaction
3992
+ ----------------------------------------------
3993
+ RubyJwtTest: test_should_encode_and_decode_RSA
3994
+ ----------------------------------------------
3995
+  (0.0ms) rollback transaction
3996
+  (0.0ms) begin transaction
3997
+ ----------------------------------------------------------
3998
+ RubyJwtTest: test_should_encode_and_decode_and_verify_hmac
3999
+ ----------------------------------------------------------
4000
+  (0.0ms) rollback transaction
4001
+  (0.0ms) begin transaction
4002
+ -----------------------------------------------
4003
+ RubyJwtTest: test_should_encode_and_decode_none
4004
+ -----------------------------------------------
4005
+  (0.0ms) rollback transaction
4006
+  (0.1ms) begin transaction
4007
+ -----------------------------------------------------
4008
+ RubyJwtTest: test_decodes_and_verifies_existing_token
4009
+ -----------------------------------------------------
4010
+  (0.0ms) rollback transaction
4011
+  (0.0ms) begin transaction
4012
+ ---------------------------------------------------------
4013
+ RubyJwtTest: test_returns_decode_error_for_invalid_base64
4014
+ ---------------------------------------------------------
4015
+  (0.0ms) rollback transaction
4016
+  (0.0ms) begin transaction
4017
+ ---------------------------------------------
4018
+ RubyJwtTest: test_returns_false_if_before_nbf
4019
+ ---------------------------------------------
4020
+  (0.1ms) rollback transaction
4021
+  (0.0ms) begin transaction
4022
+ ------------------------------------------
4023
+ RubyJwtTest: test_returns_false_if_expired
4024
+ ------------------------------------------
4025
+  (0.0ms) rollback transaction
4026
+  (0.0ms) begin transaction
4027
+ ----------------------------------------------------
4028
+ RubyJwtTest: test_returns_false_if_invalid_signature
4029
+ ----------------------------------------------------
4030
+  (0.0ms) rollback transaction
4031
+  (0.0ms) begin transaction
4032
+ -------------------------------------------------
4033
+ RubyJwtTest: test_returns_false_if_wrong_audience
4034
+ -------------------------------------------------
4035
+  (0.0ms) rollback transaction
4036
+  (0.0ms) begin transaction
4037
+ -----------------------------------------------
4038
+ RubyJwtTest: test_returns_false_if_wrong_issuer
4039
+ -----------------------------------------------
4040
+  (0.0ms) rollback transaction
4041
+  (0.0ms) begin transaction
4042
+ -------------------------------------------------------------------------
4043
+ RubyJwtTest: test_returns_not_implemented_error_for_unsupported_algorithm
4044
+ -------------------------------------------------------------------------
4045
+  (0.0ms) rollback transaction
4046
+  (0.0ms) begin transaction
4047
+ -----------------------------------------------
4048
+ RubyJwtTest: test_returns_sign_error_for_no_key
4049
+ -----------------------------------------------
4050
+  (0.0ms) rollback transaction
4051
+  (0.0ms) begin transaction
4052
+ ------------------------------------------------
4053
+ RubyJwtTest: test_should_encode_and_decode_ECDSA
4054
+ ------------------------------------------------
4055
+  (0.0ms) rollback transaction
4056
+  (0.0ms) begin transaction
4057
+ ----------------------------------------------
4058
+ RubyJwtTest: test_should_encode_and_decode_RSA
4059
+ ----------------------------------------------
4060
+  (0.0ms) rollback transaction
4061
+  (0.0ms) begin transaction
4062
+ ----------------------------------------------------------
4063
+ RubyJwtTest: test_should_encode_and_decode_and_verify_hmac
4064
+ ----------------------------------------------------------
4065
+  (0.0ms) rollback transaction
4066
+  (0.0ms) begin transaction
4067
+ -----------------------------------------------
4068
+ RubyJwtTest: test_should_encode_and_decode_none
3939
4069
  -----------------------------------------------
3940
4070
   (0.0ms) rollback transaction
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_jwt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Weston