jwt 2.1.0 → 2.2.0.pre.beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -1
  3. data/.travis.yml +9 -3
  4. data/AUTHORS +84 -0
  5. data/Appraisals +14 -0
  6. data/CHANGELOG.md +77 -8
  7. data/README.md +96 -85
  8. data/lib/jwt.rb +9 -42
  9. data/lib/jwt/algos/ecdsa.rb +1 -1
  10. data/lib/jwt/algos/ps.rb +43 -0
  11. data/lib/jwt/base64.rb +19 -0
  12. data/lib/jwt/claims_validator.rb +33 -0
  13. data/lib/jwt/decode.rb +76 -25
  14. data/lib/jwt/encode.rb +42 -25
  15. data/lib/jwt/error.rb +16 -12
  16. data/lib/jwt/json.rb +18 -0
  17. data/lib/jwt/jwk.rb +31 -0
  18. data/lib/jwt/jwk/key_finder.rb +57 -0
  19. data/lib/jwt/jwk/rsa.rb +45 -0
  20. data/lib/jwt/security_utils.rb +6 -0
  21. data/lib/jwt/signature.rb +2 -0
  22. data/lib/jwt/verify.rb +1 -5
  23. data/lib/jwt/version.rb +3 -3
  24. data/ruby-jwt.gemspec +6 -3
  25. metadata +44 -58
  26. data/.reek.yml +0 -40
  27. data/Manifest +0 -8
  28. data/spec/fixtures/certs/ec256-private.pem +0 -8
  29. data/spec/fixtures/certs/ec256-public.pem +0 -4
  30. data/spec/fixtures/certs/ec256-wrong-private.pem +0 -8
  31. data/spec/fixtures/certs/ec256-wrong-public.pem +0 -4
  32. data/spec/fixtures/certs/ec384-private.pem +0 -9
  33. data/spec/fixtures/certs/ec384-public.pem +0 -5
  34. data/spec/fixtures/certs/ec384-wrong-private.pem +0 -9
  35. data/spec/fixtures/certs/ec384-wrong-public.pem +0 -5
  36. data/spec/fixtures/certs/ec512-private.pem +0 -10
  37. data/spec/fixtures/certs/ec512-public.pem +0 -6
  38. data/spec/fixtures/certs/ec512-wrong-private.pem +0 -10
  39. data/spec/fixtures/certs/ec512-wrong-public.pem +0 -6
  40. data/spec/fixtures/certs/rsa-1024-private.pem +0 -15
  41. data/spec/fixtures/certs/rsa-1024-public.pem +0 -6
  42. data/spec/fixtures/certs/rsa-2048-private.pem +0 -27
  43. data/spec/fixtures/certs/rsa-2048-public.pem +0 -9
  44. data/spec/fixtures/certs/rsa-2048-wrong-private.pem +0 -27
  45. data/spec/fixtures/certs/rsa-2048-wrong-public.pem +0 -9
  46. data/spec/fixtures/certs/rsa-4096-private.pem +0 -51
  47. data/spec/fixtures/certs/rsa-4096-public.pem +0 -14
  48. data/spec/integration/readme_examples_spec.rb +0 -202
  49. data/spec/jwt/verify_spec.rb +0 -232
  50. data/spec/jwt_spec.rb +0 -315
  51. data/spec/spec_helper.rb +0 -28
