itsi-server 0.1.13 → 0.1.14
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 +4 -4
- data/Cargo.lock +20 -515
- data/ext/itsi_server/Cargo.toml +1 -1
- data/ext/itsi_server/src/server/middleware_stack/middlewares/auth_jwt.rs +111 -168
- data/lib/itsi/server/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b713c8d83848f636422950aa7c89d62edd41e8f0455625a0ab935151b6bc4adc
|
4
|
+
data.tar.gz: af94fbd39cf1797bebc930520958bf4f34e7c071cc026271ae6c7b593d572b1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5a5a75089e98efded82954a4582217313f89c7d50e2f166ecce7165336c6ee2b79bf658e9eb5730ce11169c88d2693c33264ff0ebaf70640dc1912770c69de7
|
7
|
+
data.tar.gz: 786a18a2e7c0e89dad58e789dba54f54fa2285981e19fd399306f2b2eed22aa4fb52fdf7164004b39afe60d5db0b2b7047101e3fc7343f7f34aad70b56a10167
|
data/Cargo.lock
CHANGED
@@ -56,30 +56,12 @@ dependencies = [
|
|
56
56
|
"libc",
|
57
57
|
]
|
58
58
|
|
59
|
-
[[package]]
|
60
|
-
name = "anyhow"
|
61
|
-
version = "1.0.97"
|
62
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
63
|
-
checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
|
64
|
-
|
65
59
|
[[package]]
|
66
60
|
name = "arc-swap"
|
67
61
|
version = "1.7.1"
|
68
62
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
69
63
|
checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
|
70
64
|
|
71
|
-
[[package]]
|
72
|
-
name = "arrayref"
|
73
|
-
version = "0.3.9"
|
74
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
75
|
-
checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
|
76
|
-
|
77
|
-
[[package]]
|
78
|
-
name = "arrayvec"
|
79
|
-
version = "0.7.6"
|
80
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
81
|
-
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
82
|
-
|
83
65
|
[[package]]
|
84
66
|
name = "asn1-rs"
|
85
67
|
version = "0.6.2"
|
@@ -198,7 +180,7 @@ version = "0.26.0"
|
|
198
180
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
199
181
|
checksum = "0f9dd2e03ee80ca2822dd6ea431163d2ef259f2066a4d6ccaca6d9dcb386aa43"
|
200
182
|
dependencies = [
|
201
|
-
"bindgen
|
183
|
+
"bindgen",
|
202
184
|
"cc",
|
203
185
|
"cmake",
|
204
186
|
"dunce",
|
@@ -230,24 +212,12 @@ dependencies = [
|
|
230
212
|
"windows-targets 0.52.6",
|
231
213
|
]
|
232
214
|
|
233
|
-
[[package]]
|
234
|
-
name = "base16ct"
|
235
|
-
version = "0.2.0"
|
236
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
237
|
-
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
|
238
|
-
|
239
215
|
[[package]]
|
240
216
|
name = "base64"
|
241
217
|
version = "0.22.1"
|
242
218
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
243
219
|
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
244
220
|
|
245
|
-
[[package]]
|
246
|
-
name = "base64ct"
|
247
|
-
version = "1.7.3"
|
248
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
249
|
-
checksum = "89e25b6adfb930f02d1981565a6e5d9c547ac15a96606256d3b59040e5cd4ca3"
|
250
|
-
|
251
221
|
[[package]]
|
252
222
|
name = "bindgen"
|
253
223
|
version = "0.69.5"
|
@@ -271,30 +241,6 @@ dependencies = [
|
|
271
241
|
"which",
|
272
242
|
]
|
273
243
|
|
274
|
-
[[package]]
|
275
|
-
name = "bindgen"
|
276
|
-
version = "0.70.1"
|
277
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
278
|
-
checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f"
|
279
|
-
dependencies = [
|
280
|
-
"bitflags 2.8.0",
|
281
|
-
"cexpr",
|
282
|
-
"clang-sys",
|
283
|
-
"itertools",
|
284
|
-
"proc-macro2",
|
285
|
-
"quote",
|
286
|
-
"regex",
|
287
|
-
"rustc-hash 1.1.0",
|
288
|
-
"shlex",
|
289
|
-
"syn",
|
290
|
-
]
|
291
|
-
|
292
|
-
[[package]]
|
293
|
-
name = "binstring"
|
294
|
-
version = "0.1.2"
|
295
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
296
|
-
checksum = "ed79c2a8151273c70956b5e3cdfdc1ff6c1a8b9779ba59c6807d281b32ee2f86"
|
297
|
-
|
298
244
|
[[package]]
|
299
245
|
name = "bitflags"
|
300
246
|
version = "1.3.2"
|
@@ -307,17 +253,6 @@ version = "2.8.0"
|
|
307
253
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
308
254
|
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
309
255
|
|
310
|
-
[[package]]
|
311
|
-
name = "blake2b_simd"
|
312
|
-
version = "1.0.3"
|
313
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
314
|
-
checksum = "06e903a20b159e944f91ec8499fe1e55651480c541ea0a584f5d967c49ad9d99"
|
315
|
-
dependencies = [
|
316
|
-
"arrayref",
|
317
|
-
"arrayvec",
|
318
|
-
"constant_time_eq",
|
319
|
-
]
|
320
|
-
|
321
256
|
[[package]]
|
322
257
|
name = "block-buffer"
|
323
258
|
version = "0.10.4"
|
@@ -327,32 +262,6 @@ dependencies = [
|
|
327
262
|
"generic-array",
|
328
263
|
]
|
329
264
|
|
330
|
-
[[package]]
|
331
|
-
name = "boring"
|
332
|
-
version = "4.15.0"
|
333
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
334
|
-
checksum = "c84a16a47c850f899c5cb6f2ef47bedf7268447c3cb84a89b7bc35f140c859d6"
|
335
|
-
dependencies = [
|
336
|
-
"bitflags 2.8.0",
|
337
|
-
"boring-sys",
|
338
|
-
"foreign-types 0.5.0",
|
339
|
-
"libc",
|
340
|
-
"openssl-macros",
|
341
|
-
]
|
342
|
-
|
343
|
-
[[package]]
|
344
|
-
name = "boring-sys"
|
345
|
-
version = "4.15.0"
|
346
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
347
|
-
checksum = "3cf7466056d7ca35a356fbc27c89eb2f1493fb2e61c24c5f9f0277e8f402dc9e"
|
348
|
-
dependencies = [
|
349
|
-
"autocfg",
|
350
|
-
"bindgen 0.70.1",
|
351
|
-
"cmake",
|
352
|
-
"fs_extra",
|
353
|
-
"fslock",
|
354
|
-
]
|
355
|
-
|
356
265
|
[[package]]
|
357
266
|
name = "brotli"
|
358
267
|
version = "7.0.0"
|
@@ -390,12 +299,6 @@ version = "3.17.0"
|
|
390
299
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
391
300
|
checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
|
392
301
|
|
393
|
-
[[package]]
|
394
|
-
name = "byteorder"
|
395
|
-
version = "1.5.0"
|
396
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
397
|
-
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
398
|
-
|
399
302
|
[[package]]
|
400
303
|
name = "bytes"
|
401
304
|
version = "1.10.1"
|
@@ -468,17 +371,6 @@ dependencies = [
|
|
468
371
|
"cc",
|
469
372
|
]
|
470
373
|
|
471
|
-
[[package]]
|
472
|
-
name = "coarsetime"
|
473
|
-
version = "0.1.36"
|
474
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
475
|
-
checksum = "91849686042de1b41cd81490edc83afbcb0abe5a9b6f2c4114f23ce8cca1bcf4"
|
476
|
-
dependencies = [
|
477
|
-
"libc",
|
478
|
-
"wasix",
|
479
|
-
"wasm-bindgen",
|
480
|
-
]
|
481
|
-
|
482
374
|
[[package]]
|
483
375
|
name = "combine"
|
484
376
|
version = "4.6.7"
|
@@ -502,18 +394,6 @@ dependencies = [
|
|
502
394
|
"crossbeam-utils",
|
503
395
|
]
|
504
396
|
|
505
|
-
[[package]]
|
506
|
-
name = "const-oid"
|
507
|
-
version = "0.9.6"
|
508
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
509
|
-
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
|
510
|
-
|
511
|
-
[[package]]
|
512
|
-
name = "constant_time_eq"
|
513
|
-
version = "0.3.1"
|
514
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
515
|
-
checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"
|
516
|
-
|
517
397
|
[[package]]
|
518
398
|
name = "core-foundation"
|
519
399
|
version = "0.9.4"
|
@@ -614,18 +494,6 @@ version = "0.8.21"
|
|
614
494
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
615
495
|
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
616
496
|
|
617
|
-
[[package]]
|
618
|
-
name = "crypto-bigint"
|
619
|
-
version = "0.5.5"
|
620
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
621
|
-
checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76"
|
622
|
-
dependencies = [
|
623
|
-
"generic-array",
|
624
|
-
"rand_core 0.6.4",
|
625
|
-
"subtle",
|
626
|
-
"zeroize",
|
627
|
-
]
|
628
|
-
|
629
497
|
[[package]]
|
630
498
|
name = "crypto-common"
|
631
499
|
version = "0.1.6"
|
@@ -636,12 +504,6 @@ dependencies = [
|
|
636
504
|
"typenum",
|
637
505
|
]
|
638
506
|
|
639
|
-
[[package]]
|
640
|
-
name = "ct-codecs"
|
641
|
-
version = "1.1.3"
|
642
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
643
|
-
checksum = "b916ba8ce9e4182696896f015e8a5ae6081b305f74690baa8465e35f5a142ea4"
|
644
|
-
|
645
507
|
[[package]]
|
646
508
|
name = "dashmap"
|
647
509
|
version = "6.1.0"
|
@@ -662,17 +524,6 @@ version = "2.8.0"
|
|
662
524
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
663
525
|
checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010"
|
664
526
|
|
665
|
-
[[package]]
|
666
|
-
name = "der"
|
667
|
-
version = "0.7.9"
|
668
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
669
|
-
checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0"
|
670
|
-
dependencies = [
|
671
|
-
"const-oid",
|
672
|
-
"pem-rfc7468",
|
673
|
-
"zeroize",
|
674
|
-
]
|
675
|
-
|
676
527
|
[[package]]
|
677
528
|
name = "der-parser"
|
678
529
|
version = "9.0.0"
|
@@ -724,7 +575,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
724
575
|
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
725
576
|
dependencies = [
|
726
577
|
"block-buffer",
|
727
|
-
"const-oid",
|
728
578
|
"crypto-common",
|
729
579
|
"subtle",
|
730
580
|
]
|
@@ -767,57 +617,12 @@ version = "1.0.5"
|
|
767
617
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
768
618
|
checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
769
619
|
|
770
|
-
[[package]]
|
771
|
-
name = "ecdsa"
|
772
|
-
version = "0.16.9"
|
773
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
774
|
-
checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca"
|
775
|
-
dependencies = [
|
776
|
-
"der",
|
777
|
-
"digest",
|
778
|
-
"elliptic-curve",
|
779
|
-
"rfc6979",
|
780
|
-
"signature",
|
781
|
-
"spki",
|
782
|
-
]
|
783
|
-
|
784
|
-
[[package]]
|
785
|
-
name = "ed25519-compact"
|
786
|
-
version = "2.1.1"
|
787
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
788
|
-
checksum = "e9b3460f44bea8cd47f45a0c70892f1eff856d97cd55358b2f73f663789f6190"
|
789
|
-
dependencies = [
|
790
|
-
"ct-codecs",
|
791
|
-
"getrandom 0.2.15",
|
792
|
-
]
|
793
|
-
|
794
620
|
[[package]]
|
795
621
|
name = "either"
|
796
622
|
version = "1.15.0"
|
797
623
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
798
624
|
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
799
625
|
|
800
|
-
[[package]]
|
801
|
-
name = "elliptic-curve"
|
802
|
-
version = "0.13.8"
|
803
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
804
|
-
checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47"
|
805
|
-
dependencies = [
|
806
|
-
"base16ct",
|
807
|
-
"crypto-bigint",
|
808
|
-
"digest",
|
809
|
-
"ff",
|
810
|
-
"generic-array",
|
811
|
-
"group",
|
812
|
-
"hkdf",
|
813
|
-
"pem-rfc7468",
|
814
|
-
"pkcs8",
|
815
|
-
"rand_core 0.6.4",
|
816
|
-
"sec1",
|
817
|
-
"subtle",
|
818
|
-
"zeroize",
|
819
|
-
]
|
820
|
-
|
821
626
|
[[package]]
|
822
627
|
name = "encoding_rs"
|
823
628
|
version = "0.8.35"
|
@@ -870,16 +675,6 @@ version = "2.3.0"
|
|
870
675
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
871
676
|
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
872
677
|
|
873
|
-
[[package]]
|
874
|
-
name = "ff"
|
875
|
-
version = "0.13.1"
|
876
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
877
|
-
checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393"
|
878
|
-
dependencies = [
|
879
|
-
"rand_core 0.6.4",
|
880
|
-
"subtle",
|
881
|
-
]
|
882
|
-
|
883
678
|
[[package]]
|
884
679
|
name = "filetime"
|
885
680
|
version = "0.2.25"
|
@@ -914,28 +709,7 @@ version = "0.3.2"
|
|
914
709
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
915
710
|
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
916
711
|
dependencies = [
|
917
|
-
"foreign-types-shared
|
918
|
-
]
|
919
|
-
|
920
|
-
[[package]]
|
921
|
-
name = "foreign-types"
|
922
|
-
version = "0.5.0"
|
923
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
924
|
-
checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
|
925
|
-
dependencies = [
|
926
|
-
"foreign-types-macros",
|
927
|
-
"foreign-types-shared 0.3.1",
|
928
|
-
]
|
929
|
-
|
930
|
-
[[package]]
|
931
|
-
name = "foreign-types-macros"
|
932
|
-
version = "0.2.3"
|
933
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
934
|
-
checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
|
935
|
-
dependencies = [
|
936
|
-
"proc-macro2",
|
937
|
-
"quote",
|
938
|
-
"syn",
|
712
|
+
"foreign-types-shared",
|
939
713
|
]
|
940
714
|
|
941
715
|
[[package]]
|
@@ -944,12 +718,6 @@ version = "0.1.1"
|
|
944
718
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
945
719
|
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
946
720
|
|
947
|
-
[[package]]
|
948
|
-
name = "foreign-types-shared"
|
949
|
-
version = "0.3.1"
|
950
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
951
|
-
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
|
952
|
-
|
953
721
|
[[package]]
|
954
722
|
name = "form_urlencoded"
|
955
723
|
version = "1.2.1"
|
@@ -984,16 +752,6 @@ dependencies = [
|
|
984
752
|
"libc",
|
985
753
|
]
|
986
754
|
|
987
|
-
[[package]]
|
988
|
-
name = "fslock"
|
989
|
-
version = "0.2.1"
|
990
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
991
|
-
checksum = "04412b8935272e3a9bae6f48c7bfff74c2911f60525404edfdd28e49884c3bfb"
|
992
|
-
dependencies = [
|
993
|
-
"libc",
|
994
|
-
"winapi",
|
995
|
-
]
|
996
|
-
|
997
755
|
[[package]]
|
998
756
|
name = "futures"
|
999
757
|
version = "0.3.31"
|
@@ -1104,7 +862,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
|
1104
862
|
dependencies = [
|
1105
863
|
"typenum",
|
1106
864
|
"version_check",
|
1107
|
-
"zeroize",
|
1108
865
|
]
|
1109
866
|
|
1110
867
|
[[package]]
|
@@ -1157,17 +914,6 @@ dependencies = [
|
|
1157
914
|
"regex-syntax 0.8.5",
|
1158
915
|
]
|
1159
916
|
|
1160
|
-
[[package]]
|
1161
|
-
name = "group"
|
1162
|
-
version = "0.13.0"
|
1163
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1164
|
-
checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63"
|
1165
|
-
dependencies = [
|
1166
|
-
"ff",
|
1167
|
-
"rand_core 0.6.4",
|
1168
|
-
"subtle",
|
1169
|
-
]
|
1170
|
-
|
1171
917
|
[[package]]
|
1172
918
|
name = "h2"
|
1173
919
|
version = "0.4.8"
|
@@ -1214,15 +960,6 @@ version = "0.3.9"
|
|
1214
960
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1215
961
|
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
|
1216
962
|
|
1217
|
-
[[package]]
|
1218
|
-
name = "hkdf"
|
1219
|
-
version = "0.12.4"
|
1220
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1221
|
-
checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7"
|
1222
|
-
dependencies = [
|
1223
|
-
"hmac",
|
1224
|
-
]
|
1225
|
-
|
1226
963
|
[[package]]
|
1227
964
|
name = "hmac"
|
1228
965
|
version = "0.12.1"
|
@@ -1232,30 +969,6 @@ dependencies = [
|
|
1232
969
|
"digest",
|
1233
970
|
]
|
1234
971
|
|
1235
|
-
[[package]]
|
1236
|
-
name = "hmac-sha1-compact"
|
1237
|
-
version = "1.1.5"
|
1238
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1239
|
-
checksum = "18492c9f6f9a560e0d346369b665ad2bdbc89fa9bceca75796584e79042694c3"
|
1240
|
-
|
1241
|
-
[[package]]
|
1242
|
-
name = "hmac-sha256"
|
1243
|
-
version = "1.1.8"
|
1244
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1245
|
-
checksum = "4a8575493d277c9092b988c780c94737fb9fd8651a1001e16bee3eccfc1baedb"
|
1246
|
-
dependencies = [
|
1247
|
-
"digest",
|
1248
|
-
]
|
1249
|
-
|
1250
|
-
[[package]]
|
1251
|
-
name = "hmac-sha512"
|
1252
|
-
version = "1.1.6"
|
1253
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1254
|
-
checksum = "b0b3a0f572aa8389d325f5852b9e0a333a15b0f86ecccbb3fdb6e97cd86dc67c"
|
1255
|
-
dependencies = [
|
1256
|
-
"digest",
|
1257
|
-
]
|
1258
|
-
|
1259
972
|
[[package]]
|
1260
973
|
name = "home"
|
1261
974
|
version = "0.5.11"
|
@@ -1653,7 +1366,7 @@ dependencies = [
|
|
1653
1366
|
"itsi_error",
|
1654
1367
|
"itsi_rb_helpers",
|
1655
1368
|
"itsi_tracing",
|
1656
|
-
"
|
1369
|
+
"jsonwebtoken",
|
1657
1370
|
"magnus",
|
1658
1371
|
"md5",
|
1659
1372
|
"moka",
|
@@ -1742,44 +1455,18 @@ dependencies = [
|
|
1742
1455
|
]
|
1743
1456
|
|
1744
1457
|
[[package]]
|
1745
|
-
name = "
|
1746
|
-
version = "
|
1458
|
+
name = "jsonwebtoken"
|
1459
|
+
version = "9.3.1"
|
1747
1460
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1748
|
-
checksum = "
|
1461
|
+
checksum = "5a87cc7a48537badeae96744432de36f4be2b4a34a05a5ef32e9dd8a1c169dde"
|
1749
1462
|
dependencies = [
|
1750
|
-
"
|
1751
|
-
"
|
1752
|
-
"
|
1753
|
-
"
|
1754
|
-
"coarsetime",
|
1755
|
-
"ct-codecs",
|
1756
|
-
"ed25519-compact",
|
1757
|
-
"hmac-sha1-compact",
|
1758
|
-
"hmac-sha256",
|
1759
|
-
"hmac-sha512",
|
1760
|
-
"k256",
|
1761
|
-
"p256",
|
1762
|
-
"p384",
|
1763
|
-
"rand 0.8.5",
|
1463
|
+
"base64",
|
1464
|
+
"js-sys",
|
1465
|
+
"pem",
|
1466
|
+
"ring",
|
1764
1467
|
"serde",
|
1765
1468
|
"serde_json",
|
1766
|
-
"
|
1767
|
-
"thiserror 2.0.12",
|
1768
|
-
"zeroize",
|
1769
|
-
]
|
1770
|
-
|
1771
|
-
[[package]]
|
1772
|
-
name = "k256"
|
1773
|
-
version = "0.13.4"
|
1774
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1775
|
-
checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b"
|
1776
|
-
dependencies = [
|
1777
|
-
"cfg-if",
|
1778
|
-
"ecdsa",
|
1779
|
-
"elliptic-curve",
|
1780
|
-
"once_cell",
|
1781
|
-
"sha2",
|
1782
|
-
"signature",
|
1469
|
+
"simple_asn1",
|
1783
1470
|
]
|
1784
1471
|
|
1785
1472
|
[[package]]
|
@@ -1807,9 +1494,6 @@ name = "lazy_static"
|
|
1807
1494
|
version = "1.5.0"
|
1808
1495
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1809
1496
|
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
1810
|
-
dependencies = [
|
1811
|
-
"spin",
|
1812
|
-
]
|
1813
1497
|
|
1814
1498
|
[[package]]
|
1815
1499
|
name = "lazycell"
|
@@ -1833,12 +1517,6 @@ dependencies = [
|
|
1833
1517
|
"windows-targets 0.52.6",
|
1834
1518
|
]
|
1835
1519
|
|
1836
|
-
[[package]]
|
1837
|
-
name = "libm"
|
1838
|
-
version = "0.2.11"
|
1839
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1840
|
-
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
1841
|
-
|
1842
1520
|
[[package]]
|
1843
1521
|
name = "libredox"
|
1844
1522
|
version = "0.1.3"
|
@@ -2107,23 +1785,6 @@ dependencies = [
|
|
2107
1785
|
"num-traits",
|
2108
1786
|
]
|
2109
1787
|
|
2110
|
-
[[package]]
|
2111
|
-
name = "num-bigint-dig"
|
2112
|
-
version = "0.8.4"
|
2113
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2114
|
-
checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151"
|
2115
|
-
dependencies = [
|
2116
|
-
"byteorder",
|
2117
|
-
"lazy_static",
|
2118
|
-
"libm",
|
2119
|
-
"num-integer",
|
2120
|
-
"num-iter",
|
2121
|
-
"num-traits",
|
2122
|
-
"rand 0.8.5",
|
2123
|
-
"smallvec",
|
2124
|
-
"zeroize",
|
2125
|
-
]
|
2126
|
-
|
2127
1788
|
[[package]]
|
2128
1789
|
name = "num-conv"
|
2129
1790
|
version = "0.1.0"
|
@@ -2139,17 +1800,6 @@ dependencies = [
|
|
2139
1800
|
"num-traits",
|
2140
1801
|
]
|
2141
1802
|
|
2142
|
-
[[package]]
|
2143
|
-
name = "num-iter"
|
2144
|
-
version = "0.1.45"
|
2145
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2146
|
-
checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf"
|
2147
|
-
dependencies = [
|
2148
|
-
"autocfg",
|
2149
|
-
"num-integer",
|
2150
|
-
"num-traits",
|
2151
|
-
]
|
2152
|
-
|
2153
1803
|
[[package]]
|
2154
1804
|
name = "num-traits"
|
2155
1805
|
version = "0.2.19"
|
@@ -2157,7 +1807,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
2157
1807
|
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
2158
1808
|
dependencies = [
|
2159
1809
|
"autocfg",
|
2160
|
-
"libm",
|
2161
1810
|
]
|
2162
1811
|
|
2163
1812
|
[[package]]
|
@@ -2202,7 +1851,7 @@ checksum = "5e14130c6a98cd258fdcb0fb6d744152343ff729cbfcb28c656a9d12b999fbcd"
|
|
2202
1851
|
dependencies = [
|
2203
1852
|
"bitflags 2.8.0",
|
2204
1853
|
"cfg-if",
|
2205
|
-
"foreign-types
|
1854
|
+
"foreign-types",
|
2206
1855
|
"libc",
|
2207
1856
|
"once_cell",
|
2208
1857
|
"openssl-macros",
|
@@ -2250,30 +1899,6 @@ version = "0.1.1"
|
|
2250
1899
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2251
1900
|
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
2252
1901
|
|
2253
|
-
[[package]]
|
2254
|
-
name = "p256"
|
2255
|
-
version = "0.13.2"
|
2256
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2257
|
-
checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b"
|
2258
|
-
dependencies = [
|
2259
|
-
"ecdsa",
|
2260
|
-
"elliptic-curve",
|
2261
|
-
"primeorder",
|
2262
|
-
"sha2",
|
2263
|
-
]
|
2264
|
-
|
2265
|
-
[[package]]
|
2266
|
-
name = "p384"
|
2267
|
-
version = "0.13.1"
|
2268
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2269
|
-
checksum = "fe42f1670a52a47d448f14b6a5c61dd78fce51856e68edaa38f7ae3a46b8d6b6"
|
2270
|
-
dependencies = [
|
2271
|
-
"ecdsa",
|
2272
|
-
"elliptic-curve",
|
2273
|
-
"primeorder",
|
2274
|
-
"sha2",
|
2275
|
-
]
|
2276
|
-
|
2277
1902
|
[[package]]
|
2278
1903
|
name = "parking"
|
2279
1904
|
version = "2.2.1"
|
@@ -2319,15 +1944,6 @@ dependencies = [
|
|
2319
1944
|
"serde",
|
2320
1945
|
]
|
2321
1946
|
|
2322
|
-
[[package]]
|
2323
|
-
name = "pem-rfc7468"
|
2324
|
-
version = "0.7.0"
|
2325
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2326
|
-
checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412"
|
2327
|
-
dependencies = [
|
2328
|
-
"base64ct",
|
2329
|
-
]
|
2330
|
-
|
2331
1947
|
[[package]]
|
2332
1948
|
name = "percent-encoding"
|
2333
1949
|
version = "2.3.1"
|
@@ -2366,27 +1982,6 @@ version = "0.1.0"
|
|
2366
1982
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2367
1983
|
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
2368
1984
|
|
2369
|
-
[[package]]
|
2370
|
-
name = "pkcs1"
|
2371
|
-
version = "0.7.5"
|
2372
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2373
|
-
checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f"
|
2374
|
-
dependencies = [
|
2375
|
-
"der",
|
2376
|
-
"pkcs8",
|
2377
|
-
"spki",
|
2378
|
-
]
|
2379
|
-
|
2380
|
-
[[package]]
|
2381
|
-
name = "pkcs8"
|
2382
|
-
version = "0.10.2"
|
2383
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2384
|
-
checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
|
2385
|
-
dependencies = [
|
2386
|
-
"der",
|
2387
|
-
"spki",
|
2388
|
-
]
|
2389
|
-
|
2390
1985
|
[[package]]
|
2391
1986
|
name = "pkg-config"
|
2392
1987
|
version = "0.3.32"
|
@@ -2424,15 +2019,6 @@ dependencies = [
|
|
2424
2019
|
"syn",
|
2425
2020
|
]
|
2426
2021
|
|
2427
|
-
[[package]]
|
2428
|
-
name = "primeorder"
|
2429
|
-
version = "0.13.6"
|
2430
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2431
|
-
checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6"
|
2432
|
-
dependencies = [
|
2433
|
-
"elliptic-curve",
|
2434
|
-
]
|
2435
|
-
|
2436
2022
|
[[package]]
|
2437
2023
|
name = "proc-macro2"
|
2438
2024
|
version = "1.0.93"
|
@@ -2609,7 +2195,7 @@ version = "0.9.111"
|
|
2609
2195
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2610
2196
|
checksum = "64691175abc704862f60a9ca8ef06174080cc50615f2bf1d4759f46db18b4d29"
|
2611
2197
|
dependencies = [
|
2612
|
-
"bindgen
|
2198
|
+
"bindgen",
|
2613
2199
|
"lazy_static",
|
2614
2200
|
"proc-macro2",
|
2615
2201
|
"quote",
|
@@ -2781,16 +2367,6 @@ dependencies = [
|
|
2781
2367
|
"windows-registry",
|
2782
2368
|
]
|
2783
2369
|
|
2784
|
-
[[package]]
|
2785
|
-
name = "rfc6979"
|
2786
|
-
version = "0.4.0"
|
2787
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2788
|
-
checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2"
|
2789
|
-
dependencies = [
|
2790
|
-
"hmac",
|
2791
|
-
"subtle",
|
2792
|
-
]
|
2793
|
-
|
2794
2370
|
[[package]]
|
2795
2371
|
name = "ring"
|
2796
2372
|
version = "0.17.14"
|
@@ -2811,27 +2387,6 @@ version = "0.3.1"
|
|
2811
2387
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2812
2388
|
checksum = "afab94fb28594581f62d981211a9a4d53cc8130bbcbbb89a0440d9b8e81a7746"
|
2813
2389
|
|
2814
|
-
[[package]]
|
2815
|
-
name = "rsa"
|
2816
|
-
version = "0.9.8"
|
2817
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2818
|
-
checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b"
|
2819
|
-
dependencies = [
|
2820
|
-
"const-oid",
|
2821
|
-
"digest",
|
2822
|
-
"num-bigint-dig",
|
2823
|
-
"num-integer",
|
2824
|
-
"num-traits",
|
2825
|
-
"pkcs1",
|
2826
|
-
"pkcs8",
|
2827
|
-
"rand_core 0.6.4",
|
2828
|
-
"sha2",
|
2829
|
-
"signature",
|
2830
|
-
"spki",
|
2831
|
-
"subtle",
|
2832
|
-
"zeroize",
|
2833
|
-
]
|
2834
|
-
|
2835
2390
|
[[package]]
|
2836
2391
|
name = "rustc-demangle"
|
2837
2392
|
version = "0.1.24"
|
@@ -3003,20 +2558,6 @@ version = "1.2.0"
|
|
3003
2558
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
3004
2559
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
3005
2560
|
|
3006
|
-
[[package]]
|
3007
|
-
name = "sec1"
|
3008
|
-
version = "0.7.3"
|
3009
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
3010
|
-
checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc"
|
3011
|
-
dependencies = [
|
3012
|
-
"base16ct",
|
3013
|
-
"der",
|
3014
|
-
"generic-array",
|
3015
|
-
"pkcs8",
|
3016
|
-
"subtle",
|
3017
|
-
"zeroize",
|
3018
|
-
]
|
3019
|
-
|
3020
2561
|
[[package]]
|
3021
2562
|
name = "security-framework"
|
3022
2563
|
version = "2.11.1"
|
@@ -3168,13 +2709,15 @@ dependencies = [
|
|
3168
2709
|
]
|
3169
2710
|
|
3170
2711
|
[[package]]
|
3171
|
-
name = "
|
3172
|
-
version = "
|
2712
|
+
name = "simple_asn1"
|
2713
|
+
version = "0.6.3"
|
3173
2714
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
3174
|
-
checksum = "
|
2715
|
+
checksum = "297f631f50729c8c99b84667867963997ec0b50f32b2a7dbcab828ef0541e8bb"
|
3175
2716
|
dependencies = [
|
3176
|
-
"
|
3177
|
-
"
|
2717
|
+
"num-bigint",
|
2718
|
+
"num-traits",
|
2719
|
+
"thiserror 2.0.12",
|
2720
|
+
"time",
|
3178
2721
|
]
|
3179
2722
|
|
3180
2723
|
[[package]]
|
@@ -3202,22 +2745,6 @@ dependencies = [
|
|
3202
2745
|
"windows-sys 0.52.0",
|
3203
2746
|
]
|
3204
2747
|
|
3205
|
-
[[package]]
|
3206
|
-
name = "spin"
|
3207
|
-
version = "0.9.8"
|
3208
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
3209
|
-
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
3210
|
-
|
3211
|
-
[[package]]
|
3212
|
-
name = "spki"
|
3213
|
-
version = "0.7.3"
|
3214
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
3215
|
-
checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d"
|
3216
|
-
dependencies = [
|
3217
|
-
"base64ct",
|
3218
|
-
"der",
|
3219
|
-
]
|
3220
|
-
|
3221
2748
|
[[package]]
|
3222
2749
|
name = "stable_deref_trait"
|
3223
2750
|
version = "1.2.0"
|
@@ -3230,19 +2757,6 @@ version = "2.6.1"
|
|
3230
2757
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
3231
2758
|
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
3232
2759
|
|
3233
|
-
[[package]]
|
3234
|
-
name = "superboring"
|
3235
|
-
version = "0.1.4"
|
3236
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
3237
|
-
checksum = "515cce34a781d7250b8a65706e0f2a5b99236ea605cb235d4baed6685820478f"
|
3238
|
-
dependencies = [
|
3239
|
-
"getrandom 0.2.15",
|
3240
|
-
"hmac-sha256",
|
3241
|
-
"hmac-sha512",
|
3242
|
-
"rand 0.8.5",
|
3243
|
-
"rsa",
|
3244
|
-
]
|
3245
|
-
|
3246
2760
|
[[package]]
|
3247
2761
|
name = "syn"
|
3248
2762
|
version = "2.0.98"
|
@@ -3775,15 +3289,6 @@ dependencies = [
|
|
3775
3289
|
"wit-bindgen-rt",
|
3776
3290
|
]
|
3777
3291
|
|
3778
|
-
[[package]]
|
3779
|
-
name = "wasix"
|
3780
|
-
version = "0.12.21"
|
3781
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
3782
|
-
checksum = "c1fbb4ef9bbca0c1170e0b00dd28abc9e3b68669821600cad1caaed606583c6d"
|
3783
|
-
dependencies = [
|
3784
|
-
"wasi 0.11.0+wasi-snapshot-preview1",
|
3785
|
-
]
|
3786
|
-
|
3787
3292
|
[[package]]
|
3788
3293
|
name = "wasm-bindgen"
|
3789
3294
|
version = "0.2.100"
|
data/ext/itsi_server/Cargo.toml
CHANGED
@@ -42,7 +42,7 @@ hyper-util = { version = "0.1.10", features = ["full"] }
|
|
42
42
|
itsi_error = { path = "../itsi_error" }
|
43
43
|
itsi_rb_helpers = { path = "../itsi_rb_helpers" }
|
44
44
|
itsi_tracing = { path = "../itsi_tracing" }
|
45
|
-
|
45
|
+
jsonwebtoken = "9.3.1"
|
46
46
|
magnus = { version = "0.7.1", features = ["bytes", "rb-sys"] }
|
47
47
|
moka = { version = "0.12.10", features = ["sync"] }
|
48
48
|
notify = { version = "8.0.0" }
|
@@ -5,20 +5,14 @@ use crate::server::{
|
|
5
5
|
};
|
6
6
|
use async_trait::async_trait;
|
7
7
|
use base64::{engine::general_purpose, Engine};
|
8
|
+
use derive_more::Debug;
|
8
9
|
use either::Either;
|
9
10
|
use itsi_error::ItsiError;
|
10
|
-
use
|
11
|
-
|
12
|
-
prelude::{
|
13
|
-
ECDSAP256PublicKeyLike, ECDSAP384PublicKeyLike, ES256PublicKey, ES384PublicKey, HS256Key,
|
14
|
-
HS384Key, HS512Key, MACLike, PS256PublicKey, PS384PublicKey, PS512PublicKey,
|
15
|
-
RS256PublicKey, RS384PublicKey, RS512PublicKey, RSAPublicKeyLike,
|
16
|
-
},
|
17
|
-
token::Token,
|
11
|
+
use jsonwebtoken::{
|
12
|
+
decode, decode_header, Algorithm as JwtAlg, DecodingKey, TokenData, Validation,
|
18
13
|
};
|
19
14
|
use magnus::error::Result;
|
20
15
|
use serde::Deserialize;
|
21
|
-
use std::str;
|
22
16
|
use std::{
|
23
17
|
collections::{HashMap, HashSet},
|
24
18
|
sync::OnceLock,
|
@@ -27,9 +21,12 @@ use std::{
|
|
27
21
|
#[derive(Debug, Clone, Deserialize)]
|
28
22
|
pub struct AuthJwt {
|
29
23
|
pub token_source: TokenSource,
|
24
|
+
// The verifiers map still holds base64-encoded key strings keyed by algorithm.
|
30
25
|
pub verifiers: HashMap<JwtAlgorithm, Vec<String>>,
|
26
|
+
// We now store jsonwebtoken’s DecodingKey in our OnceLock.
|
31
27
|
#[serde(skip_deserializing)]
|
32
|
-
|
28
|
+
#[debug(skip)]
|
29
|
+
pub keys: OnceLock<HashMap<JwtAlgorithm, Vec<DecodingKey>>>,
|
33
30
|
pub audiences: Option<HashSet<String>>,
|
34
31
|
pub subjects: Option<HashSet<String>>,
|
35
32
|
pub issuers: Option<HashSet<String>>,
|
@@ -63,161 +60,90 @@ pub enum JwtAlgorithm {
|
|
63
60
|
Ps512,
|
64
61
|
}
|
65
62
|
|
63
|
+
// Allow conversion from jsonwebtoken’s Algorithm to our JwtAlgorithm.
|
64
|
+
impl From<JwtAlg> for JwtAlgorithm {
|
65
|
+
fn from(alg: JwtAlg) -> Self {
|
66
|
+
match alg {
|
67
|
+
JwtAlg::HS256 => JwtAlgorithm::Hs256,
|
68
|
+
JwtAlg::HS384 => JwtAlgorithm::Hs384,
|
69
|
+
JwtAlg::HS512 => JwtAlgorithm::Hs512,
|
70
|
+
JwtAlg::RS256 => JwtAlgorithm::Rs256,
|
71
|
+
JwtAlg::RS384 => JwtAlgorithm::Rs384,
|
72
|
+
JwtAlg::RS512 => JwtAlgorithm::Rs512,
|
73
|
+
JwtAlg::ES256 => JwtAlgorithm::Es256,
|
74
|
+
JwtAlg::ES384 => JwtAlgorithm::Es384,
|
75
|
+
JwtAlg::PS256 => JwtAlgorithm::Ps256,
|
76
|
+
JwtAlg::PS384 => JwtAlgorithm::Ps384,
|
77
|
+
JwtAlg::PS512 => JwtAlgorithm::Ps512,
|
78
|
+
_ => panic!("Unsupported algorithm"),
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
66
83
|
impl JwtAlgorithm {
|
67
|
-
|
84
|
+
/// Given a base64-encoded key string, decode and construct a jsonwebtoken::DecodingKey.
|
85
|
+
pub fn key_from(&self, base64: &str) -> itsi_error::Result<DecodingKey> {
|
68
86
|
let bytes = general_purpose::STANDARD
|
69
87
|
.decode(base64)
|
70
88
|
.map_err(ItsiError::default)?;
|
71
|
-
|
72
89
|
match self {
|
73
|
-
|
74
|
-
JwtAlgorithm::
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
.map(JwtKey::Rs384)
|
91
|
-
.map_err(ItsiError::default)?),
|
92
|
-
JwtAlgorithm::Rs512 => Ok(RS512PublicKey::from_der(&bytes)
|
93
|
-
.or_else(|_| {
|
94
|
-
RS512PublicKey::from_pem(
|
95
|
-
&String::from_utf8(bytes.clone()).map_err(ItsiError::default)?,
|
96
|
-
)
|
97
|
-
})
|
98
|
-
.map(JwtKey::Rs512)
|
99
|
-
.map_err(ItsiError::default)?),
|
100
|
-
JwtAlgorithm::Es256 => Ok(ES256PublicKey::from_der(&bytes)
|
101
|
-
.or_else(|_| {
|
102
|
-
ES256PublicKey::from_pem(
|
103
|
-
&String::from_utf8(bytes.clone()).map_err(ItsiError::default)?,
|
104
|
-
)
|
105
|
-
})
|
106
|
-
.map(JwtKey::Es256)
|
107
|
-
.map_err(ItsiError::default)?),
|
108
|
-
JwtAlgorithm::Es384 => Ok(ES384PublicKey::from_der(&bytes)
|
109
|
-
.or_else(|_| {
|
110
|
-
ES384PublicKey::from_pem(
|
111
|
-
&String::from_utf8(bytes.clone()).map_err(ItsiError::default)?,
|
112
|
-
)
|
113
|
-
})
|
114
|
-
.map(JwtKey::Es384)
|
115
|
-
.map_err(ItsiError::default)?),
|
116
|
-
JwtAlgorithm::Ps256 => Ok(PS256PublicKey::from_der(&bytes)
|
117
|
-
.or_else(|_| {
|
118
|
-
PS256PublicKey::from_pem(
|
119
|
-
&String::from_utf8(bytes.clone()).map_err(ItsiError::default)?,
|
120
|
-
)
|
121
|
-
})
|
122
|
-
.map(JwtKey::Ps256)
|
123
|
-
.map_err(ItsiError::default)?),
|
124
|
-
JwtAlgorithm::Ps384 => Ok(PS384PublicKey::from_der(&bytes)
|
125
|
-
.or_else(|_| {
|
126
|
-
PS384PublicKey::from_pem(
|
127
|
-
&String::from_utf8(bytes.clone()).map_err(ItsiError::default)?,
|
128
|
-
)
|
129
|
-
})
|
130
|
-
.map(JwtKey::Ps384)
|
131
|
-
.map_err(ItsiError::default)?),
|
132
|
-
JwtAlgorithm::Ps512 => Ok(PS512PublicKey::from_der(&bytes)
|
133
|
-
.or_else(|_| {
|
134
|
-
PS512PublicKey::from_pem(
|
135
|
-
&String::from_utf8(bytes.clone()).map_err(ItsiError::default)?,
|
136
|
-
)
|
137
|
-
})
|
138
|
-
.map(JwtKey::Ps512)
|
139
|
-
.map_err(ItsiError::default)?),
|
90
|
+
// For HMAC algorithms, use the secret directly.
|
91
|
+
JwtAlgorithm::Hs256 | JwtAlgorithm::Hs384 | JwtAlgorithm::Hs512 => {
|
92
|
+
Ok(DecodingKey::from_secret(&bytes))
|
93
|
+
}
|
94
|
+
// For RSA (and PS) algorithms, expect a PEM-formatted key.
|
95
|
+
JwtAlgorithm::Rs256
|
96
|
+
| JwtAlgorithm::Rs384
|
97
|
+
| JwtAlgorithm::Rs512
|
98
|
+
| JwtAlgorithm::Ps256
|
99
|
+
| JwtAlgorithm::Ps384
|
100
|
+
| JwtAlgorithm::Ps512 => {
|
101
|
+
DecodingKey::from_rsa_pem(&bytes).map_err(|e| ItsiError::default(e.to_string()))
|
102
|
+
}
|
103
|
+
// For ECDSA algorithms, expect a PEM-formatted key.
|
104
|
+
JwtAlgorithm::Es256 | JwtAlgorithm::Es384 => {
|
105
|
+
DecodingKey::from_ec_pem(&bytes).map_err(|e| ItsiError::default(e.to_string()))
|
106
|
+
}
|
140
107
|
}
|
141
108
|
}
|
142
109
|
}
|
143
110
|
|
144
|
-
#[derive(Debug,
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
Rs256(RS256PublicKey),
|
150
|
-
Rs384(RS384PublicKey),
|
151
|
-
Rs512(RS512PublicKey),
|
152
|
-
Es256(ES256PublicKey),
|
153
|
-
Es384(ES384PublicKey),
|
154
|
-
Ps256(PS256PublicKey),
|
155
|
-
Ps384(PS384PublicKey),
|
156
|
-
Ps512(PS512PublicKey),
|
111
|
+
#[derive(Debug, Deserialize)]
|
112
|
+
#[serde(untagged)]
|
113
|
+
enum Audience {
|
114
|
+
Single(String),
|
115
|
+
Multiple(Vec<String>),
|
157
116
|
}
|
158
117
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
"rs384" => Ok(JwtAlgorithm::Rs384),
|
169
|
-
"rs512" => Ok(JwtAlgorithm::Rs512),
|
170
|
-
"es256" => Ok(JwtAlgorithm::Es256),
|
171
|
-
"es384" => Ok(JwtAlgorithm::Es384),
|
172
|
-
"ps256" => Ok(JwtAlgorithm::Ps256),
|
173
|
-
"ps384" => Ok(JwtAlgorithm::Ps384),
|
174
|
-
"ps512" => Ok(JwtAlgorithm::Ps512),
|
175
|
-
_ => Err(itsi_error::ItsiError::UnsupportedProtocol(
|
176
|
-
"Unsupported JWT Algorithm".to_string(),
|
177
|
-
)),
|
178
|
-
}
|
179
|
-
}
|
180
|
-
}
|
181
|
-
|
182
|
-
impl JwtKey {
|
183
|
-
pub fn verify(
|
184
|
-
&self,
|
185
|
-
token: &str,
|
186
|
-
) -> std::result::Result<JWTClaims<claims::NoCustomClaims>, jwt_simple::Error> {
|
187
|
-
match self {
|
188
|
-
JwtKey::Hs256(key) => key.verify_token::<NoCustomClaims>(token, None),
|
189
|
-
JwtKey::Hs384(key) => key.verify_token::<NoCustomClaims>(token, None),
|
190
|
-
JwtKey::Hs512(key) => key.verify_token::<NoCustomClaims>(token, None),
|
191
|
-
JwtKey::Rs256(key) => key.verify_token::<NoCustomClaims>(token, None),
|
192
|
-
JwtKey::Rs384(key) => key.verify_token::<NoCustomClaims>(token, None),
|
193
|
-
JwtKey::Rs512(key) => key.verify_token::<NoCustomClaims>(token, None),
|
194
|
-
JwtKey::Es256(key) => key.verify_token::<NoCustomClaims>(token, None),
|
195
|
-
JwtKey::Es384(key) => key.verify_token::<NoCustomClaims>(token, None),
|
196
|
-
JwtKey::Ps256(key) => key.verify_token::<NoCustomClaims>(token, None),
|
197
|
-
JwtKey::Ps384(key) => key.verify_token::<NoCustomClaims>(token, None),
|
198
|
-
JwtKey::Ps512(key) => key.verify_token::<NoCustomClaims>(token, None),
|
199
|
-
}
|
200
|
-
}
|
118
|
+
#[derive(Debug, Deserialize)]
|
119
|
+
struct Claims {
|
120
|
+
// Here we assume the token includes an expiration.
|
121
|
+
#[allow(dead_code)]
|
122
|
+
exp: usize,
|
123
|
+
// The audience claim may be a single string or an array.
|
124
|
+
aud: Option<Audience>,
|
125
|
+
sub: Option<String>,
|
126
|
+
iss: Option<String>,
|
201
127
|
}
|
202
128
|
|
203
129
|
#[async_trait]
|
204
130
|
impl MiddlewareLayer for AuthJwt {
|
205
131
|
async fn initialize(&self) -> Result<()> {
|
206
|
-
let keys: HashMap<JwtAlgorithm, Vec<
|
132
|
+
let keys: HashMap<JwtAlgorithm, Vec<DecodingKey>> = self
|
207
133
|
.verifiers
|
208
134
|
.iter()
|
209
135
|
.map(|(algorithm, key_strings)| {
|
210
136
|
let algo = algorithm.clone();
|
211
|
-
let keys: Result<Vec<
|
137
|
+
let keys: itsi_error::Result<Vec<DecodingKey>> = key_strings
|
212
138
|
.iter()
|
213
139
|
.map(|key_string| algorithm.key_from(key_string))
|
214
140
|
.collect();
|
215
141
|
keys.map(|keys| (algo, keys))
|
216
142
|
})
|
217
|
-
.collect::<Result<HashMap<JwtAlgorithm, Vec<
|
143
|
+
.collect::<itsi_error::Result<HashMap<JwtAlgorithm, Vec<DecodingKey>>>>()?;
|
218
144
|
self.keys
|
219
145
|
.set(keys)
|
220
|
-
.map_err(|
|
146
|
+
.map_err(|_| ItsiError::default("Failed to set keys".to_string()))?;
|
221
147
|
Ok(())
|
222
148
|
}
|
223
149
|
|
@@ -226,6 +152,7 @@ impl MiddlewareLayer for AuthJwt {
|
|
226
152
|
req: HttpRequest,
|
227
153
|
_context: &mut RequestContext,
|
228
154
|
) -> Result<Either<HttpRequest, HttpResponse>> {
|
155
|
+
// Retrieve the JWT token from either a header or a query parameter.
|
229
156
|
let token_str = match &self.token_source {
|
230
157
|
TokenSource::Header { name, prefix } => {
|
231
158
|
if let Some(header) = req.header(name) {
|
@@ -246,45 +173,61 @@ impl MiddlewareLayer for AuthJwt {
|
|
246
173
|
self.error_response.to_http_response(&req).await,
|
247
174
|
));
|
248
175
|
}
|
249
|
-
|
250
176
|
let token_str = token_str.unwrap();
|
251
|
-
let token_meta = Token::decode_metadata(token_str);
|
252
177
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
}
|
258
|
-
let token_meta: std::result::Result<JwtAlgorithm, ItsiError> =
|
259
|
-
token_meta.unwrap().algorithm().try_into();
|
260
|
-
if token_meta.is_err() {
|
261
|
-
return Ok(Either::Right(
|
262
|
-
self.error_response.to_http_response(&req).await,
|
263
|
-
));
|
264
|
-
}
|
265
|
-
let algorithm = token_meta.unwrap();
|
178
|
+
// Use jsonwebtoken's decode_header to inspect the token and determine its algorithm.
|
179
|
+
let header =
|
180
|
+
decode_header(token_str).map_err(|_| ItsiError::default("Invalid token header"))?;
|
181
|
+
let alg: JwtAlgorithm = header.alg.into();
|
266
182
|
|
267
|
-
if !self.verifiers.contains_key(&
|
183
|
+
if !self.verifiers.contains_key(&alg) {
|
268
184
|
return Ok(Either::Right(
|
269
185
|
self.error_response.to_http_response(&req).await,
|
270
186
|
));
|
271
187
|
}
|
188
|
+
let keys = self.keys.get().unwrap().get(&alg).unwrap();
|
272
189
|
|
273
|
-
|
190
|
+
// Build validation based on the algorithm and optional leeway.
|
191
|
+
let mut validation = Validation::new(match alg {
|
192
|
+
JwtAlgorithm::Hs256 => JwtAlg::HS256,
|
193
|
+
JwtAlgorithm::Hs384 => JwtAlg::HS384,
|
194
|
+
JwtAlgorithm::Hs512 => JwtAlg::HS512,
|
195
|
+
JwtAlgorithm::Rs256 => JwtAlg::RS256,
|
196
|
+
JwtAlgorithm::Rs384 => JwtAlg::RS384,
|
197
|
+
JwtAlgorithm::Rs512 => JwtAlg::RS512,
|
198
|
+
JwtAlgorithm::Es256 => JwtAlg::ES256,
|
199
|
+
JwtAlgorithm::Es384 => JwtAlg::ES384,
|
200
|
+
JwtAlgorithm::Ps256 => JwtAlg::PS256,
|
201
|
+
JwtAlgorithm::Ps384 => JwtAlg::PS384,
|
202
|
+
JwtAlgorithm::Ps512 => JwtAlg::PS512,
|
203
|
+
});
|
204
|
+
if let Some(leeway) = self.leeway {
|
205
|
+
validation.leeway = leeway;
|
206
|
+
}
|
207
|
+
// (Optional) You could set expected issuer or audience on `validation` here.
|
274
208
|
|
275
|
-
|
276
|
-
|
209
|
+
// Try verifying the token using each key until one succeeds.
|
210
|
+
let token_data: Option<TokenData<Claims>> = keys
|
211
|
+
.iter()
|
212
|
+
.find_map(|key| decode::<Claims>(token_str, key, &validation).ok());
|
213
|
+
let token_data = if let Some(data) = token_data {
|
214
|
+
data
|
215
|
+
} else {
|
277
216
|
return Ok(Either::Right(
|
278
217
|
self.error_response.to_http_response(&req).await,
|
279
218
|
));
|
280
|
-
}
|
219
|
+
};
|
281
220
|
|
282
|
-
let claims =
|
221
|
+
let claims = token_data.claims;
|
283
222
|
|
223
|
+
// Verify expected audiences.
|
284
224
|
if let Some(expected_audiences) = &self.audiences {
|
285
|
-
|
286
|
-
|
287
|
-
|
225
|
+
if let Some(aud) = &claims.aud {
|
226
|
+
let token_auds: HashSet<String> = match aud {
|
227
|
+
Audience::Single(s) => [s.clone()].into_iter().collect(),
|
228
|
+
Audience::Multiple(v) => v.iter().cloned().collect(),
|
229
|
+
};
|
230
|
+
if expected_audiences.is_disjoint(&token_auds) {
|
288
231
|
return Ok(Either::Right(
|
289
232
|
self.error_response.to_http_response(&req).await,
|
290
233
|
));
|
@@ -292,10 +235,10 @@ impl MiddlewareLayer for AuthJwt {
|
|
292
235
|
}
|
293
236
|
}
|
294
237
|
|
238
|
+
// Verify expected subject.
|
295
239
|
if let Some(expected_subjects) = &self.subjects {
|
296
|
-
|
297
|
-
|
298
|
-
if !expected_subjects.contains(subject) {
|
240
|
+
if let Some(sub) = &claims.sub {
|
241
|
+
if !expected_subjects.contains(sub) {
|
299
242
|
return Ok(Either::Right(
|
300
243
|
self.error_response.to_http_response(&req).await,
|
301
244
|
));
|
@@ -303,10 +246,10 @@ impl MiddlewareLayer for AuthJwt {
|
|
303
246
|
}
|
304
247
|
}
|
305
248
|
|
249
|
+
// Verify expected issuer.
|
306
250
|
if let Some(expected_issuers) = &self.issuers {
|
307
|
-
|
308
|
-
|
309
|
-
if !expected_issuers.contains(issuer) {
|
251
|
+
if let Some(iss) = &claims.iss {
|
252
|
+
if !expected_issuers.contains(iss) {
|
310
253
|
return Ok(Either::Right(
|
311
254
|
self.error_response.to_http_response(&req).await,
|
312
255
|
));
|
data/lib/itsi/server/version.rb
CHANGED