aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Cargo.lock566
-rw-r--r--Cargo.toml10
-rw-r--r--README.md8
-rw-r--r--TODO.md4
-rw-r--r--src/auth.rs112
-rw-r--r--src/error.rs63
-rw-r--r--src/handlers.rs18
-rw-r--r--src/main.rs2
-rw-r--r--src/routes.rs38
-rw-r--r--src/schema.rs14
11 files changed, 642 insertions, 194 deletions
diff --git a/.gitignore b/.gitignore
index 53d254d..ca9689c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
1/target 1/target
2/secrets
2tags.lock 3tags.lock
3tags.temp 4tags.temp
diff --git a/Cargo.lock b/Cargo.lock
index 45ae0a0..ccc00f1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -10,6 +10,12 @@ dependencies = [
10] 10]
11 11
12[[package]] 12[[package]]
13name = "anyhow"
14version = "1.0.40"
15source = "registry+https://github.com/rust-lang/crates.io-index"
16checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b"
17
18[[package]]
13name = "atty" 19name = "atty"
14version = "0.2.14" 20version = "0.2.14"
15source = "registry+https://github.com/rust-lang/crates.io-index" 21source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -17,7 +23,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
17dependencies = [ 23dependencies = [
18 "hermit-abi", 24 "hermit-abi",
19 "libc", 25 "libc",
20 "winapi 0.3.9", 26 "winapi",
21] 27]
22 28
23[[package]] 29[[package]]
@@ -64,6 +70,12 @@ dependencies = [
64] 70]
65 71
66[[package]] 72[[package]]
73name = "bumpalo"
74version = "3.6.1"
75source = "registry+https://github.com/rust-lang/crates.io-index"
76checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe"
77
78[[package]]
67name = "byteorder" 79name = "byteorder"
68version = "1.4.3" 80version = "1.4.3"
69source = "registry+https://github.com/rust-lang/crates.io-index" 81source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -71,15 +83,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
71 83
72[[package]] 84[[package]]
73name = "bytes" 85name = "bytes"
74version = "0.5.6" 86version = "1.0.1"
75source = "registry+https://github.com/rust-lang/crates.io-index" 87source = "registry+https://github.com/rust-lang/crates.io-index"
76checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" 88checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
77 89
78[[package]] 90[[package]]
79name = "bytes" 91name = "cc"
80version = "1.0.1" 92version = "1.0.67"
81source = "registry+https://github.com/rust-lang/crates.io-index" 93source = "registry+https://github.com/rust-lang/crates.io-index"
82checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" 94checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd"
83 95
84[[package]] 96[[package]]
85name = "cfg-if" 97name = "cfg-if"
@@ -104,7 +116,7 @@ dependencies = [
104 "num-traits", 116 "num-traits",
105 "serde", 117 "serde",
106 "time", 118 "time",
107 "winapi 0.3.9", 119 "winapi",
108] 120]
109 121
110[[package]] 122[[package]]
@@ -132,12 +144,6 @@ dependencies = [
132] 144]
133 145
134[[package]] 146[[package]]
135name = "dtoa"
136version = "0.4.8"
137source = "registry+https://github.com/rust-lang/crates.io-index"
138checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0"
139
140[[package]]
141name = "env_logger" 147name = "env_logger"
142version = "0.6.2" 148version = "0.6.2"
143source = "registry+https://github.com/rust-lang/crates.io-index" 149source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -157,30 +163,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
157checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 163checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
158 164
159[[package]] 165[[package]]
160name = "form_urlencoded" 166name = "foreign-types"
161version = "1.0.1" 167version = "0.3.2"
162source = "registry+https://github.com/rust-lang/crates.io-index" 168source = "registry+https://github.com/rust-lang/crates.io-index"
163checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" 169checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
164dependencies = [ 170dependencies = [
165 "matches", 171 "foreign-types-shared",
166 "percent-encoding",
167] 172]
168 173
169[[package]] 174[[package]]
170name = "fuchsia-zircon" 175name = "foreign-types-shared"
171version = "0.3.3" 176version = "0.1.1"
172source = "registry+https://github.com/rust-lang/crates.io-index" 177source = "registry+https://github.com/rust-lang/crates.io-index"
173checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" 178checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
174dependencies = [
175 "bitflags",
176 "fuchsia-zircon-sys",
177]
178 179
179[[package]] 180[[package]]
180name = "fuchsia-zircon-sys" 181name = "form_urlencoded"
181version = "0.3.3" 182version = "1.0.1"
182source = "registry+https://github.com/rust-lang/crates.io-index" 183source = "registry+https://github.com/rust-lang/crates.io-index"
183checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" 184checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191"
185dependencies = [
186 "matches",
187 "percent-encoding",
188]
184 189
185[[package]] 190[[package]]
186name = "futures" 191name = "futures"
@@ -239,7 +244,7 @@ dependencies = [
239 "futures-core", 244 "futures-core",
240 "futures-sink", 245 "futures-sink",
241 "futures-task", 246 "futures-task",
242 "pin-project-lite 0.2.6", 247 "pin-project-lite",
243 "pin-utils", 248 "pin-utils",
244 "slab", 249 "slab",
245] 250]
@@ -280,24 +285,28 @@ dependencies = [
280name = "gradecoin" 285name = "gradecoin"
281version = "0.1.0" 286version = "0.1.0"
282dependencies = [ 287dependencies = [
288 "anyhow",
283 "chrono", 289 "chrono",
290 "jsonwebtoken",
284 "log", 291 "log",
285 "parking_lot", 292 "openssl",
293 "parking_lot 0.10.2",
286 "pretty_env_logger", 294 "pretty_env_logger",
287 "serde", 295 "serde",
288 "serde_json", 296 "serde_json",
289 "serde_test", 297 "serde_test",
298 "thiserror",
290 "tokio", 299 "tokio",
291 "warp", 300 "warp",
292] 301]
293 302
294[[package]] 303[[package]]
295name = "h2" 304name = "h2"
296version = "0.2.7" 305version = "0.3.2"
297source = "registry+https://github.com/rust-lang/crates.io-index" 306source = "registry+https://github.com/rust-lang/crates.io-index"
298checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" 307checksum = "fc018e188373e2777d0ef2467ebff62a08e66c3f5857b23c8fbec3018210dc00"
299dependencies = [ 308dependencies = [
300 "bytes 0.5.6", 309 "bytes",
301 "fnv", 310 "fnv",
302 "futures-core", 311 "futures-core",
303 "futures-sink", 312 "futures-sink",
@@ -308,7 +317,6 @@ dependencies = [
308 "tokio", 317 "tokio",
309 "tokio-util", 318 "tokio-util",
310 "tracing", 319 "tracing",
311 "tracing-futures",
312] 320]
313 321
314[[package]] 322[[package]]
@@ -325,7 +333,7 @@ checksum = "f0b7591fb62902706ae8e7aaff416b1b0fa2c0fd0878b46dc13baa3712d8a855"
325dependencies = [ 333dependencies = [
326 "base64 0.13.0", 334 "base64 0.13.0",
327 "bitflags", 335 "bitflags",
328 "bytes 1.0.1", 336 "bytes",
329 "headers-core", 337 "headers-core",
330 "http", 338 "http",
331 "mime", 339 "mime",
@@ -357,19 +365,20 @@ version = "0.2.3"
357source = "registry+https://github.com/rust-lang/crates.io-index" 365source = "registry+https://github.com/rust-lang/crates.io-index"
358checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" 366checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747"
359dependencies = [ 367dependencies = [
360 "bytes 1.0.1", 368 "bytes",
361 "fnv", 369 "fnv",
362 "itoa", 370 "itoa",
363] 371]
364 372
365[[package]] 373[[package]]
366name = "http-body" 374name = "http-body"
367version = "0.3.1" 375version = "0.4.1"
368source = "registry+https://github.com/rust-lang/crates.io-index" 376source = "registry+https://github.com/rust-lang/crates.io-index"
369checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" 377checksum = "5dfb77c123b4e2f72a2069aeae0b4b4949cc7e966df277813fc16347e7549737"
370dependencies = [ 378dependencies = [
371 "bytes 0.5.6", 379 "bytes",
372 "http", 380 "http",
381 "pin-project-lite",
373] 382]
374 383
375[[package]] 384[[package]]
@@ -395,11 +404,11 @@ dependencies = [
395 404
396[[package]] 405[[package]]
397name = "hyper" 406name = "hyper"
398version = "0.13.10" 407version = "0.14.5"
399source = "registry+https://github.com/rust-lang/crates.io-index" 408source = "registry+https://github.com/rust-lang/crates.io-index"
400checksum = "8a6f157065790a3ed2f88679250419b5cdd96e714a0d65f7797fd337186e96bb" 409checksum = "8bf09f61b52cfcf4c00de50df88ae423d6c02354e385a86341133b5338630ad1"
401dependencies = [ 410dependencies = [
402 "bytes 0.5.6", 411 "bytes",
403 "futures-channel", 412 "futures-channel",
404 "futures-core", 413 "futures-core",
405 "futures-util", 414 "futures-util",
@@ -409,7 +418,7 @@ dependencies = [
409 "httparse", 418 "httparse",
410 "httpdate", 419 "httpdate",
411 "itoa", 420 "itoa",
412 "pin-project 1.0.6", 421 "pin-project",
413 "socket2", 422 "socket2",
414 "tokio", 423 "tokio",
415 "tower-service", 424 "tower-service",
@@ -440,20 +449,20 @@ dependencies = [
440 449
441[[package]] 450[[package]]
442name = "input_buffer" 451name = "input_buffer"
443version = "0.3.1" 452version = "0.4.0"
444source = "registry+https://github.com/rust-lang/crates.io-index" 453source = "registry+https://github.com/rust-lang/crates.io-index"
445checksum = "19a8a95243d5a0398cae618ec29477c6e3cb631152be5c19481f80bc71559754" 454checksum = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413"
446dependencies = [ 455dependencies = [
447 "bytes 0.5.6", 456 "bytes",
448] 457]
449 458
450[[package]] 459[[package]]
451name = "iovec" 460name = "instant"
452version = "0.1.4" 461version = "0.1.9"
453source = "registry+https://github.com/rust-lang/crates.io-index" 462source = "registry+https://github.com/rust-lang/crates.io-index"
454checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" 463checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
455dependencies = [ 464dependencies = [
456 "libc", 465 "cfg-if 1.0.0",
457] 466]
458 467
459[[package]] 468[[package]]
@@ -463,13 +472,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
463checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" 472checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
464 473
465[[package]] 474[[package]]
466name = "kernel32-sys" 475name = "js-sys"
467version = "0.2.2" 476version = "0.3.50"
468source = "registry+https://github.com/rust-lang/crates.io-index" 477source = "registry+https://github.com/rust-lang/crates.io-index"
469checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" 478checksum = "2d99f9e3e84b8f67f846ef5b4cbbc3b1c29f6c759fcbce6f01aa0e73d932a24c"
470dependencies = [ 479dependencies = [
471 "winapi 0.2.8", 480 "wasm-bindgen",
472 "winapi-build", 481]
482
483[[package]]
484name = "jsonwebtoken"
485version = "7.2.0"
486source = "registry+https://github.com/rust-lang/crates.io-index"
487checksum = "afabcc15e437a6484fc4f12d0fd63068fe457bf93f1c148d3d9649c60b103f32"
488dependencies = [
489 "base64 0.12.3",
490 "pem",
491 "ring",
492 "serde",
493 "serde_json",
494 "simple_asn1",
473] 495]
474 496
475[[package]] 497[[package]]
@@ -494,6 +516,15 @@ dependencies = [
494] 516]
495 517
496[[package]] 518[[package]]
519name = "lock_api"
520version = "0.4.3"
521source = "registry+https://github.com/rust-lang/crates.io-index"
522checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176"
523dependencies = [
524 "scopeguard",
525]
526
527[[package]]
497name = "log" 528name = "log"
498version = "0.4.14" 529version = "0.4.14"
499source = "registry+https://github.com/rust-lang/crates.io-index" 530source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -532,33 +563,24 @@ dependencies = [
532 563
533[[package]] 564[[package]]
534name = "mio" 565name = "mio"
535version = "0.6.23" 566version = "0.7.11"
536source = "registry+https://github.com/rust-lang/crates.io-index" 567source = "registry+https://github.com/rust-lang/crates.io-index"
537checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" 568checksum = "cf80d3e903b34e0bd7282b218398aec54e082c840d9baf8339e0080a0c542956"
538dependencies = [ 569dependencies = [
539 "cfg-if 0.1.10",
540 "fuchsia-zircon",
541 "fuchsia-zircon-sys",
542 "iovec",
543 "kernel32-sys",
544 "libc", 570 "libc",
545 "log", 571 "log",
546 "miow", 572 "miow",
547 "net2", 573 "ntapi",
548 "slab", 574 "winapi",
549 "winapi 0.2.8",
550] 575]
551 576
552[[package]] 577[[package]]
553name = "miow" 578name = "miow"
554version = "0.2.2" 579version = "0.3.7"
555source = "registry+https://github.com/rust-lang/crates.io-index" 580source = "registry+https://github.com/rust-lang/crates.io-index"
556checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" 581checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
557dependencies = [ 582dependencies = [
558 "kernel32-sys", 583 "winapi",
559 "net2",
560 "winapi 0.2.8",
561 "ws2_32-sys",
562] 584]
563 585
564[[package]] 586[[package]]
@@ -580,14 +602,23 @@ dependencies = [
580] 602]
581 603
582[[package]] 604[[package]]
583name = "net2" 605name = "ntapi"
584version = "0.2.37" 606version = "0.3.6"
585source = "registry+https://github.com/rust-lang/crates.io-index" 607source = "registry+https://github.com/rust-lang/crates.io-index"
586checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" 608checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
587dependencies = [ 609dependencies = [
588 "cfg-if 0.1.10", 610 "winapi",
589 "libc", 611]
590 "winapi 0.3.9", 612
613[[package]]
614name = "num-bigint"
615version = "0.2.6"
616source = "registry+https://github.com/rust-lang/crates.io-index"
617checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304"
618dependencies = [
619 "autocfg",
620 "num-integer",
621 "num-traits",
591] 622]
592 623
593[[package]] 624[[package]]
@@ -610,19 +641,73 @@ dependencies = [
610] 641]
611 642
612[[package]] 643[[package]]
644name = "num_cpus"
645version = "1.13.0"
646source = "registry+https://github.com/rust-lang/crates.io-index"
647checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
648dependencies = [
649 "hermit-abi",
650 "libc",
651]
652
653[[package]]
654name = "once_cell"
655version = "1.7.2"
656source = "registry+https://github.com/rust-lang/crates.io-index"
657checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3"
658
659[[package]]
613name = "opaque-debug" 660name = "opaque-debug"
614version = "0.3.0" 661version = "0.3.0"
615source = "registry+https://github.com/rust-lang/crates.io-index" 662source = "registry+https://github.com/rust-lang/crates.io-index"
616checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" 663checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
617 664
618[[package]] 665[[package]]
666name = "openssl"
667version = "0.10.33"
668source = "registry+https://github.com/rust-lang/crates.io-index"
669checksum = "a61075b62a23fef5a29815de7536d940aa35ce96d18ce0cc5076272db678a577"
670dependencies = [
671 "bitflags",
672 "cfg-if 1.0.0",
673 "foreign-types",
674 "libc",
675 "once_cell",
676 "openssl-sys",
677]
678
679[[package]]
680name = "openssl-sys"
681version = "0.9.61"
682source = "registry+https://github.com/rust-lang/crates.io-index"
683checksum = "313752393519e876837e09e1fa183ddef0be7735868dced3196f4472d536277f"
684dependencies = [
685 "autocfg",
686 "cc",
687 "libc",
688 "pkg-config",
689 "vcpkg",
690]
691
692[[package]]
619name = "parking_lot" 693name = "parking_lot"
620version = "0.10.2" 694version = "0.10.2"
621source = "registry+https://github.com/rust-lang/crates.io-index" 695source = "registry+https://github.com/rust-lang/crates.io-index"
622checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" 696checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e"
623dependencies = [ 697dependencies = [
624 "lock_api", 698 "lock_api 0.3.4",
625 "parking_lot_core", 699 "parking_lot_core 0.7.2",
700]
701
702[[package]]
703name = "parking_lot"
704version = "0.11.1"
705source = "registry+https://github.com/rust-lang/crates.io-index"
706checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
707dependencies = [
708 "instant",
709 "lock_api 0.4.3",
710 "parking_lot_core 0.8.3",
626] 711]
627 712
628[[package]] 713[[package]]
@@ -636,42 +721,47 @@ dependencies = [
636 "libc", 721 "libc",
637 "redox_syscall 0.1.57", 722 "redox_syscall 0.1.57",
638 "smallvec", 723 "smallvec",
639 "winapi 0.3.9", 724 "winapi",
640] 725]
641 726
642[[package]] 727[[package]]
643name = "percent-encoding" 728name = "parking_lot_core"
644version = "2.1.0" 729version = "0.8.3"
645source = "registry+https://github.com/rust-lang/crates.io-index" 730source = "registry+https://github.com/rust-lang/crates.io-index"
646checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" 731checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
732dependencies = [
733 "cfg-if 1.0.0",
734 "instant",
735 "libc",
736 "redox_syscall 0.2.5",
737 "smallvec",
738 "winapi",
739]
647 740
648[[package]] 741[[package]]
649name = "pin-project" 742name = "pem"
650version = "0.4.28" 743version = "0.8.3"
651source = "registry+https://github.com/rust-lang/crates.io-index" 744source = "registry+https://github.com/rust-lang/crates.io-index"
652checksum = "918192b5c59119d51e0cd221f4d49dde9112824ba717369e903c97d076083d0f" 745checksum = "fd56cbd21fea48d0c440b41cd69c589faacade08c992d9a54e471b79d0fd13eb"
653dependencies = [ 746dependencies = [
654 "pin-project-internal 0.4.28", 747 "base64 0.13.0",
748 "once_cell",
749 "regex",
655] 750]
656 751
657[[package]] 752[[package]]
658name = "pin-project" 753name = "percent-encoding"
659version = "1.0.6" 754version = "2.1.0"
660source = "registry+https://github.com/rust-lang/crates.io-index" 755source = "registry+https://github.com/rust-lang/crates.io-index"
661checksum = "bc174859768806e91ae575187ada95c91a29e96a98dc5d2cd9a1fed039501ba6" 756checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
662dependencies = [
663 "pin-project-internal 1.0.6",
664]
665 757
666[[package]] 758[[package]]
667name = "pin-project-internal" 759name = "pin-project"
668version = "0.4.28" 760version = "1.0.6"
669source = "registry+https://github.com/rust-lang/crates.io-index" 761source = "registry+https://github.com/rust-lang/crates.io-index"
670checksum = "3be26700300be6d9d23264c73211d8190e755b6b5ca7a1b28230025511b52a5e" 762checksum = "bc174859768806e91ae575187ada95c91a29e96a98dc5d2cd9a1fed039501ba6"
671dependencies = [ 763dependencies = [
672 "proc-macro2", 764 "pin-project-internal",
673 "quote",
674 "syn",
675] 765]
676 766
677[[package]] 767[[package]]
@@ -687,12 +777,6 @@ dependencies = [
687 777
688[[package]] 778[[package]]
689name = "pin-project-lite" 779name = "pin-project-lite"
690version = "0.1.12"
691source = "registry+https://github.com/rust-lang/crates.io-index"
692checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777"
693
694[[package]]
695name = "pin-project-lite"
696version = "0.2.6" 780version = "0.2.6"
697source = "registry+https://github.com/rust-lang/crates.io-index" 781source = "registry+https://github.com/rust-lang/crates.io-index"
698checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" 782checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
@@ -704,6 +788,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
704checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 788checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
705 789
706[[package]] 790[[package]]
791name = "pkg-config"
792version = "0.3.19"
793source = "registry+https://github.com/rust-lang/crates.io-index"
794checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
795
796[[package]]
707name = "ppv-lite86" 797name = "ppv-lite86"
708version = "0.2.10" 798version = "0.2.10"
709source = "registry+https://github.com/rust-lang/crates.io-index" 799source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -863,7 +953,22 @@ version = "0.5.3"
863source = "registry+https://github.com/rust-lang/crates.io-index" 953source = "registry+https://github.com/rust-lang/crates.io-index"
864checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" 954checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
865dependencies = [ 955dependencies = [
866 "winapi 0.3.9", 956 "winapi",
957]
958
959[[package]]
960name = "ring"
961version = "0.16.20"
962source = "registry+https://github.com/rust-lang/crates.io-index"
963checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
964dependencies = [
965 "cc",
966 "libc",
967 "once_cell",
968 "spin",
969 "untrusted",
970 "web-sys",
971 "winapi",
867] 972]
868 973
869[[package]] 974[[package]]
@@ -932,14 +1037,14 @@ dependencies = [
932 1037
933[[package]] 1038[[package]]
934name = "serde_urlencoded" 1039name = "serde_urlencoded"
935version = "0.6.1" 1040version = "0.7.0"
936source = "registry+https://github.com/rust-lang/crates.io-index" 1041source = "registry+https://github.com/rust-lang/crates.io-index"
937checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" 1042checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9"
938dependencies = [ 1043dependencies = [
939 "dtoa", 1044 "form_urlencoded",
940 "itoa", 1045 "itoa",
1046 "ryu",
941 "serde", 1047 "serde",
942 "url",
943] 1048]
944 1049
945[[package]] 1050[[package]]
@@ -956,6 +1061,26 @@ dependencies = [
956] 1061]
957 1062
958[[package]] 1063[[package]]
1064name = "signal-hook-registry"
1065version = "1.3.0"
1066source = "registry+https://github.com/rust-lang/crates.io-index"
1067checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6"
1068dependencies = [
1069 "libc",
1070]
1071
1072[[package]]
1073name = "simple_asn1"
1074version = "0.4.1"
1075source = "registry+https://github.com/rust-lang/crates.io-index"
1076checksum = "692ca13de57ce0613a363c8c2f1de925adebc81b04c923ac60c5488bb44abe4b"
1077dependencies = [
1078 "chrono",
1079 "num-bigint",
1080 "num-traits",
1081]
1082
1083[[package]]
959name = "slab" 1084name = "slab"
960version = "0.4.2" 1085version = "0.4.2"
961source = "registry+https://github.com/rust-lang/crates.io-index" 1086source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -969,16 +1094,21 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
969 1094
970[[package]] 1095[[package]]
971name = "socket2" 1096name = "socket2"
972version = "0.3.19" 1097version = "0.4.0"
973source = "registry+https://github.com/rust-lang/crates.io-index" 1098source = "registry+https://github.com/rust-lang/crates.io-index"
974checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" 1099checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2"
975dependencies = [ 1100dependencies = [
976 "cfg-if 1.0.0",
977 "libc", 1101 "libc",
978 "winapi 0.3.9", 1102 "winapi",
979] 1103]
980 1104
981[[package]] 1105[[package]]
1106name = "spin"
1107version = "0.5.2"
1108source = "registry+https://github.com/rust-lang/crates.io-index"
1109checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
1110
1111[[package]]
982name = "syn" 1112name = "syn"
983version = "1.0.68" 1113version = "1.0.68"
984source = "registry+https://github.com/rust-lang/crates.io-index" 1114source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1000,7 +1130,7 @@ dependencies = [
1000 "rand 0.8.3", 1130 "rand 0.8.3",
1001 "redox_syscall 0.2.5", 1131 "redox_syscall 0.2.5",
1002 "remove_dir_all", 1132 "remove_dir_all",
1003 "winapi 0.3.9", 1133 "winapi",
1004] 1134]
1005 1135
1006[[package]] 1136[[package]]
@@ -1013,6 +1143,26 @@ dependencies = [
1013] 1143]
1014 1144
1015[[package]] 1145[[package]]
1146name = "thiserror"
1147version = "1.0.24"
1148source = "registry+https://github.com/rust-lang/crates.io-index"
1149checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e"
1150dependencies = [
1151 "thiserror-impl",
1152]
1153
1154[[package]]
1155name = "thiserror-impl"
1156version = "1.0.24"
1157source = "registry+https://github.com/rust-lang/crates.io-index"
1158checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
1159dependencies = [
1160 "proc-macro2",
1161 "quote",
1162 "syn",
1163]
1164
1165[[package]]
1016name = "time" 1166name = "time"
1017version = "0.1.44" 1167version = "0.1.44"
1018source = "registry+https://github.com/rust-lang/crates.io-index" 1168source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1020,7 +1170,7 @@ checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
1020dependencies = [ 1170dependencies = [
1021 "libc", 1171 "libc",
1022 "wasi 0.10.0+wasi-snapshot-preview1", 1172 "wasi 0.10.0+wasi-snapshot-preview1",
1023 "winapi 0.3.9", 1173 "winapi",
1024] 1174]
1025 1175
1026[[package]] 1176[[package]]
@@ -1040,27 +1190,29 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
1040 1190
1041[[package]] 1191[[package]]
1042name = "tokio" 1192name = "tokio"
1043version = "0.2.25" 1193version = "1.4.0"
1044source = "registry+https://github.com/rust-lang/crates.io-index" 1194source = "registry+https://github.com/rust-lang/crates.io-index"
1045checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" 1195checksum = "134af885d758d645f0f0505c9a8b3f9bf8a348fd822e112ab5248138348f1722"
1046dependencies = [ 1196dependencies = [
1047 "bytes 0.5.6", 1197 "autocfg",
1048 "fnv", 1198 "bytes",
1049 "futures-core", 1199 "libc",
1050 "iovec",
1051 "lazy_static",
1052 "memchr", 1200 "memchr",
1053 "mio", 1201 "mio",
1054 "pin-project-lite 0.1.12", 1202 "num_cpus",
1055 "slab", 1203 "once_cell",
1204 "parking_lot 0.11.1",
1205 "pin-project-lite",
1206 "signal-hook-registry",
1056 "tokio-macros", 1207 "tokio-macros",
1208 "winapi",
1057] 1209]
1058 1210
1059[[package]] 1211[[package]]
1060name = "tokio-macros" 1212name = "tokio-macros"
1061version = "0.2.6" 1213version = "1.1.0"
1062source = "registry+https://github.com/rust-lang/crates.io-index" 1214source = "registry+https://github.com/rust-lang/crates.io-index"
1063checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" 1215checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57"
1064dependencies = [ 1216dependencies = [
1065 "proc-macro2", 1217 "proc-macro2",
1066 "quote", 1218 "quote",
@@ -1068,29 +1220,40 @@ dependencies = [
1068] 1220]
1069 1221
1070[[package]] 1222[[package]]
1223name = "tokio-stream"
1224version = "0.1.5"
1225source = "registry+https://github.com/rust-lang/crates.io-index"
1226checksum = "e177a5d8c3bf36de9ebe6d58537d8879e964332f93fb3339e43f618c81361af0"
1227dependencies = [
1228 "futures-core",
1229 "pin-project-lite",
1230 "tokio",
1231]
1232
1233[[package]]
1071name = "tokio-tungstenite" 1234name = "tokio-tungstenite"
1072version = "0.11.0" 1235version = "0.13.0"
1073source = "registry+https://github.com/rust-lang/crates.io-index" 1236source = "registry+https://github.com/rust-lang/crates.io-index"
1074checksum = "6d9e878ad426ca286e4dcae09cbd4e1973a7f8987d97570e2469703dd7f5720c" 1237checksum = "e1a5f475f1b9d077ea1017ecbc60890fda8e54942d680ca0b1d2b47cfa2d861b"
1075dependencies = [ 1238dependencies = [
1076 "futures-util", 1239 "futures-util",
1077 "log", 1240 "log",
1078 "pin-project 0.4.28", 1241 "pin-project",
1079 "tokio", 1242 "tokio",
1080 "tungstenite", 1243 "tungstenite",
1081] 1244]
1082 1245
1083[[package]] 1246[[package]]
1084name = "tokio-util" 1247name = "tokio-util"
1085version = "0.3.1" 1248version = "0.6.5"
1086source = "registry+https://github.com/rust-lang/crates.io-index" 1249source = "registry+https://github.com/rust-lang/crates.io-index"
1087checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" 1250checksum = "5143d049e85af7fbc36f5454d990e62c2df705b3589f123b71f441b6b59f443f"
1088dependencies = [ 1251dependencies = [
1089 "bytes 0.5.6", 1252 "bytes",
1090 "futures-core", 1253 "futures-core",
1091 "futures-sink", 1254 "futures-sink",
1092 "log", 1255 "log",
1093 "pin-project-lite 0.1.12", 1256 "pin-project-lite",
1094 "tokio", 1257 "tokio",
1095] 1258]
1096 1259
@@ -1108,7 +1271,7 @@ checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f"
1108dependencies = [ 1271dependencies = [
1109 "cfg-if 1.0.0", 1272 "cfg-if 1.0.0",
1110 "log", 1273 "log",
1111 "pin-project-lite 0.2.6", 1274 "pin-project-lite",
1112 "tracing-core", 1275 "tracing-core",
1113] 1276]
1114 1277
@@ -1122,16 +1285,6 @@ dependencies = [
1122] 1285]
1123 1286
1124[[package]] 1287[[package]]
1125name = "tracing-futures"
1126version = "0.2.5"
1127source = "registry+https://github.com/rust-lang/crates.io-index"
1128checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
1129dependencies = [
1130 "pin-project 1.0.6",
1131 "tracing",
1132]
1133
1134[[package]]
1135name = "try-lock" 1288name = "try-lock"
1136version = "0.2.3" 1289version = "0.2.3"
1137source = "registry+https://github.com/rust-lang/crates.io-index" 1290source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1139,18 +1292,18 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
1139 1292
1140[[package]] 1293[[package]]
1141name = "tungstenite" 1294name = "tungstenite"
1142version = "0.11.1" 1295version = "0.12.0"
1143source = "registry+https://github.com/rust-lang/crates.io-index" 1296source = "registry+https://github.com/rust-lang/crates.io-index"
1144checksum = "f0308d80d86700c5878b9ef6321f020f29b1bb9d5ff3cab25e75e23f3a492a23" 1297checksum = "8ada8297e8d70872fa9a551d93250a9f407beb9f37ef86494eb20012a2ff7c24"
1145dependencies = [ 1298dependencies = [
1146 "base64 0.12.3", 1299 "base64 0.13.0",
1147 "byteorder", 1300 "byteorder",
1148 "bytes 0.5.6", 1301 "bytes",
1149 "http", 1302 "http",
1150 "httparse", 1303 "httparse",
1151 "input_buffer", 1304 "input_buffer",
1152 "log", 1305 "log",
1153 "rand 0.7.3", 1306 "rand 0.8.3",
1154 "sha-1", 1307 "sha-1",
1155 "url", 1308 "url",
1156 "utf-8", 1309 "utf-8",
@@ -1205,6 +1358,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1205checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" 1358checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
1206 1359
1207[[package]] 1360[[package]]
1361name = "untrusted"
1362version = "0.7.1"
1363source = "registry+https://github.com/rust-lang/crates.io-index"
1364checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
1365
1366[[package]]
1208name = "url" 1367name = "url"
1209version = "2.2.1" 1368version = "2.2.1"
1210source = "registry+https://github.com/rust-lang/crates.io-index" 1369source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1217,18 +1376,18 @@ dependencies = [
1217] 1376]
1218 1377
1219[[package]] 1378[[package]]
1220name = "urlencoding"
1221version = "1.1.1"
1222source = "registry+https://github.com/rust-lang/crates.io-index"
1223checksum = "c9232eb53352b4442e40d7900465dfc534e8cb2dc8f18656fcb2ac16112b5593"
1224
1225[[package]]
1226name = "utf-8" 1379name = "utf-8"
1227version = "0.7.5" 1380version = "0.7.5"
1228source = "registry+https://github.com/rust-lang/crates.io-index" 1381source = "registry+https://github.com/rust-lang/crates.io-index"
1229checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" 1382checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7"
1230 1383
1231[[package]] 1384[[package]]
1385name = "vcpkg"
1386version = "0.2.11"
1387source = "registry+https://github.com/rust-lang/crates.io-index"
1388checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb"
1389
1390[[package]]
1232name = "version_check" 1391name = "version_check"
1233version = "0.9.3" 1392version = "0.9.3"
1234source = "registry+https://github.com/rust-lang/crates.io-index" 1393source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1246,11 +1405,11 @@ dependencies = [
1246 1405
1247[[package]] 1406[[package]]
1248name = "warp" 1407name = "warp"
1249version = "0.2.5" 1408version = "0.3.1"
1250source = "registry+https://github.com/rust-lang/crates.io-index" 1409source = "registry+https://github.com/rust-lang/crates.io-index"
1251checksum = "f41be6df54c97904af01aa23e613d4521eed7ab23537cede692d4058f6449407" 1410checksum = "332d47745e9a0c38636dbd454729b147d16bd1ed08ae67b3ab281c4506771054"
1252dependencies = [ 1411dependencies = [
1253 "bytes 0.5.6", 1412 "bytes",
1254 "futures", 1413 "futures",
1255 "headers", 1414 "headers",
1256 "http", 1415 "http",
@@ -1259,17 +1418,18 @@ dependencies = [
1259 "mime", 1418 "mime",
1260 "mime_guess", 1419 "mime_guess",
1261 "multipart", 1420 "multipart",
1262 "pin-project 0.4.28", 1421 "percent-encoding",
1422 "pin-project",
1263 "scoped-tls", 1423 "scoped-tls",
1264 "serde", 1424 "serde",
1265 "serde_json", 1425 "serde_json",
1266 "serde_urlencoded", 1426 "serde_urlencoded",
1267 "tokio", 1427 "tokio",
1428 "tokio-stream",
1268 "tokio-tungstenite", 1429 "tokio-tungstenite",
1430 "tokio-util",
1269 "tower-service", 1431 "tower-service",
1270 "tracing", 1432 "tracing",
1271 "tracing-futures",
1272 "urlencoding",
1273] 1433]
1274 1434
1275[[package]] 1435[[package]]
@@ -1285,10 +1445,68 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1285checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" 1445checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
1286 1446
1287[[package]] 1447[[package]]
1288name = "winapi" 1448name = "wasm-bindgen"
1289version = "0.2.8" 1449version = "0.2.73"
1450source = "registry+https://github.com/rust-lang/crates.io-index"
1451checksum = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9"
1452dependencies = [
1453 "cfg-if 1.0.0",
1454 "wasm-bindgen-macro",
1455]
1456
1457[[package]]
1458name = "wasm-bindgen-backend"
1459version = "0.2.73"
1460source = "registry+https://github.com/rust-lang/crates.io-index"
1461checksum = "ae70622411ca953215ca6d06d3ebeb1e915f0f6613e3b495122878d7ebec7dae"
1462dependencies = [
1463 "bumpalo",
1464 "lazy_static",
1465 "log",
1466 "proc-macro2",
1467 "quote",
1468 "syn",
1469 "wasm-bindgen-shared",
1470]
1471
1472[[package]]
1473name = "wasm-bindgen-macro"
1474version = "0.2.73"
1475source = "registry+https://github.com/rust-lang/crates.io-index"
1476checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f"
1477dependencies = [
1478 "quote",
1479 "wasm-bindgen-macro-support",
1480]
1481
1482[[package]]
1483name = "wasm-bindgen-macro-support"
1484version = "0.2.73"
1485source = "registry+https://github.com/rust-lang/crates.io-index"
1486checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c"
1487dependencies = [
1488 "proc-macro2",
1489 "quote",
1490 "syn",
1491 "wasm-bindgen-backend",
1492 "wasm-bindgen-shared",
1493]
1494
1495[[package]]
1496name = "wasm-bindgen-shared"
1497version = "0.2.73"
1290source = "registry+https://github.com/rust-lang/crates.io-index" 1498source = "registry+https://github.com/rust-lang/crates.io-index"
1291checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" 1499checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489"
1500
1501[[package]]
1502name = "web-sys"
1503version = "0.3.50"
1504source = "registry+https://github.com/rust-lang/crates.io-index"
1505checksum = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be"
1506dependencies = [
1507 "js-sys",
1508 "wasm-bindgen",
1509]
1292 1510
1293[[package]] 1511[[package]]
1294name = "winapi" 1512name = "winapi"
@@ -1301,12 +1519,6 @@ dependencies = [
1301] 1519]
1302 1520
1303[[package]] 1521[[package]]
1304name = "winapi-build"
1305version = "0.1.1"
1306source = "registry+https://github.com/rust-lang/crates.io-index"
1307checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
1308
1309[[package]]
1310name = "winapi-i686-pc-windows-gnu" 1522name = "winapi-i686-pc-windows-gnu"
1311version = "0.4.0" 1523version = "0.4.0"
1312source = "registry+https://github.com/rust-lang/crates.io-index" 1524source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1318,7 +1530,7 @@ version = "0.1.5"
1318source = "registry+https://github.com/rust-lang/crates.io-index" 1530source = "registry+https://github.com/rust-lang/crates.io-index"
1319checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 1531checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
1320dependencies = [ 1532dependencies = [
1321 "winapi 0.3.9", 1533 "winapi",
1322] 1534]
1323 1535
1324[[package]] 1536[[package]]
@@ -1326,13 +1538,3 @@ name = "winapi-x86_64-pc-windows-gnu"
1326version = "0.4.0" 1538version = "0.4.0"
1327source = "registry+https://github.com/rust-lang/crates.io-index" 1539source = "registry+https://github.com/rust-lang/crates.io-index"
1328checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1540checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
1329
1330[[package]]
1331name = "ws2_32-sys"
1332version = "0.2.1"
1333source = "registry+https://github.com/rust-lang/crates.io-index"
1334checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
1335dependencies = [
1336 "winapi 0.2.8",
1337 "winapi-build",
1338]
diff --git a/Cargo.toml b/Cargo.toml
index a203a6f..cffb196 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,13 +7,17 @@ edition = "2018"
7# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8 8
9[dependencies] 9[dependencies]
10warp = "0.2.0" 10warp = "0.3"
11tokio = { version = "0.2.9", features = ["macros"] } 11tokio = { version = "1", features = ["full"] }
12serde = { version = "1.0.104", features = ["derive"] } 12serde = { version = "1.0.125", features = ["derive"] }
13chrono = { version = "0.4.10", features = ["serde"] } 13chrono = { version = "0.4.10", features = ["serde"] }
14log = "0.4.8" 14log = "0.4.8"
15anyhow = "1.0.40"
15pretty_env_logger = "0.3.1" 16pretty_env_logger = "0.3.1"
16parking_lot = "0.10.0" 17parking_lot = "0.10.0"
18thiserror = "1.0"
19jsonwebtoken = "7"
20openssl = "0.10.28"
17 21
18[dev-dependencies] 22[dev-dependencies]
19serde_json = "1.0.44" 23serde_json = "1.0.44"
diff --git a/README.md b/README.md
index 664336c..33da21f 100644
--- a/README.md
+++ b/README.md
@@ -16,12 +16,12 @@ $ curl --location --request POST 'localhost:8080/transaction' --header 'Content-
16# how? 16# how?
17 17
18## authentication 18## authentication
19Students generate their own `keypairs` and authenticate with their METU Student IDs. 19- Student generates a 2048 bit RSA Public Key (PK) / Private Key (PR) pair (available in python, c++, rust, gpg)
20Some JWT scheme, coming up. 20- They then encrypt their PKs and Student IDs with Gradecoin's PK (will be published)
21 21- They use their PR as the signing key for JWTs
22Authenticated students propose transactions, between them and another node (=public keys) or between the grader (=bank) and themselves.
23 22
24## transactions 23## transactions
24Students propose transactions, between them and another node (=public keys) or between the grader (=bank) and themselves.
25Transactions are `signed` using the proposers private key. 25Transactions are `signed` using the proposers private key.
26(This whole public/private key + signing process will require some crypto dependency, **todo**) 26(This whole public/private key + signing process will require some crypto dependency, **todo**)
27 27
diff --git a/TODO.md b/TODO.md
index 7b58d96..4810390 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,4 +1,8 @@
1# TODO 1# TODO
2
3## Schema
4- [ ] It would be a good idea to keep blockchain and users in a database and only have `pending_transactions` in memory https://blog.logrocket.com/create-an-async-crud-web-service-in-rust-with-warp/
5
2## Process 6## Process
3- [ ] we need our own representation of students and their grades, "there is no blockchain" 7- [ ] we need our own representation of students and their grades, "there is no blockchain"
4 8
diff --git a/src/auth.rs b/src/auth.rs
new file mode 100644
index 0000000..e22262c
--- /dev/null
+++ b/src/auth.rs
@@ -0,0 +1,112 @@
1use crate::error::Error;
2use crate::schema::{Db, Transaction};
3use jsonwebtoken::{decode, Algorithm, DecodingKey, Validation};
4use serde::{Deserialize, Serialize};
5use warp::header::headers_cloned;
6use warp::http::header::{HeaderMap, HeaderValue, AUTHORIZATION};
7use warp::{reject, Filter, Rejection};
8use thiserror::Error;
9use anyhow::*;
10
11const BEARER: &str = "Bearer ";
12const PUBLIC_KEY_PEM: &str = "-----BEGIN PUBLIC KEY-----
13MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4nU0G4WjkmcQUx0hq6LQ
14uV5Q+ACmUFL/OjoYMDwC/O/6pCd1UZgCfgHN2xEffDPznzcTn8OiFRxr4oWyBiny
15rUpnY4mhy0SQUwoeCw7YkcHAyhCjNT74aR/ohX0MCj0qRRdbt5ZQXM/GC3HJuXE1
16ptSuhFgQxziItamn8maoJ6JUSVEXVO1NOrrjoM3r7Q+BK2B+sX4/bLZ+VG5g1q2n
17EbFdTHS6pHqtZNHQndTmEKwRfh0RYtzEzOXuO6e1gQY42Tujkof40dhGCIU7TeIG
18GHwdFxy1niLkXwtHNjV7lnIOkTbx6+sSPamRfQAlZqUWM2Lf5o+7h3qWP3ENB138
19sQIDAQAB
20-----END PUBLIC KEY-----";
21
22// const private_key_pem: &str = "-----BEGIN RSA PRIVATE KEY-----
23// MIIEpAIBAAKCAQEA4nU0G4WjkmcQUx0hq6LQuV5Q+ACmUFL/OjoYMDwC/O/6pCd1
24// UZgCfgHN2xEffDPznzcTn8OiFRxr4oWyBinyrUpnY4mhy0SQUwoeCw7YkcHAyhCj
25// NT74aR/ohX0MCj0qRRdbt5ZQXM/GC3HJuXE1ptSuhFgQxziItamn8maoJ6JUSVEX
26// VO1NOrrjoM3r7Q+BK2B+sX4/bLZ+VG5g1q2nEbFdTHS6pHqtZNHQndTmEKwRfh0R
27// YtzEzOXuO6e1gQY42Tujkof40dhGCIU7TeIGGHwdFxy1niLkXwtHNjV7lnIOkTbx
28// 6+sSPamRfQAlZqUWM2Lf5o+7h3qWP3ENB138sQIDAQABAoIBAD23nYTmrganag6M
29// wPFrBSGP79c3Lhx0EjUHQjJbGKFgsdltG48qM3ut+DF9ACy0Z+/7bbC7+39vaIOq
30// 1jLR2d6aiYTaLKseO4s2FawD1sgamvU3BZPsXn0gAhnnU5Gyy8Nas1dccvhoc9wI
31// neaZUPrvucQ90AzLfo6r9yacDbYHB1lOyomApUvpJxOgHISGEtc9qGPDrdH19aF0
32// 8fCv2bbQRh+TChgN3IB0o5w0wXaI7YAyAouAv/AzHCoEMpt7OGjFTkjh/ujlPL9O
33// +FLuJNsQRHDN0gJo2pcvwGwDCsioMixQ9bZ7ZrUu2BNpEQygyeSbj9ZI1iRvhosO
34// JU3rwEECgYEA9MppTYA6A9WQbCCwPH1QMpUAmPNVSWVhUVag4lGOEhdCDRcz9ook
35// DohQMKctiEB1luKuvDokxo0uMOfMO9/YwjsRB7qjQip7Th1zMJIjD+A+juLzHK4r
36// /RiRtWYGAnF8mptDvE+93JsPb3C/lQLvIhio5GQYWBqPJu6SpeosIskCgYEA7NPi
37// Gbffzr2UQhW8BNKmctEEh8yFRVojFo3wwwWxSNUVXGSmSm31CL+Q8h817R+2OkPV
38// 1ZMUOBU4UJiqFt28kIvTDFqbAJlJQGCpY2mY7OLQiD2A+TVLcFrHmoCaPfCAK1Qd
39// hQ0PmFK7Mf8qClpA3E5chop/WfKQfiu46sZv1qkCgYAhGdXPcw1lQ1W6KVlrdI6J
40// qHhiNlVMDXdxZkNvFxQdAiQeXQrbxaZGiMw/J/wSNpUwCAsUzM/4QVMDrfSCDCzl
41// ZtNQtj4pTlFKKNVQthIjrXEIJUw2jp7IJLBfVSJu5iWxSlmId0f3MsiNizN81N69
42// P5Rm/doE3+KHoy8VXGsHcQKBgQCkNh62enqjHWypjex6450qS6f6iWN3PRLLVsw0
43// TcQpniZblCaBwVCAKmRUnjOEIdL2/4ZLutnwMTaFG/YEOOfAylMiY8jKV38lNmD9
44// X4D78CFr9klxgvS2CRwSE03f2NzmLkLxuKaxldvaxPTfjMkgeO1LFMlNExYBhkuH
45// 7uQpUQKBgQCKX6qMNh2gSdgG7qyxfTFZ4y5EGOBoKe/dE+IcVF3Vnh6DZVbCAbBL
46// 5EdFWZSrCnDjA4xiKW55mwp95Ud9EZsZAb13L8V9t82eK+UDBoWlb7VRNYpda/x1
47// 5/i4qQJ28x2UNJDStpYFpnp4Ba1lvXjKngIbDPkjU+hbBJ+BNGAIeg==
48// -----END RSA PRIVATE KEY-----";
49
50/// sub: Subject, user identifier
51/// exp: Expiration date, Unix Time, epoch
52/// puk: Public Key? Not 100% on this
53#[derive(Debug, Serialize, Deserialize)]
54struct Claims {
55 sub: String,
56 exp: usize,
57 puk: String,
58}
59
60// #[derive(Error, Debug)]
61// pub enum Nope {
62// #[error("Invalid header")]
63// InvalidHeader {
64// expected: String,
65// found: String,
66// },
67// }
68
69pub fn with_auth(
70 db: Db,
71 t: Transaction,
72) -> impl Filter<Extract = (String,), Error = Rejection> + Clone {
73 headers_cloned()
74 .map(move |headers: HeaderMap<HeaderValue>| (db.clone(), headers))
75 .and_then(authorize)
76}
77
78impl warp::reject::Reject for Nope {}
79
80async fn authorize((db, headers): (Db, HeaderMap<HeaderValue>)) -> Result<String, Error> {
81 match jwt_from_header(&headers) {
82 Ok(jwt) => {
83 let decoded = decode::<Claims>(
84 &jwt,
85 // TODO: what key are we using here? pass db/pw store here to get the claimant's
86 // public key <10-04-21, yigit> //
87 &DecodingKey::from_rsa_pem(PUBLIC_KEY_PEM.as_bytes()).unwrap(),
88 &Validation::new(Algorithm::HS512),
89 )
90 .map_err(|_| reject::custom(Error::JWTTokenError))
91 .unwrap();
92
93 Ok(decoded.claims.puk)
94 }
95 Err(e) => return Err(anyhow!("missing!"));
96 }
97}
98
99fn jwt_from_header(headers: &HeaderMap<HeaderValue>) -> Result<String, Error> {
100 let header = match headers.get(AUTHORIZATION) {
101 Some(v) => v,
102 None => return Err(Error::NoAuthHeaderError),
103 };
104 let auth_header = match std::str::from_utf8(header.as_bytes()) {
105 Ok(v) => v,
106 Err(_) => return Err(Error::NoAuthHeaderError),
107 };
108 if !auth_header.starts_with(BEARER) {
109 return Err(Error::InvalidAuthHeaderError);
110 }
111 Ok(auth_header.trim_start_matches(BEARER).to_owned())
112}
diff --git a/src/error.rs b/src/error.rs
new file mode 100644
index 0000000..0db26c4
--- /dev/null
+++ b/src/error.rs
@@ -0,0 +1,63 @@
1use serde::Serialize;
2use std::convert::Infallible;
3use thiserror::Error;
4use warp::{http::StatusCode, Rejection, Reply};
5
6#[derive(Error, Debug)]
7pub enum Error {
8 // #[error("wrong credentials")]
9 // WrongCredentialsError,
10 #[error("jwt token not valid")]
11 JWTTokenError,
12 // #[error("jwt token creation error")]
13 // JWTTokenCreationError,
14 #[error("no auth header")]
15 NoAuthHeaderError,
16 #[error("invalid auth header")]
17 InvalidAuthHeaderError,
18 // #[error("no permission")]
19 // NoPermissionError,
20}
21
22#[derive(Serialize, Debug)]
23struct ErrorResponse {
24 message: String,
25 status: String,
26}
27
28impl warp::reject::Reject for Error {}
29
30pub async fn handle_rejection(err: Rejection) -> std::result::Result<impl Reply, Infallible> {
31 let (code, message) = if err.is_not_found() {
32 (StatusCode::NOT_FOUND, "Not Found".to_string())
33 } else if let Some(e) = err.find::<Error>() {
34 match e {
35 // Error::WrongCredentialsError => (StatusCode::FORBIDDEN, e.to_string()),
36 // Error::NoPermissionError => (StatusCode::UNAUTHORIZED, e.to_string()),
37 Error::JWTTokenError => (StatusCode::UNAUTHORIZED, e.to_string()),
38 // Error::JWTTokenCreationError => (
39 // StatusCode::INTERNAL_SERVER_ERROR,
40 // "Internal Server Error".to_string(),
41 // ),
42 _ => (StatusCode::BAD_REQUEST, e.to_string()),
43 }
44 } else if err.find::<warp::reject::MethodNotAllowed>().is_some() {
45 (
46 StatusCode::METHOD_NOT_ALLOWED,
47 "Method Not Allowed".to_string(),
48 )
49 } else {
50 eprintln!("unhandled error: {:?}", err);
51 (
52 StatusCode::INTERNAL_SERVER_ERROR,
53 "Internal Server Error".to_string(),
54 )
55 };
56
57 let json = warp::reply::json(&ErrorResponse {
58 status: code.to_string(),
59 message,
60 });
61
62 Ok(warp::reply::with_status(json, code))
63}
diff --git a/src/handlers.rs b/src/handlers.rs
index 856970d..256e72a 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -58,6 +58,24 @@ pub async fn propose_transaction(
58 Ok(StatusCode::CREATED) 58 Ok(StatusCode::CREATED)
59} 59}
60 60
61/// POST /transaction, authenticated
62/// The transaction arrived in this method has been authored by the public key in the source
63pub async fn propose_authenticated_transaction(
64 pubkey: String,
65 new_transaction: Transaction,
66 db: Db,
67) -> Result<impl warp::Reply, warp::Rejection> {
68 debug!("new transaction request {:?}", new_transaction);
69
70 // let mut transactions = db.lock().await;
71 let mut transactions = db.pending_transactions.write();
72
73 transactions.insert(new_transaction.source.to_owned(), new_transaction);
74
75 Ok(StatusCode::CREATED)
76}
77
78
61/// POST /block 79/// POST /block
62/// Proposes a new block for the next round 80/// Proposes a new block for the next round
63/// Can reject the block 81/// Can reject the block
diff --git a/src/main.rs b/src/main.rs
index 7ef2597..91f6757 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5,6 +5,8 @@ mod custom_filters;
5mod handlers; 5mod handlers;
6mod routes; 6mod routes;
7mod schema; 7mod schema;
8mod auth;
9mod error;
8// mod validators; 10// mod validators;
9 11
10#[tokio::main] 12#[tokio::main]
diff --git a/src/routes.rs b/src/routes.rs
index 95138e6..499ba35 100644
--- a/src/routes.rs
+++ b/src/routes.rs
@@ -1,8 +1,9 @@
1use warp::{Filter, Rejection, Reply}; 1use warp::{Filter, Rejection, Reply};
2 2
3use crate::auth::with_auth;
3use crate::custom_filters; 4use crate::custom_filters;
4use crate::handlers; 5use crate::handlers;
5use crate::schema::Db; 6use crate::schema::{Db, Transaction};
6 7
7/// Root, all routes combined 8/// Root, all routes combined
8pub fn consensus_routes(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { 9pub fn consensus_routes(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
@@ -14,7 +15,8 @@ pub fn consensus_routes(db: Db) -> impl Filter<Extract = impl Reply, Error = Rej
14 15
15/// GET /transaction warp route 16/// GET /transaction warp route
16pub fn transaction_list(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { 17pub fn transaction_list(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
17 warp::path!("transaction") 18 warp::path("transaction")
19 .and(warp::path::end())
18 .and(warp::get()) 20 .and(warp::get())
19 .and(custom_filters::with_db(db)) 21 .and(custom_filters::with_db(db))
20 .and_then(handlers::list_transactions) 22 .and_then(handlers::list_transactions)
@@ -30,13 +32,43 @@ pub fn block_list(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection
30 32
31/// POST /transaction warp route 33/// POST /transaction warp route
32pub fn transaction_propose(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { 34pub fn transaction_propose(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
33 warp::path!("transaction") 35 warp::path("transaction")
36 .and(warp::path::end())
34 .and(warp::post()) 37 .and(warp::post())
35 .and(custom_filters::transaction_json_body()) 38 .and(custom_filters::transaction_json_body())
36 .and(custom_filters::with_db(db)) 39 .and(custom_filters::with_db(db))
37 .and_then(handlers::propose_transaction) 40 .and_then(handlers::propose_transaction)
38} 41}
39 42
43/// POST /transaction warp route with authentication
44pub fn authenticated_transaction_propose(
45 db: Db,
46) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
47 warp::path("transaction")
48 .and(warp::path::end())
49 .and(warp::post())
50 .and(custom_filters::transaction_json_body())
51 .map(|t: Transaction| {
52 with_auth(db.clone(), t)
53 })
54 .untuple_one()
55 .and(custom_filters::transaction_json_body())
56 .and(custom_filters::with_db(db))
57 .and_then(handlers::propose_authenticated_transaction)
58
59 // .and(custom_filters::transaction_json_body())
60 // // TODO: you might have to restore this
61 // // what we're trying to do is knowing which public key to use to decode the jwt in the
62 // // header of the request, we will either request it through a header (ugly, ugh) or get it
63 // // from json (then how do we chain these ugh) or we can just validate/check (move the
64 // // header/jwt logic to propose_transaction but that doesn't feel right either
65 // // good luck <10-04-21, yigit> //
66 // .map(|t: Transaction| with_auth(db.clone(), t))
67 // .and(custom_filters::transaction_json_body())
68 // .and(custom_filters::with_db(db))
69 // .and_then(handlers::propose_transaction)
70}
71
40/// POST /block warp route 72/// POST /block warp route
41pub fn block_propose(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { 73pub fn block_propose(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
42 warp::path!("block") 74 warp::path!("block")
diff --git a/src/schema.rs b/src/schema.rs
index 556e625..c4917ab 100644
--- a/src/schema.rs
+++ b/src/schema.rs
@@ -29,6 +29,8 @@ pub struct Db {
29 pub blockchain: Arc<RwLock<Vec<Block>>>, 29 pub blockchain: Arc<RwLock<Vec<Block>>>,
30 // every proposer can have _one_ pending transaction, a way to enforce this, String is proposer identifier 30 // every proposer can have _one_ pending transaction, a way to enforce this, String is proposer identifier
31 pub pending_transactions: Arc<RwLock<HashMap<String, Transaction>>>, 31 pub pending_transactions: Arc<RwLock<HashMap<String, Transaction>>>,
32 // this was bound to happen eventually
33 pub users: Arc<RwLock<HashMap<String, User>>>,
32} 34}
33 35
34impl Db { 36impl Db {
@@ -36,12 +38,15 @@ impl Db {
36 Db { 38 Db {
37 blockchain: Arc::new(RwLock::new(Vec::new())), 39 blockchain: Arc::new(RwLock::new(Vec::new())),
38 pending_transactions: Arc::new(RwLock::new(HashMap::new())), 40 pending_transactions: Arc::new(RwLock::new(HashMap::new())),
41 users: Arc::new(RwLock::new(HashMap::new())),
39 } 42 }
40 } 43 }
41} 44}
42 45
43/// A transaction between `source` and `target` that moves `amount` 46/// A transaction between `source` and `target` that moves `amount` Note:
44#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] 47/// https://serde.rs/container-attrs.html might be valueable to normalize the serialize/deserialize
48/// conventions as these will be hashed
49#[derive(Serialize, Deserialize, Debug)]
45pub struct Transaction { 50pub struct Transaction {
46 pub source: String, 51 pub source: String,
47 pub target: String, 52 pub target: String,
@@ -65,5 +70,10 @@ pub struct Block {
65 pub hash: String, // future proof'd baby 70 pub hash: String, // future proof'd baby
66} 71}
67 72
73#[derive(Serialize, Deserialize, Debug)]
74pub struct User {
75 username: String,
76 token: String
77}
68 78
69// TODO: write schema tests using the original repo <09-04-21, yigit> // 79// TODO: write schema tests using the original repo <09-04-21, yigit> //