@@ -1,4 +0,0 @@
1
- -----BEGIN PUBLIC KEY-----
2
- MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAr+WbDE5VtIDGhtYMxvEc6cMsDBc
3
- /DX1wuhIMu8dQzOLSt0tpqK9MVfXbVfrKdayVFgoWzs8MilcYq0QIhKx/w==
4
- -----END PUBLIC KEY-----
@@ -1,8 +0,0 @@
1
- -----BEGIN EC PARAMETERS-----
2
- BgUrgQQACg==
3
- -----END EC PARAMETERS-----
4
- -----BEGIN EC PRIVATE KEY-----
5
- MHQCAQEEICfA4AaomONdmPTzeyrx5U/jugYXTERyb5U3ETTv7Hx7oAcGBSuBBAAK
6
- oUQDQgAEPmuXZT3jpJnEMVPOW6RMsmxeGLOCE1PN6fwvUwOsxv7YnyoQ5/bpo64n
7
- +Jp4slSl1aUNoCBF2oz9bS0iyBo3jg==
8
- -----END EC PRIVATE KEY-----
@@ -1,4 +0,0 @@
1
- -----BEGIN PUBLIC KEY-----
2
- MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEPmuXZT3jpJnEMVPOW6RMsmxeGLOCE1PN
3
- 6fwvUwOsxv7YnyoQ5/bpo64n+Jp4slSl1aUNoCBF2oz9bS0iyBo3jg==
4
- -----END PUBLIC KEY-----
@@ -1,9 +0,0 @@
1
- -----BEGIN EC PARAMETERS-----
2
- BgUrgQQAIg==
3
- -----END EC PARAMETERS-----
4
- -----BEGIN EC PRIVATE KEY-----
5
- MIGkAgEBBDDxOljqUKw9YNhkluSJIBAYO1YXcNtS+vckd5hpTZ5toxsOlwbmyrnU
6
- Tn+D5Xma1m2gBwYFK4EEACKhZANiAASQwYTiRvXu1hMHceSosMs/8uf50sJI3jvK
7
- kdSkvuRAPxSzhtrUvCQDnVsThFq4aOdZZY1qh2ErJGtzmrx+pEsJvJnvfOTG3NGU
8
- KRalek+LQfVqAUSvDMKlxdkz2e67tso=
9
- -----END EC PRIVATE KEY-----
@@ -1,5 +0,0 @@
1
- -----BEGIN PUBLIC KEY-----
2
- MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEkMGE4kb17tYTB3HkqLDLP/Ln+dLCSN47
3
- ypHUpL7kQD8Us4ba1LwkA51bE4RauGjnWWWNaodhKyRrc5q8fqRLCbyZ73zkxtzR
4
- lCkWpXpPi0H1agFErwzCpcXZM9nuu7bK
5
- -----END PUBLIC KEY-----
@@ -1,9 +0,0 @@
1
- -----BEGIN EC PARAMETERS-----
2
- BgUrgQQAIg==
3
- -----END EC PARAMETERS-----
4
- -----BEGIN EC PRIVATE KEY-----
5
- MIGkAgEBBDAfZW47dSKnC5JkSVOk1ERxCIi/IJ1p1WBnVGx4hnrNHy+dxtaZJaF+
6
- YLInFQ/QbYegBwYFK4EEACKhZANiAAQwXkx4BFBGLXbzl5yVrfxK7er8hSi38iDE
7
- K2+7cdrR137Wn5JUnL4WTwXTzkyUgfBOL3sHNozwfgU03GD/EOUEKqzsIJiz2cbP
8
- bFALd4hS+8T4szDLVC9Jl1W6k0CAtmM=
9
- -----END EC PRIVATE KEY-----
@@ -1,5 +0,0 @@
1
- -----BEGIN PUBLIC KEY-----
2
- MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEMF5MeARQRi1285ecla38Su3q/IUot/Ig
3
- xCtvu3Ha0dd+1p+SVJy+Fk8F085MlIHwTi97BzaM8H4FNNxg/xDlBCqs7CCYs9nG
4
- z2xQC3eIUvvE+LMwy1QvSZdVupNAgLZj
5
- -----END PUBLIC KEY-----
@@ -1,10 +0,0 @@
1
- -----BEGIN EC PARAMETERS-----
2
- BgUrgQQAIw==
3
- -----END EC PARAMETERS-----
4
- -----BEGIN EC PRIVATE KEY-----
5
- MIHcAgEBBEIB0/+ffxEj7j62xvGaB5pvzk888e412ESO/EK/K0QlS9dSF8+Rj1rG
6
- zqpRB8fvDnoe8xdmkW/W5GKzojMyv7YQYumgBwYFK4EEACOhgYkDgYYABAEw74Yw
7
- aTbPY6TtWmxx6LJDzCX2nKWCPnKdZcEH9Ncu8g5RjRBRq2yacja3OoS6nA2YeDng
8
- reBJxZr376P6Ns6XcQFWDA6K/MCTrEBCsPxXZNxd8KR9vMGWhgNtWRrcKzwJfQkr
9
- suyehZkbbYyFnAWyARKHZuV7VUXmeEmRS/f93MPqVA==
10
- -----END EC PRIVATE KEY-----
@@ -1,6 +0,0 @@
1
- -----BEGIN PUBLIC KEY-----
2
- MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBMO+GMGk2z2Ok7VpsceiyQ8wl9pyl
3
- gj5ynWXBB/TXLvIOUY0QUatsmnI2tzqEupwNmHg54K3gScWa9++j+jbOl3EBVgwO
4
- ivzAk6xAQrD8V2TcXfCkfbzBloYDbVka3Cs8CX0JK7LsnoWZG22MhZwFsgESh2bl
5
- e1VF5nhJkUv3/dzD6lQ=
6
- -----END PUBLIC KEY-----
@@ -1,10 +0,0 @@
1
- -----BEGIN EC PARAMETERS-----
2
- BgUrgQQAIw==
3
- -----END EC PARAMETERS-----
4
- -----BEGIN EC PRIVATE KEY-----
5
- MIHbAgEBBEG/KbA2oCbiCT6L3V8XSz2WKBy0XhGvIFbl/ZkXIXnkYt+1B7wViSVo
6
- KCHuMFsi6xU/5nE1EuDG2UsQJmKeAMkIOKAHBgUrgQQAI6GBiQOBhgAEAG0TFWe5
7
- cZ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r8
10
- 9v23rhydvCe1ERPYe7EjF4RGWVPN3KLdExcCQDdzNfL3BApMS97OkoRQQC/nXbjU
11
- 2SPlN1MqVQuGCG8pqGG0V40h11y1CkvxMS10ldEojq77SOrwFnZUsXGS82sCQQC6
12
- XdO7QCaxSq5XIRYlHN4EtS40NLOIYy3/LK6osHel4GIyTVd+UjSLk0QzssJxqwln
13
- V5TqWQO0cxPcLQiFUYEZAkEA2G84ilb9QXOgbNyoE1VifNk49hhodbSskLb86uwY
14
- Vgtzq1ZsqoPBCasr4WRiXt270n+mo5dNYRlZwiUn9lH78Q==
15
- -----END RSA PRIVATE KEY-----
@@ -1,6 +0,0 @@
1
- -----BEGIN PUBLIC KEY-----
2
- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDO/ahgFDvniFoQ1dm+MdnkBi+T
3
- s5W9AtQNgw4ZHIdPnqEzSgW70opKEu8hnlLqsIyU2BC2op/xOanipdbXObuFlA6b
4
- th1cYRI+YJlR3BbPGOIL6YbJud9m0gIsBlCDLm4e/E45ZS+emudISP7/SF7zxvxZ
5
- lnr1z7HTm7nIIVBvuQIDAQAB
6
- -----END PUBLIC KEY-----
@@ -1,27 +0,0 @@
1
- -----BEGIN RSA PRIVATE KEY-----
2
- MIIEpAIBAAKCAQEA4GzZTLU48c4WbyvHi+QKrB71x+T0eq5hqDbQqnlYjhD1Ika7
3
- io1iplsdJWJuyxfYbUkb2Ol0fj4koZ/GS6lgCZr4+8UHbr1qf0Eu5HZSpszs2YxY
4
- 8U5RHnrpw67co7hlgAR9HbyNf5XIYgLV9ldHH/eazwnc3F/hgNsV0xjScVilejgo
5
- cJ4zcsyymvW8t42lteM7bI867ZuJhGop/V+Y0HFyrMsPoQyLuCUpr6ulOfrkr7ZO
6
- dhAIG8r1HcjOp/AUjM15vfXcbUZjkM/VloifX1YitU3upMGJ8/DpFGffMOImrn5r
7
- 6BT494V8rRyN2qvQoAkLJpqZ0avLxwiR2lgVQQIDAQABAoIBAEH0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Eaqc4oRGGPOSTaTK63PQ0TXOb8k0pTD7l0CtYSWMFwzkXCoLGYbeCi
23
- vqd5tqDRLAe7QxYa9rl5pSUqptMrGeeNATZa6sya4H5Hp5oCyny8n54z/OJh7ZRq
24
- W0TwwQKBgQDDP7ksm2pcqadaVAmODdOlaDHbaEcxp8wN7YVz0lM3UpJth96ukbj7
25
- S39eJhXYWOn6oJQb/lN9fGOYqjg3y6IchGZDp67ATvWYvn/NY0R7mt4K4oHx5TuN
26
- rSQlP3WmOGv8Kemw892uRfW/jZyBEHhsfS213WDttVPn9F635GdNWw==
27
- -----END RSA PRIVATE KEY-----
@@ -1,9 +0,0 @@
1
- -----BEGIN PUBLIC KEY-----
2
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzHAVGaW9j4l3/b4ngcjj
3
- oIoIcnsQEWOMqErb5VhLZMGIq1gEO5qxPDAwooKsNotzcAOB3ZyLn7p5D+dmOrNU
4
- YkYWgYITNGeSifrnVqQugd5Fh1L8K7zOGltUo2UtjbN4uJ56tzxBMZp2wejs2/Qu
5
- 0eu0xZK3To+YkDcWOk92rmNgmUSQC/kNyIOj+yBvOo3wTk6HvbhoIarCgJ6Lay1v
6
- /hMLyQLzwRY/Qfty1FTIDyTv2dch47FsfkZ1KAL+MbUnHuCBPzGxRjXa8Iy9Z7YG
7
- xrYasUt1b0um64bscxoIiCu8yLL8jlg01Rwrjr/MTwKRhwXlMp8B7HTonwtaG6ar
8
- JwIDAQAB
9
- -----END PUBLIC KEY-----
@@ -1,51 +0,0 @@
1
- -----BEGIN RSA PRIVATE KEY-----
2
- MIIJJwIBAAKCAgEAqETmgWBi5rCmb7euJplA/9xs65+bncc9Yvs5zjyycXSW82Jf
3
- RuyguGm0OvA2wog24dR4N2kT/87DcGtp5JqJWADVFNr+2V2r6i57/OMLruRpn3p2
4
- r95dmo0COE+BxPFl7XEBT8JbH57ZtpgcB3/xkS14nLOWFf96hrXPlXJC+VMVKVZm
5
- A8k2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YXeCeEXc197PTmb9H67jos8nhauqOoW/qaMJK2M9D
37
- tCubLUNf3eAT14R16CHNP93qnUE/TSeXQ3JsIofne0neb47u4F6zcuzvaNEbjSEn
38
- HJqID7sw5GoA6WQo0I+yqWAXICMXmHf/gtYfxGHEFeSUwexULH5BKG1R8sncw7J0
39
- Ag3h8xkGrNON4SkcTLy8Iay/eS6YxRcKndo4mk2mU65tr77TX4xi3Z/jWkQLY5WO
40
- eJwhAoIBABO17wkSxyGDjJ/fDfpsE3bDmgRV2KuBHoqqOBvXH26sM7ghXLZKjT4o
41
- 5ooqXmTYJm91GIjYs71exnkr8hDW9L4nbEuxOgeSVyRg69H+NMshOaQ8sE8GDJxO
42
- wgsnAyY4Vq6UomwYW/E0RL/AxRezM/nZGaVzgo3qgLJXP4MwbOQm7hMq1FD2LQuW
43
- PDhH3Ty+kA5ca97W0Asd/3k+Pi0pNDvdZUOj8e7E369cKoTcKAdPGGsQ8aILhsCd
44
- q3EUTKwwDl8+KrH9utBJPejQzeTjfBVo/xH6q145QeVFcy9ku/zQN3M9p5vQMEuX
45
- j1lBMTkpTFw7uYBE2idyHw5BJoZsWQcCggEADfZTChqnOncItSflzGoaAACrr4/x
46
- KyT/4A+cPMCs11JN9J+EWsCezya2o1l/NF7YPcBR4qjCmFMEiq5GxH5fGLQp0aa7
47
- V13mHA8XBQ25OW2K7BGJhMHdbuvTnl6jsOfC4+t7P2bUAYxoP6/ncxTzZ5OlBN5k
48
- aMv9firWl1kSKK75ww9DWn6j0rQ4dBetwX45EMcs+iKIdydg0fmJxR2EJ+uQsCFy
49
- xcWBEDqV7qLUi6UrAPL3v/DXUv9wKcKOTbKw/aNE8+YTWMUO330GCJ5cVU1eTL5t
50
- UrcNKOJkFIj7jJUCzv6vcy++hMJEbNXnnTVRnky6e9C2vwzMl33njntapg==
51
- -----END RSA PRIVATE KEY-----
@@ -1,14 +0,0 @@
1
- -----BEGIN PUBLIC KEY-----
2
- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAqETmgWBi5rCmb7euJplA
3
- /9xs65+bncc9Yvs5zjyycXSW82JfRuyguGm0OvA2wog24dR4N2kT/87DcGtp5JqJ
4
- WADVFNr+2V2r6i57/OMLruRpn3p2r95dmo0COE+BxPFl7XEBT8JbH57ZtpgcB3/x
5
- kS14nLOWFf96hrXPlXJC+VMVKVZmA8k2LRh42vT5wUf4U0Doy/p7yFNSFFa6Q8ww
6
- e4TBy/z/f+rhFD1w8rxlYjallee/ocm7bjZCwbJGMm7orLViqWfsFX3O35PeoJ5h
7
- /7uJ7iRwvTFERkTdwWP/0BeKBeItBR3YFc2mut+V9W+WKRkMSL6Crc+oVSx3p8aB
8
- 7j9SZFzQiRtes4BYETpX1xl2mgIq5hvsFbLw7ESrlIodiwUMTrSIid2DQ6q80kv1
9
- zXPr4+Id6L0sJLxPCaXnTmNtasSwyedJJYxLjwhHJwtzFAeaq18H3O791YKhjAJ6
10
- YxK3zJ59jTE6Pkvqjq183f2PGHVRvgSN7aCmI6MBUUB5wDP2K8zX2sh40/uPDVSd
11
- 6ei1vl3DpPk+h8iExx6AzbohfqZ+5RUUNx127L3MaQvOVC5TxV+R99gwKW++wzcV
12
- uO3m2KqVUj+K1uYBy3KBCUMBbckpEWGbN++jcdV5oJX6fsC66nOmKlntYwCL/pRw
13
- w+oLsbzF8J3dxeDbKNF9JDsCAwEAAQ==
14
- -----END PUBLIC KEY-----
@@ -1,202 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../spec_helper'
4
- require 'jwt'
5
-
6
- describe 'README.md code test' do
7
- context 'algorithm usage' do
8
- let(:payload) { { data: 'test' } }
9
-
10
- it 'NONE' do
11
- token = JWT.encode payload, nil, 'none'
12
- decoded_token = JWT.decode token, nil, false
13
-
14
- expect(token).to eq 'eyJhbGciOiJub25lIn0.eyJkYXRhIjoidGVzdCJ9.'
15
- expect(decoded_token).to eq [
16
- { 'data' => 'test' },
17
- { 'alg' => 'none' }
18
- ]
19
- end
20
-
21
- it 'HMAC' do
22
- token = JWT.encode payload, 'my$ecretK3y', 'HS256'
23
- decoded_token = JWT.decode token, 'my$ecretK3y', false
24
-
25
- expect(token).to eq 'eyJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoidGVzdCJ9.pNIWIL34Jo13LViZAJACzK6Yf0qnvT_BuwOxiMCPE-Y'
26
- expect(decoded_token).to eq [
27
- { 'data' => 'test' },
28
- { 'alg' => 'HS256' }
29
- ]
30
- end
31
-
32
- it 'RSA' do
33
- rsa_private = OpenSSL::PKey::RSA.generate 2048
34
- rsa_public = rsa_private.public_key
35
-
36
- token = JWT.encode payload, rsa_private, 'RS256'
37
- decoded_token = JWT.decode token, rsa_public, true, algorithm: 'RS256'
38
-
39
- expect(decoded_token).to eq [
40
- { 'data' => 'test' },
41
- { 'alg' => 'RS256' }
42
- ]
43
- end
44
-
45
- it 'ECDSA' do
46
- ecdsa_key = OpenSSL::PKey::EC.new 'prime256v1'
47
- ecdsa_key.generate_key
48
- ecdsa_public = OpenSSL::PKey::EC.new ecdsa_key
49
- ecdsa_public.private_key = nil
50
-
51
- token = JWT.encode payload, ecdsa_key, 'ES256'
52
- decoded_token = JWT.decode token, ecdsa_public, true, algorithm: 'ES256'
53
-
54
- expect(decoded_token).to eq [
55
- { 'data' => 'test' },
56
- { 'alg' => 'ES256' }
57
- ]
58
- end
59
- end
60
-
61
- context 'claims' do
62
- let(:hmac_secret) { 'MyP4ssW0rD' }
63
-
64
- context 'exp' do
65
- it 'without leeway' do
66
- exp = Time.now.to_i + 4 * 3600
67
- exp_payload = { data: 'data', exp: exp }
68
-
69
- token = JWT.encode exp_payload, hmac_secret, 'HS256'
70
-
71
- expect do
72
- JWT.decode token, hmac_secret, true, algorithm: 'HS256'
73
- end.not_to raise_error
74
- end
75
-
76
- it 'with leeway' do
77
- exp = Time.now.to_i - 10
78
- leeway = 30 # seconds
79
-
80
- exp_payload = { data: 'data', exp: exp }
81
-
82
- token = JWT.encode exp_payload, hmac_secret, 'HS256'
83
-
84
- expect do
85
- JWT.decode token, hmac_secret, true, leeway: leeway, algorithm: 'HS256'
86
- end.not_to raise_error
87
- end
88
- end
89
-
90
- context 'nbf' do
91
- it 'without leeway' do
92
- nbf = Time.now.to_i - 3600
93
- nbf_payload = { data: 'data', nbf: nbf }
94
- token = JWT.encode nbf_payload, hmac_secret, 'HS256'
95
-
96
- expect do
97
- JWT.decode token, hmac_secret, true, algorithm: 'HS256'
98
- end.not_to raise_error
99
- end
100
-
101
- it 'with leeway' do
102
- nbf = Time.now.to_i + 10
103
- leeway = 30
104
- nbf_payload = { data: 'data', nbf: nbf }
105
- token = JWT.encode nbf_payload, hmac_secret, 'HS256'
106
-
107
- expect do
108
- JWT.decode token, hmac_secret, true, leeway: leeway, algorithm: 'HS256'
109
- end.not_to raise_error
110
- end
111
- end
112
-
113
- it 'iss' do
114
- iss = 'My Awesome Company Inc. or https://my.awesome.website/'
115
- iss_payload = { data: 'data', iss: iss }
116
-
117
- token = JWT.encode iss_payload, hmac_secret, 'HS256'
118
-
119
- expect do
120
- JWT.decode token, hmac_secret, true, iss: iss, algorithm: 'HS256'
121
- end.not_to raise_error
122
- end
123
-
124
- context 'aud' do
125
- it 'array' do
126
- aud = %w[Young Old]
127
- aud_payload = { data: 'data', aud: aud }
128
-
129
- token = JWT.encode aud_payload, hmac_secret, 'HS256'
130
-
131
- expect do
132
- JWT.decode token, hmac_secret, true, aud: %w[Old Young], verify_aud: true, algorithm: 'HS256'
133
- end.not_to raise_error
134
- end
135
-
136
- it 'string' do
137
- expect do
138
- end.not_to raise_error
139
- end
140
- end
141
-
142
- it 'jti' do
143
- iat = Time.now.to_i
144
- hmac_secret = 'test'
145
- jti_raw = [hmac_secret, iat].join(':').to_s
146
- jti = Digest::MD5.hexdigest(jti_raw)
147
- jti_payload = { data: 'data', iat: iat, jti: jti }
148
-
149
- token = JWT.encode jti_payload, hmac_secret, 'HS256'
150
-
151
- expect do
152
- JWT.decode token, hmac_secret, true, verify_jti: true, algorithm: 'HS256'
153
- end.not_to raise_error
154
- end
155
-
156
- context 'iat' do
157
- it 'without leeway' do
158
- iat = Time.now.to_i
159
- iat_payload = { data: 'data', iat: iat }
160
-
161
- token = JWT.encode iat_payload, hmac_secret, 'HS256'
162
-
163
- expect do
164
- JWT.decode token, hmac_secret, true, verify_iat: true, algorithm: 'HS256'
165
- end.not_to raise_error
166
- end
167
-
168
- it 'with leeway' do
169
- iat = Time.now.to_i - 7
170
- iat_payload = { data: 'data', iat: iat, leeway: 10 }
171
-
172
- token = JWT.encode iat_payload, hmac_secret, 'HS256'
173
-
174
- expect do
175
- JWT.decode token, hmac_secret, true, verify_iat: true, algorithm: 'HS256'
176
- end.not_to raise_error
177
- end
178
- end
179
-
180
- context 'custom header fields' do
181
- it 'with custom field' do
182
- payload = { data: 'test' }
183
-
184
- token = JWT.encode payload, nil, 'none', typ: 'JWT'
185
- _, header = JWT.decode token, nil, false
186
-
187
- expect(header['typ']).to eq 'JWT'
188
- end
189
- end
190
-
191
- it 'sub' do
192
- sub = 'Subject'
193
- sub_payload = { data: 'data', sub: sub }
194
-
195
- token = JWT.encode sub_payload, hmac_secret, 'HS256'
196
-
197
- expect do
198
- JWT.decode token, hmac_secret, true, 'sub' => sub, :verify_sub => true, :algorithm => 'HS256'
199
- end.not_to raise_error
200
- end
201
- end
202
- end