diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Cargo.lock | 566 | ||||
| -rw-r--r-- | Cargo.toml | 10 | ||||
| -rw-r--r-- | README.md | 8 | ||||
| -rw-r--r-- | TODO.md | 4 | ||||
| -rw-r--r-- | src/auth.rs | 112 | ||||
| -rw-r--r-- | src/error.rs | 63 | ||||
| -rw-r--r-- | src/handlers.rs | 18 | ||||
| -rw-r--r-- | src/main.rs | 2 | ||||
| -rw-r--r-- | src/routes.rs | 38 | ||||
| -rw-r--r-- | src/schema.rs | 14 |
11 files changed, 642 insertions, 194 deletions
| @@ -1,3 +1,4 @@ | |||
| 1 | /target | 1 | /target |
| 2 | /secrets | ||
| 2 | tags.lock | 3 | tags.lock |
| 3 | tags.temp | 4 | tags.temp |
| @@ -10,6 +10,12 @@ dependencies = [ | |||
| 10 | ] | 10 | ] |
| 11 | 11 | ||
| 12 | [[package]] | 12 | [[package]] |
| 13 | name = "anyhow" | ||
| 14 | version = "1.0.40" | ||
| 15 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 16 | checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" | ||
| 17 | |||
| 18 | [[package]] | ||
| 13 | name = "atty" | 19 | name = "atty" |
| 14 | version = "0.2.14" | 20 | version = "0.2.14" |
| 15 | source = "registry+https://github.com/rust-lang/crates.io-index" | 21 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -17,7 +23,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" | |||
| 17 | dependencies = [ | 23 | dependencies = [ |
| 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]] |
| 73 | name = "bumpalo" | ||
| 74 | version = "3.6.1" | ||
| 75 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 76 | checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" | ||
| 77 | |||
| 78 | [[package]] | ||
| 67 | name = "byteorder" | 79 | name = "byteorder" |
| 68 | version = "1.4.3" | 80 | version = "1.4.3" |
| 69 | source = "registry+https://github.com/rust-lang/crates.io-index" | 81 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -71,15 +83,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" | |||
| 71 | 83 | ||
| 72 | [[package]] | 84 | [[package]] |
| 73 | name = "bytes" | 85 | name = "bytes" |
| 74 | version = "0.5.6" | 86 | version = "1.0.1" |
| 75 | source = "registry+https://github.com/rust-lang/crates.io-index" | 87 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 76 | checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" | 88 | checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" |
| 77 | 89 | ||
| 78 | [[package]] | 90 | [[package]] |
| 79 | name = "bytes" | 91 | name = "cc" |
| 80 | version = "1.0.1" | 92 | version = "1.0.67" |
| 81 | source = "registry+https://github.com/rust-lang/crates.io-index" | 93 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 82 | checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" | 94 | checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" |
| 83 | 95 | ||
| 84 | [[package]] | 96 | [[package]] |
| 85 | name = "cfg-if" | 97 | name = "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]] |
| 135 | name = "dtoa" | ||
| 136 | version = "0.4.8" | ||
| 137 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 138 | checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" | ||
| 139 | |||
| 140 | [[package]] | ||
| 141 | name = "env_logger" | 147 | name = "env_logger" |
| 142 | version = "0.6.2" | 148 | version = "0.6.2" |
| 143 | source = "registry+https://github.com/rust-lang/crates.io-index" | 149 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -157,30 +163,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 157 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" | 163 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" |
| 158 | 164 | ||
| 159 | [[package]] | 165 | [[package]] |
| 160 | name = "form_urlencoded" | 166 | name = "foreign-types" |
| 161 | version = "1.0.1" | 167 | version = "0.3.2" |
| 162 | source = "registry+https://github.com/rust-lang/crates.io-index" | 168 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 163 | checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" | 169 | checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" |
| 164 | dependencies = [ | 170 | dependencies = [ |
| 165 | "matches", | 171 | "foreign-types-shared", |
| 166 | "percent-encoding", | ||
| 167 | ] | 172 | ] |
| 168 | 173 | ||
| 169 | [[package]] | 174 | [[package]] |
| 170 | name = "fuchsia-zircon" | 175 | name = "foreign-types-shared" |
| 171 | version = "0.3.3" | 176 | version = "0.1.1" |
| 172 | source = "registry+https://github.com/rust-lang/crates.io-index" | 177 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 173 | checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" | 178 | checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" |
| 174 | dependencies = [ | ||
| 175 | "bitflags", | ||
| 176 | "fuchsia-zircon-sys", | ||
| 177 | ] | ||
| 178 | 179 | ||
| 179 | [[package]] | 180 | [[package]] |
| 180 | name = "fuchsia-zircon-sys" | 181 | name = "form_urlencoded" |
| 181 | version = "0.3.3" | 182 | version = "1.0.1" |
| 182 | source = "registry+https://github.com/rust-lang/crates.io-index" | 183 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 183 | checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" | 184 | checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" |
| 185 | dependencies = [ | ||
| 186 | "matches", | ||
| 187 | "percent-encoding", | ||
| 188 | ] | ||
| 184 | 189 | ||
| 185 | [[package]] | 190 | [[package]] |
| 186 | name = "futures" | 191 | name = "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 = [ | |||
| 280 | name = "gradecoin" | 285 | name = "gradecoin" |
| 281 | version = "0.1.0" | 286 | version = "0.1.0" |
| 282 | dependencies = [ | 287 | dependencies = [ |
| 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]] |
| 295 | name = "h2" | 304 | name = "h2" |
| 296 | version = "0.2.7" | 305 | version = "0.3.2" |
| 297 | source = "registry+https://github.com/rust-lang/crates.io-index" | 306 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 298 | checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" | 307 | checksum = "fc018e188373e2777d0ef2467ebff62a08e66c3f5857b23c8fbec3018210dc00" |
| 299 | dependencies = [ | 308 | dependencies = [ |
| 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" | |||
| 325 | dependencies = [ | 333 | dependencies = [ |
| 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" | |||
| 357 | source = "registry+https://github.com/rust-lang/crates.io-index" | 365 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 358 | checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" | 366 | checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" |
| 359 | dependencies = [ | 367 | dependencies = [ |
| 360 | "bytes 1.0.1", | 368 | "bytes", |
| 361 | "fnv", | 369 | "fnv", |
| 362 | "itoa", | 370 | "itoa", |
| 363 | ] | 371 | ] |
| 364 | 372 | ||
| 365 | [[package]] | 373 | [[package]] |
| 366 | name = "http-body" | 374 | name = "http-body" |
| 367 | version = "0.3.1" | 375 | version = "0.4.1" |
| 368 | source = "registry+https://github.com/rust-lang/crates.io-index" | 376 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 369 | checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" | 377 | checksum = "5dfb77c123b4e2f72a2069aeae0b4b4949cc7e966df277813fc16347e7549737" |
| 370 | dependencies = [ | 378 | dependencies = [ |
| 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]] |
| 397 | name = "hyper" | 406 | name = "hyper" |
| 398 | version = "0.13.10" | 407 | version = "0.14.5" |
| 399 | source = "registry+https://github.com/rust-lang/crates.io-index" | 408 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 400 | checksum = "8a6f157065790a3ed2f88679250419b5cdd96e714a0d65f7797fd337186e96bb" | 409 | checksum = "8bf09f61b52cfcf4c00de50df88ae423d6c02354e385a86341133b5338630ad1" |
| 401 | dependencies = [ | 410 | dependencies = [ |
| 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]] |
| 442 | name = "input_buffer" | 451 | name = "input_buffer" |
| 443 | version = "0.3.1" | 452 | version = "0.4.0" |
| 444 | source = "registry+https://github.com/rust-lang/crates.io-index" | 453 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 445 | checksum = "19a8a95243d5a0398cae618ec29477c6e3cb631152be5c19481f80bc71559754" | 454 | checksum = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413" |
| 446 | dependencies = [ | 455 | dependencies = [ |
| 447 | "bytes 0.5.6", | 456 | "bytes", |
| 448 | ] | 457 | ] |
| 449 | 458 | ||
| 450 | [[package]] | 459 | [[package]] |
| 451 | name = "iovec" | 460 | name = "instant" |
| 452 | version = "0.1.4" | 461 | version = "0.1.9" |
| 453 | source = "registry+https://github.com/rust-lang/crates.io-index" | 462 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 454 | checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" | 463 | checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" |
| 455 | dependencies = [ | 464 | dependencies = [ |
| 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" | |||
| 463 | checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" | 472 | checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" |
| 464 | 473 | ||
| 465 | [[package]] | 474 | [[package]] |
| 466 | name = "kernel32-sys" | 475 | name = "js-sys" |
| 467 | version = "0.2.2" | 476 | version = "0.3.50" |
| 468 | source = "registry+https://github.com/rust-lang/crates.io-index" | 477 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 469 | checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" | 478 | checksum = "2d99f9e3e84b8f67f846ef5b4cbbc3b1c29f6c759fcbce6f01aa0e73d932a24c" |
| 470 | dependencies = [ | 479 | dependencies = [ |
| 471 | "winapi 0.2.8", | 480 | "wasm-bindgen", |
| 472 | "winapi-build", | 481 | ] |
| 482 | |||
| 483 | [[package]] | ||
| 484 | name = "jsonwebtoken" | ||
| 485 | version = "7.2.0" | ||
| 486 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 487 | checksum = "afabcc15e437a6484fc4f12d0fd63068fe457bf93f1c148d3d9649c60b103f32" | ||
| 488 | dependencies = [ | ||
| 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]] |
| 519 | name = "lock_api" | ||
| 520 | version = "0.4.3" | ||
| 521 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 522 | checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176" | ||
| 523 | dependencies = [ | ||
| 524 | "scopeguard", | ||
| 525 | ] | ||
| 526 | |||
| 527 | [[package]] | ||
| 497 | name = "log" | 528 | name = "log" |
| 498 | version = "0.4.14" | 529 | version = "0.4.14" |
| 499 | source = "registry+https://github.com/rust-lang/crates.io-index" | 530 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -532,33 +563,24 @@ dependencies = [ | |||
| 532 | 563 | ||
| 533 | [[package]] | 564 | [[package]] |
| 534 | name = "mio" | 565 | name = "mio" |
| 535 | version = "0.6.23" | 566 | version = "0.7.11" |
| 536 | source = "registry+https://github.com/rust-lang/crates.io-index" | 567 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 537 | checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" | 568 | checksum = "cf80d3e903b34e0bd7282b218398aec54e082c840d9baf8339e0080a0c542956" |
| 538 | dependencies = [ | 569 | dependencies = [ |
| 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]] |
| 553 | name = "miow" | 578 | name = "miow" |
| 554 | version = "0.2.2" | 579 | version = "0.3.7" |
| 555 | source = "registry+https://github.com/rust-lang/crates.io-index" | 580 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 556 | checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" | 581 | checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" |
| 557 | dependencies = [ | 582 | dependencies = [ |
| 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]] |
| 583 | name = "net2" | 605 | name = "ntapi" |
| 584 | version = "0.2.37" | 606 | version = "0.3.6" |
| 585 | source = "registry+https://github.com/rust-lang/crates.io-index" | 607 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 586 | checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" | 608 | checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" |
| 587 | dependencies = [ | 609 | dependencies = [ |
| 588 | "cfg-if 0.1.10", | 610 | "winapi", |
| 589 | "libc", | 611 | ] |
| 590 | "winapi 0.3.9", | 612 | |
| 613 | [[package]] | ||
| 614 | name = "num-bigint" | ||
| 615 | version = "0.2.6" | ||
| 616 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 617 | checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" | ||
| 618 | dependencies = [ | ||
| 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]] |
| 644 | name = "num_cpus" | ||
| 645 | version = "1.13.0" | ||
| 646 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 647 | checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" | ||
| 648 | dependencies = [ | ||
| 649 | "hermit-abi", | ||
| 650 | "libc", | ||
| 651 | ] | ||
| 652 | |||
| 653 | [[package]] | ||
| 654 | name = "once_cell" | ||
| 655 | version = "1.7.2" | ||
| 656 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 657 | checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" | ||
| 658 | |||
| 659 | [[package]] | ||
| 613 | name = "opaque-debug" | 660 | name = "opaque-debug" |
| 614 | version = "0.3.0" | 661 | version = "0.3.0" |
| 615 | source = "registry+https://github.com/rust-lang/crates.io-index" | 662 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 616 | checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" | 663 | checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" |
| 617 | 664 | ||
| 618 | [[package]] | 665 | [[package]] |
| 666 | name = "openssl" | ||
| 667 | version = "0.10.33" | ||
| 668 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 669 | checksum = "a61075b62a23fef5a29815de7536d940aa35ce96d18ce0cc5076272db678a577" | ||
| 670 | dependencies = [ | ||
| 671 | "bitflags", | ||
| 672 | "cfg-if 1.0.0", | ||
| 673 | "foreign-types", | ||
| 674 | "libc", | ||
| 675 | "once_cell", | ||
| 676 | "openssl-sys", | ||
| 677 | ] | ||
| 678 | |||
| 679 | [[package]] | ||
| 680 | name = "openssl-sys" | ||
| 681 | version = "0.9.61" | ||
| 682 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 683 | checksum = "313752393519e876837e09e1fa183ddef0be7735868dced3196f4472d536277f" | ||
| 684 | dependencies = [ | ||
| 685 | "autocfg", | ||
| 686 | "cc", | ||
| 687 | "libc", | ||
| 688 | "pkg-config", | ||
| 689 | "vcpkg", | ||
| 690 | ] | ||
| 691 | |||
| 692 | [[package]] | ||
| 619 | name = "parking_lot" | 693 | name = "parking_lot" |
| 620 | version = "0.10.2" | 694 | version = "0.10.2" |
| 621 | source = "registry+https://github.com/rust-lang/crates.io-index" | 695 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 622 | checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" | 696 | checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" |
| 623 | dependencies = [ | 697 | dependencies = [ |
| 624 | "lock_api", | 698 | "lock_api 0.3.4", |
| 625 | "parking_lot_core", | 699 | "parking_lot_core 0.7.2", |
| 700 | ] | ||
| 701 | |||
| 702 | [[package]] | ||
| 703 | name = "parking_lot" | ||
| 704 | version = "0.11.1" | ||
| 705 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 706 | checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" | ||
| 707 | dependencies = [ | ||
| 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]] |
| 643 | name = "percent-encoding" | 728 | name = "parking_lot_core" |
| 644 | version = "2.1.0" | 729 | version = "0.8.3" |
| 645 | source = "registry+https://github.com/rust-lang/crates.io-index" | 730 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 646 | checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" | 731 | checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" |
| 732 | dependencies = [ | ||
| 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]] |
| 649 | name = "pin-project" | 742 | name = "pem" |
| 650 | version = "0.4.28" | 743 | version = "0.8.3" |
| 651 | source = "registry+https://github.com/rust-lang/crates.io-index" | 744 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 652 | checksum = "918192b5c59119d51e0cd221f4d49dde9112824ba717369e903c97d076083d0f" | 745 | checksum = "fd56cbd21fea48d0c440b41cd69c589faacade08c992d9a54e471b79d0fd13eb" |
| 653 | dependencies = [ | 746 | dependencies = [ |
| 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]] |
| 658 | name = "pin-project" | 753 | name = "percent-encoding" |
| 659 | version = "1.0.6" | 754 | version = "2.1.0" |
| 660 | source = "registry+https://github.com/rust-lang/crates.io-index" | 755 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 661 | checksum = "bc174859768806e91ae575187ada95c91a29e96a98dc5d2cd9a1fed039501ba6" | 756 | checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" |
| 662 | dependencies = [ | ||
| 663 | "pin-project-internal 1.0.6", | ||
| 664 | ] | ||
| 665 | 757 | ||
| 666 | [[package]] | 758 | [[package]] |
| 667 | name = "pin-project-internal" | 759 | name = "pin-project" |
| 668 | version = "0.4.28" | 760 | version = "1.0.6" |
| 669 | source = "registry+https://github.com/rust-lang/crates.io-index" | 761 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 670 | checksum = "3be26700300be6d9d23264c73211d8190e755b6b5ca7a1b28230025511b52a5e" | 762 | checksum = "bc174859768806e91ae575187ada95c91a29e96a98dc5d2cd9a1fed039501ba6" |
| 671 | dependencies = [ | 763 | dependencies = [ |
| 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]] |
| 689 | name = "pin-project-lite" | 779 | name = "pin-project-lite" |
| 690 | version = "0.1.12" | ||
| 691 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 692 | checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" | ||
| 693 | |||
| 694 | [[package]] | ||
| 695 | name = "pin-project-lite" | ||
| 696 | version = "0.2.6" | 780 | version = "0.2.6" |
| 697 | source = "registry+https://github.com/rust-lang/crates.io-index" | 781 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 698 | checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" | 782 | checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" |
| @@ -704,6 +788,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 704 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" | 788 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" |
| 705 | 789 | ||
| 706 | [[package]] | 790 | [[package]] |
| 791 | name = "pkg-config" | ||
| 792 | version = "0.3.19" | ||
| 793 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 794 | checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" | ||
| 795 | |||
| 796 | [[package]] | ||
| 707 | name = "ppv-lite86" | 797 | name = "ppv-lite86" |
| 708 | version = "0.2.10" | 798 | version = "0.2.10" |
| 709 | source = "registry+https://github.com/rust-lang/crates.io-index" | 799 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -863,7 +953,22 @@ version = "0.5.3" | |||
| 863 | source = "registry+https://github.com/rust-lang/crates.io-index" | 953 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 864 | checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" | 954 | checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" |
| 865 | dependencies = [ | 955 | dependencies = [ |
| 866 | "winapi 0.3.9", | 956 | "winapi", |
| 957 | ] | ||
| 958 | |||
| 959 | [[package]] | ||
| 960 | name = "ring" | ||
| 961 | version = "0.16.20" | ||
| 962 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 963 | checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" | ||
| 964 | dependencies = [ | ||
| 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]] |
| 934 | name = "serde_urlencoded" | 1039 | name = "serde_urlencoded" |
| 935 | version = "0.6.1" | 1040 | version = "0.7.0" |
| 936 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1041 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 937 | checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" | 1042 | checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" |
| 938 | dependencies = [ | 1043 | dependencies = [ |
| 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]] |
| 1064 | name = "signal-hook-registry" | ||
| 1065 | version = "1.3.0" | ||
| 1066 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1067 | checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" | ||
| 1068 | dependencies = [ | ||
| 1069 | "libc", | ||
| 1070 | ] | ||
| 1071 | |||
| 1072 | [[package]] | ||
| 1073 | name = "simple_asn1" | ||
| 1074 | version = "0.4.1" | ||
| 1075 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1076 | checksum = "692ca13de57ce0613a363c8c2f1de925adebc81b04c923ac60c5488bb44abe4b" | ||
| 1077 | dependencies = [ | ||
| 1078 | "chrono", | ||
| 1079 | "num-bigint", | ||
| 1080 | "num-traits", | ||
| 1081 | ] | ||
| 1082 | |||
| 1083 | [[package]] | ||
| 959 | name = "slab" | 1084 | name = "slab" |
| 960 | version = "0.4.2" | 1085 | version = "0.4.2" |
| 961 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1086 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -969,16 +1094,21 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" | |||
| 969 | 1094 | ||
| 970 | [[package]] | 1095 | [[package]] |
| 971 | name = "socket2" | 1096 | name = "socket2" |
| 972 | version = "0.3.19" | 1097 | version = "0.4.0" |
| 973 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1098 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 974 | checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" | 1099 | checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" |
| 975 | dependencies = [ | 1100 | dependencies = [ |
| 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]] |
| 1106 | name = "spin" | ||
| 1107 | version = "0.5.2" | ||
| 1108 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1109 | checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" | ||
| 1110 | |||
| 1111 | [[package]] | ||
| 982 | name = "syn" | 1112 | name = "syn" |
| 983 | version = "1.0.68" | 1113 | version = "1.0.68" |
| 984 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1114 | source = "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]] |
| 1146 | name = "thiserror" | ||
| 1147 | version = "1.0.24" | ||
| 1148 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1149 | checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" | ||
| 1150 | dependencies = [ | ||
| 1151 | "thiserror-impl", | ||
| 1152 | ] | ||
| 1153 | |||
| 1154 | [[package]] | ||
| 1155 | name = "thiserror-impl" | ||
| 1156 | version = "1.0.24" | ||
| 1157 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1158 | checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" | ||
| 1159 | dependencies = [ | ||
| 1160 | "proc-macro2", | ||
| 1161 | "quote", | ||
| 1162 | "syn", | ||
| 1163 | ] | ||
| 1164 | |||
| 1165 | [[package]] | ||
| 1016 | name = "time" | 1166 | name = "time" |
| 1017 | version = "0.1.44" | 1167 | version = "0.1.44" |
| 1018 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1168 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -1020,7 +1170,7 @@ checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" | |||
| 1020 | dependencies = [ | 1170 | dependencies = [ |
| 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]] |
| 1042 | name = "tokio" | 1192 | name = "tokio" |
| 1043 | version = "0.2.25" | 1193 | version = "1.4.0" |
| 1044 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1194 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1045 | checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" | 1195 | checksum = "134af885d758d645f0f0505c9a8b3f9bf8a348fd822e112ab5248138348f1722" |
| 1046 | dependencies = [ | 1196 | dependencies = [ |
| 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]] |
| 1060 | name = "tokio-macros" | 1212 | name = "tokio-macros" |
| 1061 | version = "0.2.6" | 1213 | version = "1.1.0" |
| 1062 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1214 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1063 | checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" | 1215 | checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57" |
| 1064 | dependencies = [ | 1216 | dependencies = [ |
| 1065 | "proc-macro2", | 1217 | "proc-macro2", |
| 1066 | "quote", | 1218 | "quote", |
| @@ -1068,29 +1220,40 @@ dependencies = [ | |||
| 1068 | ] | 1220 | ] |
| 1069 | 1221 | ||
| 1070 | [[package]] | 1222 | [[package]] |
| 1223 | name = "tokio-stream" | ||
| 1224 | version = "0.1.5" | ||
| 1225 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1226 | checksum = "e177a5d8c3bf36de9ebe6d58537d8879e964332f93fb3339e43f618c81361af0" | ||
| 1227 | dependencies = [ | ||
| 1228 | "futures-core", | ||
| 1229 | "pin-project-lite", | ||
| 1230 | "tokio", | ||
| 1231 | ] | ||
| 1232 | |||
| 1233 | [[package]] | ||
| 1071 | name = "tokio-tungstenite" | 1234 | name = "tokio-tungstenite" |
| 1072 | version = "0.11.0" | 1235 | version = "0.13.0" |
| 1073 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1236 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1074 | checksum = "6d9e878ad426ca286e4dcae09cbd4e1973a7f8987d97570e2469703dd7f5720c" | 1237 | checksum = "e1a5f475f1b9d077ea1017ecbc60890fda8e54942d680ca0b1d2b47cfa2d861b" |
| 1075 | dependencies = [ | 1238 | dependencies = [ |
| 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]] |
| 1084 | name = "tokio-util" | 1247 | name = "tokio-util" |
| 1085 | version = "0.3.1" | 1248 | version = "0.6.5" |
| 1086 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1249 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1087 | checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" | 1250 | checksum = "5143d049e85af7fbc36f5454d990e62c2df705b3589f123b71f441b6b59f443f" |
| 1088 | dependencies = [ | 1251 | dependencies = [ |
| 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" | |||
| 1108 | dependencies = [ | 1271 | dependencies = [ |
| 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]] |
| 1125 | name = "tracing-futures" | ||
| 1126 | version = "0.2.5" | ||
| 1127 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1128 | checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" | ||
| 1129 | dependencies = [ | ||
| 1130 | "pin-project 1.0.6", | ||
| 1131 | "tracing", | ||
| 1132 | ] | ||
| 1133 | |||
| 1134 | [[package]] | ||
| 1135 | name = "try-lock" | 1288 | name = "try-lock" |
| 1136 | version = "0.2.3" | 1289 | version = "0.2.3" |
| 1137 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1290 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -1139,18 +1292,18 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" | |||
| 1139 | 1292 | ||
| 1140 | [[package]] | 1293 | [[package]] |
| 1141 | name = "tungstenite" | 1294 | name = "tungstenite" |
| 1142 | version = "0.11.1" | 1295 | version = "0.12.0" |
| 1143 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1296 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1144 | checksum = "f0308d80d86700c5878b9ef6321f020f29b1bb9d5ff3cab25e75e23f3a492a23" | 1297 | checksum = "8ada8297e8d70872fa9a551d93250a9f407beb9f37ef86494eb20012a2ff7c24" |
| 1145 | dependencies = [ | 1298 | dependencies = [ |
| 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" | |||
| 1205 | checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" | 1358 | checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" |
| 1206 | 1359 | ||
| 1207 | [[package]] | 1360 | [[package]] |
| 1361 | name = "untrusted" | ||
| 1362 | version = "0.7.1" | ||
| 1363 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1364 | checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" | ||
| 1365 | |||
| 1366 | [[package]] | ||
| 1208 | name = "url" | 1367 | name = "url" |
| 1209 | version = "2.2.1" | 1368 | version = "2.2.1" |
| 1210 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1369 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -1217,18 +1376,18 @@ dependencies = [ | |||
| 1217 | ] | 1376 | ] |
| 1218 | 1377 | ||
| 1219 | [[package]] | 1378 | [[package]] |
| 1220 | name = "urlencoding" | ||
| 1221 | version = "1.1.1" | ||
| 1222 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1223 | checksum = "c9232eb53352b4442e40d7900465dfc534e8cb2dc8f18656fcb2ac16112b5593" | ||
| 1224 | |||
| 1225 | [[package]] | ||
| 1226 | name = "utf-8" | 1379 | name = "utf-8" |
| 1227 | version = "0.7.5" | 1380 | version = "0.7.5" |
| 1228 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1381 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1229 | checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" | 1382 | checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" |
| 1230 | 1383 | ||
| 1231 | [[package]] | 1384 | [[package]] |
| 1385 | name = "vcpkg" | ||
| 1386 | version = "0.2.11" | ||
| 1387 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1388 | checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" | ||
| 1389 | |||
| 1390 | [[package]] | ||
| 1232 | name = "version_check" | 1391 | name = "version_check" |
| 1233 | version = "0.9.3" | 1392 | version = "0.9.3" |
| 1234 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1393 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -1246,11 +1405,11 @@ dependencies = [ | |||
| 1246 | 1405 | ||
| 1247 | [[package]] | 1406 | [[package]] |
| 1248 | name = "warp" | 1407 | name = "warp" |
| 1249 | version = "0.2.5" | 1408 | version = "0.3.1" |
| 1250 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1409 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1251 | checksum = "f41be6df54c97904af01aa23e613d4521eed7ab23537cede692d4058f6449407" | 1410 | checksum = "332d47745e9a0c38636dbd454729b147d16bd1ed08ae67b3ab281c4506771054" |
| 1252 | dependencies = [ | 1411 | dependencies = [ |
| 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" | |||
| 1285 | checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" | 1445 | checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" |
| 1286 | 1446 | ||
| 1287 | [[package]] | 1447 | [[package]] |
| 1288 | name = "winapi" | 1448 | name = "wasm-bindgen" |
| 1289 | version = "0.2.8" | 1449 | version = "0.2.73" |
| 1450 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1451 | checksum = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9" | ||
| 1452 | dependencies = [ | ||
| 1453 | "cfg-if 1.0.0", | ||
| 1454 | "wasm-bindgen-macro", | ||
| 1455 | ] | ||
| 1456 | |||
| 1457 | [[package]] | ||
| 1458 | name = "wasm-bindgen-backend" | ||
| 1459 | version = "0.2.73" | ||
| 1460 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1461 | checksum = "ae70622411ca953215ca6d06d3ebeb1e915f0f6613e3b495122878d7ebec7dae" | ||
| 1462 | dependencies = [ | ||
| 1463 | "bumpalo", | ||
| 1464 | "lazy_static", | ||
| 1465 | "log", | ||
| 1466 | "proc-macro2", | ||
| 1467 | "quote", | ||
| 1468 | "syn", | ||
| 1469 | "wasm-bindgen-shared", | ||
| 1470 | ] | ||
| 1471 | |||
| 1472 | [[package]] | ||
| 1473 | name = "wasm-bindgen-macro" | ||
| 1474 | version = "0.2.73" | ||
| 1475 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1476 | checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f" | ||
| 1477 | dependencies = [ | ||
| 1478 | "quote", | ||
| 1479 | "wasm-bindgen-macro-support", | ||
| 1480 | ] | ||
| 1481 | |||
| 1482 | [[package]] | ||
| 1483 | name = "wasm-bindgen-macro-support" | ||
| 1484 | version = "0.2.73" | ||
| 1485 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1486 | checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c" | ||
| 1487 | dependencies = [ | ||
| 1488 | "proc-macro2", | ||
| 1489 | "quote", | ||
| 1490 | "syn", | ||
| 1491 | "wasm-bindgen-backend", | ||
| 1492 | "wasm-bindgen-shared", | ||
| 1493 | ] | ||
| 1494 | |||
| 1495 | [[package]] | ||
| 1496 | name = "wasm-bindgen-shared" | ||
| 1497 | version = "0.2.73" | ||
| 1290 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1498 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1291 | checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" | 1499 | checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" |
| 1500 | |||
| 1501 | [[package]] | ||
| 1502 | name = "web-sys" | ||
| 1503 | version = "0.3.50" | ||
| 1504 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1505 | checksum = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be" | ||
| 1506 | dependencies = [ | ||
| 1507 | "js-sys", | ||
| 1508 | "wasm-bindgen", | ||
| 1509 | ] | ||
| 1292 | 1510 | ||
| 1293 | [[package]] | 1511 | [[package]] |
| 1294 | name = "winapi" | 1512 | name = "winapi" |
| @@ -1301,12 +1519,6 @@ dependencies = [ | |||
| 1301 | ] | 1519 | ] |
| 1302 | 1520 | ||
| 1303 | [[package]] | 1521 | [[package]] |
| 1304 | name = "winapi-build" | ||
| 1305 | version = "0.1.1" | ||
| 1306 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1307 | checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" | ||
| 1308 | |||
| 1309 | [[package]] | ||
| 1310 | name = "winapi-i686-pc-windows-gnu" | 1522 | name = "winapi-i686-pc-windows-gnu" |
| 1311 | version = "0.4.0" | 1523 | version = "0.4.0" |
| 1312 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1524 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -1318,7 +1530,7 @@ version = "0.1.5" | |||
| 1318 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1530 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1319 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" | 1531 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" |
| 1320 | dependencies = [ | 1532 | dependencies = [ |
| 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" | |||
| 1326 | version = "0.4.0" | 1538 | version = "0.4.0" |
| 1327 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1539 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1328 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" | 1540 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" |
| 1329 | |||
| 1330 | [[package]] | ||
| 1331 | name = "ws2_32-sys" | ||
| 1332 | version = "0.2.1" | ||
| 1333 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1334 | checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" | ||
| 1335 | dependencies = [ | ||
| 1336 | "winapi 0.2.8", | ||
| 1337 | "winapi-build", | ||
| 1338 | ] | ||
| @@ -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] |
| 10 | warp = "0.2.0" | 10 | warp = "0.3" |
| 11 | tokio = { version = "0.2.9", features = ["macros"] } | 11 | tokio = { version = "1", features = ["full"] } |
| 12 | serde = { version = "1.0.104", features = ["derive"] } | 12 | serde = { version = "1.0.125", features = ["derive"] } |
| 13 | chrono = { version = "0.4.10", features = ["serde"] } | 13 | chrono = { version = "0.4.10", features = ["serde"] } |
| 14 | log = "0.4.8" | 14 | log = "0.4.8" |
| 15 | anyhow = "1.0.40" | ||
| 15 | pretty_env_logger = "0.3.1" | 16 | pretty_env_logger = "0.3.1" |
| 16 | parking_lot = "0.10.0" | 17 | parking_lot = "0.10.0" |
| 18 | thiserror = "1.0" | ||
| 19 | jsonwebtoken = "7" | ||
| 20 | openssl = "0.10.28" | ||
| 17 | 21 | ||
| 18 | [dev-dependencies] | 22 | [dev-dependencies] |
| 19 | serde_json = "1.0.44" | 23 | serde_json = "1.0.44" |
| @@ -16,12 +16,12 @@ $ curl --location --request POST 'localhost:8080/transaction' --header 'Content- | |||
| 16 | # how? | 16 | # how? |
| 17 | 17 | ||
| 18 | ## authentication | 18 | ## authentication |
| 19 | Students 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) |
| 20 | Some 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 | |
| 22 | Authenticated students propose transactions, between them and another node (=public keys) or between the grader (=bank) and themselves. | ||
| 23 | 22 | ||
| 24 | ## transactions | 23 | ## transactions |
| 24 | Students propose transactions, between them and another node (=public keys) or between the grader (=bank) and themselves. | ||
| 25 | Transactions are `signed` using the proposers private key. | 25 | Transactions 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 | ||
| @@ -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 @@ | |||
| 1 | use crate::error::Error; | ||
| 2 | use crate::schema::{Db, Transaction}; | ||
| 3 | use jsonwebtoken::{decode, Algorithm, DecodingKey, Validation}; | ||
| 4 | use serde::{Deserialize, Serialize}; | ||
| 5 | use warp::header::headers_cloned; | ||
| 6 | use warp::http::header::{HeaderMap, HeaderValue, AUTHORIZATION}; | ||
| 7 | use warp::{reject, Filter, Rejection}; | ||
| 8 | use thiserror::Error; | ||
| 9 | use anyhow::*; | ||
| 10 | |||
| 11 | const BEARER: &str = "Bearer "; | ||
| 12 | const PUBLIC_KEY_PEM: &str = "-----BEGIN PUBLIC KEY----- | ||
| 13 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4nU0G4WjkmcQUx0hq6LQ | ||
| 14 | uV5Q+ACmUFL/OjoYMDwC/O/6pCd1UZgCfgHN2xEffDPznzcTn8OiFRxr4oWyBiny | ||
| 15 | rUpnY4mhy0SQUwoeCw7YkcHAyhCjNT74aR/ohX0MCj0qRRdbt5ZQXM/GC3HJuXE1 | ||
| 16 | ptSuhFgQxziItamn8maoJ6JUSVEXVO1NOrrjoM3r7Q+BK2B+sX4/bLZ+VG5g1q2n | ||
| 17 | EbFdTHS6pHqtZNHQndTmEKwRfh0RYtzEzOXuO6e1gQY42Tujkof40dhGCIU7TeIG | ||
| 18 | GHwdFxy1niLkXwtHNjV7lnIOkTbx6+sSPamRfQAlZqUWM2Lf5o+7h3qWP3ENB138 | ||
| 19 | sQIDAQAB | ||
| 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)] | ||
| 54 | struct 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 | |||
| 69 | pub 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 | |||
| 78 | impl warp::reject::Reject for Nope {} | ||
| 79 | |||
| 80 | async 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 | |||
| 99 | fn 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 @@ | |||
| 1 | use serde::Serialize; | ||
| 2 | use std::convert::Infallible; | ||
| 3 | use thiserror::Error; | ||
| 4 | use warp::{http::StatusCode, Rejection, Reply}; | ||
| 5 | |||
| 6 | #[derive(Error, Debug)] | ||
| 7 | pub 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)] | ||
| 23 | struct ErrorResponse { | ||
| 24 | message: String, | ||
| 25 | status: String, | ||
| 26 | } | ||
| 27 | |||
| 28 | impl warp::reject::Reject for Error {} | ||
| 29 | |||
| 30 | pub 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 | ||
| 63 | pub 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; | |||
| 5 | mod handlers; | 5 | mod handlers; |
| 6 | mod routes; | 6 | mod routes; |
| 7 | mod schema; | 7 | mod schema; |
| 8 | mod auth; | ||
| 9 | mod 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 @@ | |||
| 1 | use warp::{Filter, Rejection, Reply}; | 1 | use warp::{Filter, Rejection, Reply}; |
| 2 | 2 | ||
| 3 | use crate::auth::with_auth; | ||
| 3 | use crate::custom_filters; | 4 | use crate::custom_filters; |
| 4 | use crate::handlers; | 5 | use crate::handlers; |
| 5 | use crate::schema::Db; | 6 | use crate::schema::{Db, Transaction}; |
| 6 | 7 | ||
| 7 | /// Root, all routes combined | 8 | /// Root, all routes combined |
| 8 | pub fn consensus_routes(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { | 9 | pub 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 |
| 16 | pub fn transaction_list(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { | 17 | pub 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 |
| 32 | pub fn transaction_propose(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { | 34 | pub 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 | ||
| 44 | pub 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 |
| 41 | pub fn block_propose(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { | 73 | pub 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 | ||
| 34 | impl Db { | 36 | impl 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)] | ||
| 45 | pub struct Transaction { | 50 | pub 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)] | ||
| 74 | pub 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> // |
