From 1c3e80b56ba8eab9430aae116f6d57f634ffd542 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Thu, 18 Feb 2021 14:35:40 +0100 Subject: [PATCH 01/20] Update some deps (the most important is actix-web to 3.x) and some changes in the code run with new versions. --- Cargo.lock | 714 ++++++++++++++++++++++++++++++++++---------------- Cargo.toml | 4 +- src/server.rs | 6 +- 3 files changed, 493 insertions(+), 231 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a4e289df..b11ec9c7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,11 +6,11 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4af87564ff659dee8f9981540cac9418c45e910c8072fdedd643a262a38fcaf" dependencies = [ - "actix-http", + "actix-http 1.0.1", "actix-rt", "actix_derive", "bitflags", - "bytes", + "bytes 0.5.6", "crossbeam-channel 0.4.4", "derive_more", "futures", @@ -21,8 +21,8 @@ dependencies = [ "smallvec", "tokio", "tokio-util 0.2.0", - "trust-dns-proto", - "trust-dns-resolver", + "trust-dns-proto 0.18.0-alpha.2", + "trust-dns-resolver 0.18.0-alpha.2", ] [[package]] @@ -32,7 +32,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09e55f0a5c2ca15795035d90c46bd0e73a5123b72f68f12596d6ba5282051380" dependencies = [ "bitflags", - "bytes", + "bytes 0.5.6", "futures-core", "futures-sink", "log", @@ -47,7 +47,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78d1833b3838dbe990df0f1f87baf640cf6146e898166afe401839d1b001e570" dependencies = [ "bitflags", - "bytes", + "bytes 0.5.6", "futures-core", "futures-sink", "log", @@ -71,20 +71,41 @@ dependencies = [ "futures", "http", "log", - "trust-dns-proto", - "trust-dns-resolver", + "trust-dns-proto 0.18.0-alpha.2", + "trust-dns-resolver 0.18.0-alpha.2", ] [[package]] -name = "actix-cors" -version = "0.2.0" +name = "actix-connect" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6206917d5c0fdd79d81cec9ef02d3e802df4abf276d96241e1f595d971e002" +checksum = "177837a10863f15ba8d3ae3ec12fac1099099529ed20083a27fdfe247381d0dc" dependencies = [ + "actix-codec 0.3.0", + "actix-rt", "actix-service", + "actix-utils 2.0.0", + "derive_more", + "either", + "futures-util", + "http", + "log", + "trust-dns-proto 0.19.6", + "trust-dns-resolver 0.19.6", +] + +[[package]] +name = "actix-cors" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36b133d8026a9f209a9aeeeacd028e7451bcca975f592881b305d37983f303d7" +dependencies = [ "actix-web", "derive_more", - "futures", + "futures-util", + "log", + "once_cell", + "tinyvec", ] [[package]] @@ -94,22 +115,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c16664cc4fdea8030837ad5a845eb231fb93fc3c5c171edfefb52fad92ce9019" dependencies = [ "actix-codec 0.2.0", - "actix-connect", + "actix-connect 1.0.2", "actix-rt", "actix-service", "actix-threadpool", "actix-utils 1.0.6", "base64 0.11.0", "bitflags", - "brotli2", - "bytes", + "bytes 0.5.6", "chrono", "copyless", "derive_more", "either", "encoding_rs", - "failure", - "flate2", "futures-channel", "futures-core", "futures-util", @@ -124,16 +142,63 @@ dependencies = [ "mime", "percent-encoding", "pin-project 0.4.27", - "rand", + "rand 0.7.3", "regex", "serde", "serde_json", - "serde_urlencoded", + "serde_urlencoded 0.6.1", "sha1", "slab", "time 0.1.44", ] +[[package]] +name = "actix-http" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "452299e87817ae5673910e53c243484ca38be3828db819b6011736fc6982e874" +dependencies = [ + "actix-codec 0.3.0", + "actix-connect 2.0.0", + "actix-rt", + "actix-service", + "actix-threadpool", + "actix-utils 2.0.0", + "base64 0.13.0", + "bitflags", + "brotli2", + "bytes 0.5.6", + "cookie", + "copyless", + "derive_more", + "either", + "encoding_rs", + "flate2", + "futures-channel", + "futures-core", + "futures-util", + "fxhash", + "h2", + "http", + "httparse", + "indexmap", + "itoa", + "language-tags", + "lazy_static", + "log", + "mime", + "percent-encoding", + "pin-project 1.0.5", + "rand 0.7.3", + "regex", + "serde", + "serde_json", + "serde_urlencoded 0.7.0", + "sha-1", + "slab", + "time 0.2.25", +] + [[package]] name = "actix-macros" version = "0.1.3" @@ -146,9 +211,9 @@ dependencies = [ [[package]] name = "actix-router" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd1f7dbda1645bf7da33554db60891755f6c01c1b2169e2f4c492098d30c235" +checksum = "2ad299af73649e1fc893e333ccf86f377751eb95ff875d095131574c6f43452c" dependencies = [ "bytestring", "http", @@ -233,18 +298,14 @@ dependencies = [ [[package]] name = "actix-tls" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e5b4faaf105e9a6d389c606c298dcdb033061b00d532af9df56ff3a54995a8" +checksum = "24789b7d7361cf5503a504ebe1c10806896f61e96eca9a7350e23001aca715fb" dependencies = [ - "actix-codec 0.2.0", - "actix-rt", + "actix-codec 0.3.0", "actix-service", - "actix-utils 1.0.6", - "derive_more", - "either", - "futures", - "log", + "actix-utils 2.0.0", + "futures-util", ] [[package]] @@ -257,7 +318,7 @@ dependencies = [ "actix-rt", "actix-service", "bitflags", - "bytes", + "bytes 0.5.6", "either", "futures", "log", @@ -275,7 +336,7 @@ dependencies = [ "actix-rt", "actix-service", "bitflags", - "bytes", + "bytes 0.5.6", "either", "futures-channel", "futures-sink", @@ -287,12 +348,12 @@ dependencies = [ [[package]] name = "actix-web" -version = "2.0.0" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3158e822461040822f0dbf1735b9c2ce1f95f93b651d7a7aded00b1efbb1f635" +checksum = "e641d4a172e7faa0862241a20ff4f1f5ab0ab7c279f00c2d4587b77483477b86" dependencies = [ - "actix-codec 0.2.0", - "actix-http", + "actix-codec 0.3.0", + "actix-http 2.2.0", "actix-macros", "actix-router", "actix-rt", @@ -301,31 +362,34 @@ dependencies = [ "actix-testing", "actix-threadpool", "actix-tls", - "actix-utils 1.0.6", + "actix-utils 2.0.0", "actix-web-codegen", "awc", - "bytes", + "bytes 0.5.6", "derive_more", "encoding_rs", - "futures", + "futures-channel", + "futures-core", + "futures-util", "fxhash", "log", "mime", - "net2", - "pin-project 0.4.27", + "pin-project 1.0.5", "regex", "serde", "serde_json", - "serde_urlencoded", - "time 0.1.44", + "serde_urlencoded 0.7.0", + "socket2", + "time 0.2.25", + "tinyvec", "url", ] [[package]] name = "actix-web-codegen" -version = "0.2.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a71bf475cbe07281d0b3696abb48212db118e7e23219f13596ce865235ff5766" +checksum = "ad26f77093333e0e7c6ffe54ebe3582d908a104e448723eec6d43d08b07143fb" dependencies = [ "proc-macro2", "quote", @@ -345,9 +409,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" dependencies = [ "gimli", ] @@ -397,32 +461,33 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "awc" -version = "1.0.1" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7601d4d1d7ef2335d6597a41b5fe069f6ab799b85f53565ab390e7b7065aac5" +checksum = "b381e490e7b0cfc37ebc54079b0413d8093ef43d14a4e4747083f7fa47a9e691" dependencies = [ - "actix-codec 0.2.0", - "actix-http", + "actix-codec 0.3.0", + "actix-http 2.2.0", "actix-rt", "actix-service", - "base64 0.11.0", - "bytes", + "base64 0.13.0", + "bytes 0.5.6", + "cfg-if 1.0.0", "derive_more", "futures-core", "log", "mime", "percent-encoding", - "rand", + "rand 0.7.3", "serde", "serde_json", - "serde_urlencoded", + "serde_urlencoded 0.7.0", ] [[package]] name = "backtrace" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" dependencies = [ "addr2line", "cfg-if 1.0.0", @@ -487,9 +552,9 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473fc6b38233f9af7baa94fb5852dca389e3d95b8e21c8e3719301462c5d9faf" +checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" dependencies = [ "lazy_static", "memchr", @@ -499,15 +564,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.4.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" +checksum = "099e596ef14349721d9016f6b80dd3419ea1bf289ab9b44df8e4dfd3a005d5d9" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" [[package]] name = "bytes" @@ -515,13 +580,19 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" +[[package]] +name = "bytes" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" + [[package]] name = "bytestring" -version = "0.1.5" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7c05fa5172da78a62d9949d662d2ac89d4cc7355d7b49adee5163f1fb3f363" +checksum = "90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d" dependencies = [ - "bytes", + "bytes 1.0.1", ] [[package]] @@ -592,9 +663,20 @@ dependencies = [ [[package]] name = "const_fn" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd51eab21ab4fd6a3bf889e2d0958c0a6e3a61ad04260325e919e652a2a62826" +checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" + +[[package]] +name = "cookie" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784ad0fbab4f3e9cef09f20e0aea6000ae08d2cb98ac4c0abc53df18803d702f" +dependencies = [ + "percent-encoding", + "time 0.2.25", + "version_check", +] [[package]] name = "copyless" @@ -635,16 +717,16 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70daa7ceec6cf143990669a04c7df13391d55fb27bd4079d252fca774ba244d8" +checksum = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" dependencies = [ "atty", "cast", "clap", "criterion-plot", "csv", - "itertools", + "itertools 0.10.0", "lazy_static", "num-traits", "oorandom", @@ -666,7 +748,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d" dependencies = [ "cast", - "itertools", + "itertools 0.9.0", ] [[package]] @@ -808,9 +890,9 @@ dependencies = [ [[package]] name = "dtoa" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" +checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e" [[package]] name = "either" @@ -820,9 +902,9 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "encoding_rs" -version = "0.8.26" +version = "0.8.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "801bbab217d7f79c0062f4f7205b5d4427c6d1a7bd7aafdd1475f7c59d62b283" +checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" dependencies = [ "cfg-if 1.0.0", ] @@ -841,9 +923,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e" +checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" dependencies = [ "atty", "humantime", @@ -882,9 +964,9 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "flate2" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129" +checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" dependencies = [ "cfg-if 1.0.0", "crc32fast", @@ -941,9 +1023,9 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "futures" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b3b0c040a1fe6529d30b3c5944b280c7f0dcb2930d2c3062bca967b602583d0" +checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150" dependencies = [ "futures-channel", "futures-core", @@ -956,9 +1038,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b7109687aa4e177ef6fe84553af6280ef2778bdb7783ba44c9dc3399110fe64" +checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846" dependencies = [ "futures-core", "futures-sink", @@ -966,15 +1048,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748" +checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" [[package]] name = "futures-executor" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4caa2b2b68b880003057c1dd49f1ed937e38f22fcf6c212188a121f08cf40a65" +checksum = "e9e59fdc009a4b3096bf94f740a0f2424c082521f20a9b08c5c07c48d90fd9b9" dependencies = [ "futures-core", "futures-task", @@ -983,15 +1065,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611834ce18aaa1bd13c4b374f5d653e1027cf99b6b502584ff8c9a64413b30bb" +checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500" [[package]] name = "futures-macro" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556" +checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -1001,24 +1083,24 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f878195a49cee50e006b02b93cf7e0a95a38ac7b776b4c4d9cc1207cd20fcb3d" +checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6" [[package]] name = "futures-task" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c554eb5bf48b2426c4771ab68c6b14468b6e76cc90996f528c3338d761a4d0d" +checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86" dependencies = [ "once_cell", ] [[package]] name = "futures-util" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2" +checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b" dependencies = [ "futures-channel", "futures-core", @@ -1027,7 +1109,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project 1.0.2", + "pin-project-lite 0.2.4", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -1055,15 +1137,26 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", +] + [[package]] name = "gimli" version = "0.23.0" @@ -1076,7 +1169,7 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" dependencies = [ - "bytes", + "bytes 0.5.6", "fnv", "futures-core", "futures-sink", @@ -1092,9 +1185,9 @@ dependencies = [ [[package]] name = "half" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36fab90f82edc3c747f9d438e06cf0a491055896f2a279638bb5beed6c40177" +checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" [[package]] name = "hashbrown" @@ -1104,18 +1197,18 @@ checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" [[package]] name = "heck" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] @@ -1143,32 +1236,32 @@ dependencies = [ [[package]] name = "http" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84129d298a6d57d246960ff8eb831ca4af3f96d29e2e28848dae275408658e26" +checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" dependencies = [ - "bytes", + "bytes 1.0.1", "fnv", "itoa", ] [[package]] name = "httparse" -version = "1.3.4" +version = "1.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +checksum = "615caabe2c3160b313d52ccc905335f4ed5f10881dd63dc5699d47e90be85691" [[package]] name = "humantime" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "idna" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +checksum = "89829a5d69c23d348314a7ac337fe39173b61149a9864deabd260983aed48c21" dependencies = [ "matches", "unicode-bidi", @@ -1224,17 +1317,26 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d572918e350e82412fe766d24b15e6682fb2ed2bbe018280caa810397cb319" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "js-sys" -version = "0.3.46" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" +checksum = "5cfb73131c35423a367daf8cbd24100af0d077668c8c2943f0e7dd775fef0f65" dependencies = [ "wasm-bindgen", ] @@ -1263,15 +1365,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.81" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" +checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" [[package]] name = "linked-hash-map" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "lock_api" @@ -1493,9 +1595,9 @@ dependencies = [ [[package]] name = "object" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" [[package]] name = "once_cell" @@ -1517,9 +1619,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.31" +version = "0.10.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d008f51b1acffa0d3450a68606e6a51c123012edaacb0f4e1426bd978869187" +checksum = "038d43985d1ddca7a9900630d8cd031b56e4794eecc2e9ea39dd17aa04399a70" dependencies = [ "bitflags", "cfg-if 1.0.0", @@ -1537,9 +1639,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" [[package]] name = "openssl-sys" -version = "0.9.59" +version = "0.9.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de52d8eabd217311538a39bba130d7dea1f1e118010fee7a033d966845e7d5fe" +checksum = "921fc71883267538946025deffb622905ecad223c28efbfdef9bb59a0175f3e6" dependencies = [ "autocfg", "cc", @@ -1566,7 +1668,7 @@ checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ "instant", "lock_api 0.4.2", - "parking_lot_core 0.8.1", + "parking_lot_core 0.8.3", ] [[package]] @@ -1578,21 +1680,21 @@ dependencies = [ "cfg-if 0.1.10", "cloudabi", "libc", - "redox_syscall", + "redox_syscall 0.1.57", "smallvec", "winapi 0.3.9", ] [[package]] name = "parking_lot_core" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c6d9b8427445284a09c55be860a15855ab580a417ccad9da88f5a06787ced0" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" dependencies = [ "cfg-if 1.0.0", "instant", "libc", - "redox_syscall", + "redox_syscall 0.2.5", "smallvec", "winapi 0.3.9", ] @@ -1641,11 +1743,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7" +checksum = "96fa8ebb90271c4477f144354485b8068bd8f6b78b428b01ba892ca26caf0b63" dependencies = [ - "pin-project-internal 1.0.2", + "pin-project-internal 1.0.5", ] [[package]] @@ -1661,9 +1763,9 @@ dependencies = [ [[package]] name = "pin-project-internal" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f" +checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b" dependencies = [ "proc-macro2", "quote", @@ -1678,9 +1780,9 @@ checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" [[package]] name = "pin-project-lite" -version = "0.2.0" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" +checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" [[package]] name = "pin-utils" @@ -1696,23 +1798,39 @@ checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "plotters" -version = "0.2.15" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d1685fbe7beba33de0330629da9d955ac75bd54f33d7b79f9a895590124f6bb" +checksum = "45ca0ae5f169d0917a7c7f5a9c1a3d3d9598f18f529dd2b8373ed988efea307a" dependencies = [ - "js-sys", "num-traits", + "plotters-backend", + "plotters-svg", "wasm-bindgen", "web-sys", ] +[[package]] +name = "plotters-backend" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" + +[[package]] +name = "plotters-svg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" +dependencies = [ + "plotters-backend", +] + [[package]] name = "postgres" version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14d864cf6c2eabf1323afe4145ff273aad1898e4f2a3bcb30347715df8624a07" dependencies = [ - "bytes", + "bytes 0.5.6", "fallible-iterator", "futures", "log", @@ -1726,7 +1844,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "616bfdeeb542b2b0d444391dbcdd91e9a800bc7f35950c9741fe24b07e958900" dependencies = [ - "bytes", + "bytes 0.5.6", "futures", "native-tls", "tokio", @@ -1742,12 +1860,12 @@ checksum = "4888a0e36637ab38d76cace88c1476937d617ad015f07f6b669cec11beacc019" dependencies = [ "base64 0.13.0", "byteorder", - "bytes", + "bytes 0.5.6", "fallible-iterator", "hmac", "md5", "memchr", - "rand", + "rand 0.7.3", "sha2", "stringprep", ] @@ -1758,12 +1876,12 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfc08a7d94a80665de4a83942fa8db2fdeaf2f123fc0535e384dc4fff251efae" dependencies = [ - "bytes", + "bytes 0.5.6", "fallible-iterator", "postgres-protocol", "serde", "serde_json", - "time 0.2.23", + "time 0.2.25", "uuid", ] @@ -1781,9 +1899,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro-nested" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" @@ -1802,9 +1920,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ "proc-macro2", ] @@ -1836,11 +1954,23 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" +dependencies = [ "libc", - "rand_chacha", - "rand_core", - "rand_hc", + "rand_chacha 0.3.0", + "rand_core 0.6.2", + "rand_hc 0.3.0", ] [[package]] @@ -1850,7 +1980,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.2", ] [[package]] @@ -1859,7 +1999,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +dependencies = [ + "getrandom 0.2.2", ] [[package]] @@ -1868,7 +2017,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core 0.6.2", ] [[package]] @@ -1902,11 +2060,20 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "redox_syscall" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +dependencies = [ + "bitflags", +] + [[package]] name = "regex" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" dependencies = [ "aho-corasick", "memchr", @@ -1925,9 +2092,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" [[package]] name = "remove_dir_all" @@ -1948,6 +2115,16 @@ dependencies = [ "quick-error", ] +[[package]] +name = "resolv-conf" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +dependencies = [ + "hostname", + "quick-error", +] + [[package]] name = "rustc-demangle" version = "0.1.18" @@ -2041,7 +2218,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" dependencies = [ - "semver-parser 0.10.1", + "semver-parser 0.10.2", ] [[package]] @@ -2052,9 +2229,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "semver-parser" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ef146c2ad5e5f4b037cd6ce2ebb775401729b19a82040c1beac9d36c7d1428" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" dependencies = [ "pest", ] @@ -2112,6 +2289,18 @@ dependencies = [ "url", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "serde_yaml" version = "0.8.17" @@ -2124,6 +2313,19 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "sha-1" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfebf75d25bd900fd1e7d11501efab59bc846dbc76196839663e6637bba9f25f" +dependencies = [ + "block-buffer", + "cfg-if 1.0.0", + "cpuid-bool", + "digest", + "opaque-debug", +] + [[package]] name = "sha1" version = "0.6.0" @@ -2132,9 +2334,9 @@ checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" [[package]] name = "sha2" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8" +checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" dependencies = [ "block-buffer", "cfg-if 1.0.0", @@ -2145,9 +2347,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.2.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" dependencies = [ "libc", ] @@ -2166,15 +2368,15 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "smallvec" -version = "1.5.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "socket2" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97e0e9fd577458a4f61fb91fcb559ea2afecc54c934119421f9f5d3d5b1a1057" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" dependencies = [ "cfg-if 1.0.0", "libc", @@ -2183,9 +2385,9 @@ dependencies = [ [[package]] name = "standback" -version = "0.2.13" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf906c8b8fc3f6ecd1046e01da1d8ddec83e48c8b08b84dcc02b585a6bedf5a8" +checksum = "a2beb4d1860a61f571530b3f855a1b538d0200f7871c63331ecd6f17b1f014f8" dependencies = [ "version_check", ] @@ -2286,14 +2488,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", - "rand", - "redox_syscall", + "rand 0.8.3", + "redox_syscall 0.2.5", "remove_dir_all", "winapi 0.3.9", ] @@ -2316,13 +2518,33 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "thiserror" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "thread_local" -version = "1.0.1" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] @@ -2357,9 +2579,9 @@ dependencies = [ [[package]] name = "time" -version = "0.2.23" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcdaeea317915d59b2b4cd3b5efcd156c309108664277793f5351700c02ce98b" +checksum = "1195b046942c221454c2539395f85413b33383a067449d78aab2b7b052a142f7" dependencies = [ "const_fn", "libc", @@ -2395,9 +2617,9 @@ dependencies = [ [[package]] name = "tinytemplate" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3dc76004a03cec1c5932bca4cdc2e39aaa798e3f82363dd94f9adf6098c12f" +checksum = "a2ada8616fad06a2d0c455adc530de4ef57605a8120cc65da9653e0e9623ca74" dependencies = [ "serde", "serde_json", @@ -2405,9 +2627,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f" +checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" dependencies = [ "tinyvec_macros", ] @@ -2420,11 +2642,11 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "0.2.24" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099837d3464c16a808060bb3f02263b412f6fafcb5d01c533d309985fbeebe48" +checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" dependencies = [ - "bytes", + "bytes 0.5.6", "fnv", "futures-core", "iovec", @@ -2447,7 +2669,7 @@ checksum = "55a2482c9fe4dd481723cf5c0616f34afc710e55dcda0944e12e7b3316117892" dependencies = [ "async-trait", "byteorder", - "bytes", + "bytes 0.5.6", "fallible-iterator", "futures", "log", @@ -2477,7 +2699,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" dependencies = [ - "bytes", + "bytes 0.5.6", "futures-core", "futures-sink", "log", @@ -2491,7 +2713,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ - "bytes", + "bytes 0.5.6", "futures-core", "futures-sink", "log", @@ -2501,13 +2723,13 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.22" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" +checksum = "f77d3842f76ca899ff2dbcf231c5c65813dea431301d6eb686279c15c4464f12" dependencies = [ "cfg-if 1.0.0", "log", - "pin-project-lite 0.2.0", + "pin-project-lite 0.2.4", "tracing-core", ] @@ -2522,11 +2744,11 @@ dependencies = [ [[package]] name = "tracing-futures" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" dependencies = [ - "pin-project 0.4.27", + "pin-project 1.0.5", "tracing", ] @@ -2543,13 +2765,33 @@ dependencies = [ "idna", "lazy_static", "log", - "rand", + "rand 0.7.3", "smallvec", "socket2", "tokio", "url", ] +[[package]] +name = "trust-dns-proto" +version = "0.19.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53861fcb288a166aae4c508ae558ed18b53838db728d4d310aad08270a7d4c2b" +dependencies = [ + "async-trait", + "backtrace", + "enum-as-inner", + "futures", + "idna", + "lazy_static", + "log", + "rand 0.7.3", + "smallvec", + "thiserror", + "tokio", + "url", +] + [[package]] name = "trust-dns-resolver" version = "0.18.0-alpha.2" @@ -2563,10 +2805,30 @@ dependencies = [ "lazy_static", "log", "lru-cache", - "resolv-conf", + "resolv-conf 0.6.3", "smallvec", "tokio", - "trust-dns-proto", + "trust-dns-proto 0.18.0-alpha.2", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.19.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6759e8efc40465547b0dfce9500d733c65f969a4cbbfbe3ccf68daaa46ef179e" +dependencies = [ + "backtrace", + "cfg-if 0.1.10", + "futures", + "ipconfig", + "lazy_static", + "log", + "lru-cache", + "resolv-conf 0.7.0", + "smallvec", + "thiserror", + "tokio", + "trust-dns-proto 0.19.6", ] [[package]] @@ -2592,9 +2854,9 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" +checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef" dependencies = [ "tinyvec", ] @@ -2631,9 +2893,9 @@ dependencies = [ [[package]] name = "uuid" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" [[package]] name = "vcpkg" @@ -2672,9 +2934,9 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasm-bindgen" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" +checksum = "55c0f7123de74f0dab9b7d00fd614e7b19349cd1e2f5252bbe9b1754b59433be" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -2682,9 +2944,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62" +checksum = "7bc45447f0d4573f3d65720f636bbcc3dd6ce920ed704670118650bcd47764c7" dependencies = [ "bumpalo", "lazy_static", @@ -2697,9 +2959,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" +checksum = "3b8853882eef39593ad4174dd26fc9865a64e84026d223f63bb2c42affcbba2c" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2707,9 +2969,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" +checksum = "4133b5e7f2a531fa413b3a1695e925038a05a71cf67e87dafa295cb645a01385" dependencies = [ "proc-macro2", "quote", @@ -2720,15 +2982,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" +checksum = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64" [[package]] name = "web-sys" -version = "0.3.46" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" +checksum = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index a1b2cfc0b..b9ed63b2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,9 +14,9 @@ path = "src/bin/main.rs" [dependencies] actix = "0.9" -actix-cors = "0.2" +actix-cors = "0.5.4" actix-rt = "1.1" -actix-web = "2.0" +actix-web = "3.3.2" docopt = "1" env_logger = "0.8" log = "0.4" diff --git a/src/server.rs b/src/server.rs index 3763212d2..78e4f4ef2 100755 --- a/src/server.rs +++ b/src/server.rs @@ -6,7 +6,7 @@ use std::rc::Rc; use actix::{Actor, Addr, SyncArbiter, SystemRunner}; use actix_cors::Cors; use actix_web::{ - error, http, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, Result, + error, http, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, Result }; use crate::config::Config; @@ -336,12 +336,12 @@ pub fn new(pool: Pool, config: Config) -> SystemRunner { HttpServer::new(move || { let state = create_state(db.clone(), coordinator.clone(), config.clone()); - let cors_middleware = Cors::default(); + let cors_middleware = Cors::default().allow_any_origin(); App::new() .data(state) .wrap(cors_middleware) - .wrap(middleware::NormalizePath) + .wrap(middleware::NormalizePath::new(middleware::normalize::TrailingSlash::MergeOnly)) .wrap(middleware::Logger::default()) .wrap(middleware::Compress::default()) .configure(router) From af0645d441f620783df3366710d1d3ce0cec47c9 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Thu, 18 Feb 2021 15:17:37 +0100 Subject: [PATCH 02/20] Some fixes for cargo fmt. --- src/server.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server.rs b/src/server.rs index 78e4f4ef2..03ed70ab6 100755 --- a/src/server.rs +++ b/src/server.rs @@ -6,7 +6,7 @@ use std::rc::Rc; use actix::{Actor, Addr, SyncArbiter, SystemRunner}; use actix_cors::Cors; use actix_web::{ - error, http, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, Result + error, http, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, Result, }; use crate::config::Config; @@ -341,7 +341,9 @@ pub fn new(pool: Pool, config: Config) -> SystemRunner { App::new() .data(state) .wrap(cors_middleware) - .wrap(middleware::NormalizePath::new(middleware::normalize::TrailingSlash::MergeOnly)) + .wrap(middleware::NormalizePath::new( + middleware::normalize::TrailingSlash::MergeOnly, + )) .wrap(middleware::Logger::default()) .wrap(middleware::Compress::default()) .configure(router) From aca359a0afaf57b10efbbeb11e1f8bd603e5279a Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Thu, 18 Feb 2021 15:43:32 +0100 Subject: [PATCH 03/20] Fixed "error: this functions return value is unnecessarily wrapped by Result" from github actions (clippy). --- src/bin/main.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/bin/main.rs b/src/bin/main.rs index d3fefc2bf..65389a84a 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -114,7 +114,7 @@ fn setup_from_args(args: Args) -> io::Result<(Config, Pool)> { Ok((config, pool)) } -fn parse_env(args: Args) -> io::Result { +fn parse_env(args: Args) -> Args { let arg_connection = args.arg_connection.or_else(|| { env::var_os("DATABASE_URL").and_then(|connection| connection.into_string().ok()) }); @@ -124,14 +124,12 @@ fn parse_env(args: Args) -> io::Result { let flag_watch = args.flag_watch || env::var_os("WATCH_MODE").is_some(); - let args = Args { + Args { arg_connection, flag_watch, flag_danger_accept_invalid_certs, ..args - }; - - Ok(args) + } } fn start(args: Args) -> io::Result { @@ -170,7 +168,7 @@ fn main() -> io::Result<()> { .and_then(|d| d.deserialize::()) .map_err(prettify_error("Can't parse CLI arguments"))?; - let args = parse_env(args).map_err(prettify_error("Can't parse environment variables"))?; + let args = parse_env(args); if args.flag_help { println!("{}", USAGE); From 9041b8f774c5417037e523a362ae08825f4d60cb Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Thu, 25 Feb 2021 17:46:06 +0100 Subject: [PATCH 04/20] First commit with code for to check JWT. It needs a token from config.yml and other config to enable or disable jwt...and tests. --- Cargo.lock | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 ++ src/server.rs | 44 ++++++++++++++++++++++- 3 files changed, 141 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index b11ec9c7e..fc837283e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -396,6 +396,19 @@ dependencies = [ "syn", ] +[[package]] +name = "actix-web-httpauth" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "536a75d767c5c2b3e64d3f569621f38ed7609359a0c82d149c88290a6ba41b22" +dependencies = [ + "actix-service", + "actix-web", + "base64 0.12.3", + "bytes 0.5.6", + "futures-util", +] + [[package]] name = "actix_derive" version = "0.5.0" @@ -509,6 +522,12 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + [[package]] name = "base64" version = "0.13.0" @@ -1341,6 +1360,21 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonwebtokens" +version = "1.0.0-alpha.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "454b5b99a0c14d6fc1cb7b5ca031adfe2935c922b0232be9a8143c8b542daa94" +dependencies = [ + "base64 0.11.0", + "pem", + "regex", + "ring", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -1419,10 +1453,12 @@ dependencies = [ "actix-cors", "actix-rt", "actix-web", + "actix-web-httpauth", "cargo-husky", "criterion", "docopt", "env_logger", + "jsonwebtokens", "log", "native-tls", "num_cpus", @@ -1564,6 +1600,17 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "num-bigint" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -1699,6 +1746,17 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "pem" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1581760c757a756a41f0ee3ff01256227bdf64cb752839779b95ffb01c59793" +dependencies = [ + "base64 0.11.0", + "lazy_static", + "regex", +] + [[package]] name = "percent-encoding" version = "2.1.0" @@ -2125,6 +2183,21 @@ dependencies = [ "quick-error", ] +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi 0.3.9", +] + [[package]] name = "rustc-demangle" version = "0.1.18" @@ -2354,6 +2427,17 @@ dependencies = [ "libc", ] +[[package]] +name = "simple_asn1" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "692ca13de57ce0613a363c8c2f1de925adebc81b04c923ac60c5488bb44abe4b" +dependencies = [ + "chrono", + "num-bigint", + "num-traits", +] + [[package]] name = "siphasher" version = "0.3.3" @@ -2383,6 +2467,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "standback" version = "0.2.15" @@ -2879,6 +2969,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "url" version = "2.2.0" diff --git a/Cargo.toml b/Cargo.toml index b9ed63b2a..75aae23c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ actix = "0.9" actix-cors = "0.5.4" actix-rt = "1.1" actix-web = "3.3.2" +actix-web-httpauth = "0.5.0" docopt = "1" env_logger = "0.8" log = "0.4" @@ -32,6 +33,7 @@ serde_derive = "1.0" serde_json = "1.0" serde_yaml = "0.8" tilejson = "0.2" +jsonwebtokens = "1.0.0-alpha.13" [dev-dependencies] criterion = "0.3" diff --git a/src/server.rs b/src/server.rs index 03ed70ab6..39cb8caef 100755 --- a/src/server.rs +++ b/src/server.rs @@ -5,9 +5,10 @@ use std::rc::Rc; use actix::{Actor, Addr, SyncArbiter, SystemRunner}; use actix_cors::Cors; -use actix_web::{ +use actix_web::{dev, error, http, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, Result, }; +use actix_web_httpauth::{extractors::bearer::BearerAuth, middleware::HttpAuthentication}; use crate::config::Config; use crate::coordinator_actor::CoordinatorActor; @@ -19,6 +20,11 @@ use crate::source::{Source, XYZ}; use crate::table_source::TableSources; use crate::worker_actor::WorkerActor; +// For JWT +use std::str::FromStr; +use jsonwebtokens as jwt; +use jwt::{Algorithm, AlgorithmID, Verifier, raw}; + pub struct AppState { pub db: Addr, pub coordinator: Addr, @@ -323,6 +329,39 @@ fn create_state( } } +async fn bearer_auth_validator(req: dev::ServiceRequest, credentials: BearerAuth) -> Result { + let secret = "zzzz"; + + let try_catch_block = || -> Result<(Verifier, Algorithm), jwt::error::Error> { + let raw::TokenSlices {header, .. } = raw::split_token(credentials.token())?; + let header = raw::decode_json_token_slice(header)?; + let alg_name = header["alg"].as_str().unwrap_or(""); + let alg_id = AlgorithmID::from_str(alg_name)?; + + Ok((Verifier::create().build()?, Algorithm::new_hmac(alg_id, secret)?)) + }; + + match try_catch_block() { + Ok((verifier, alg)) => { + // Only check the exp claim/field from jwt. + match verifier.verify(&credentials.token(), &alg) { + Ok(_) => { + Ok(req) + }, + Err(e) => { + info!("Error verify JWT: token \"{}\" error \"{}\".", + credentials.token(), e.to_string()); + Err(error::ErrorForbidden(e.to_string())) + } + } + }, + Err(e) => { + info!("Error generate algorith and verifier JWT:token \"{}\" error \"{}\".", credentials.token(), e.to_string()); + Err(error::ErrorForbidden(e.to_string())) + } + } +} + pub fn new(pool: Pool, config: Config) -> SystemRunner { let sys = actix_rt::System::new("server"); @@ -337,6 +376,8 @@ pub fn new(pool: Pool, config: Config) -> SystemRunner { let state = create_state(db.clone(), coordinator.clone(), config.clone()); let cors_middleware = Cors::default().allow_any_origin(); + + let auth = HttpAuthentication::bearer(bearer_auth_validator); App::new() .data(state) @@ -346,6 +387,7 @@ pub fn new(pool: Pool, config: Config) -> SystemRunner { )) .wrap(middleware::Logger::default()) .wrap(middleware::Compress::default()) + .wrap(auth) .configure(router) }) .bind(listen_addresses.clone()) From 1b348053a6d2331bc385a5bb17a5041e6f4919b5 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Fri, 26 Feb 2021 11:00:14 +0100 Subject: [PATCH 05/20] A tiny change in the secret for re-enabled the husky or pre-push hook (it is annoying...but it is ok). --- src/server.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server.rs b/src/server.rs index 39cb8caef..ce052e5a3 100755 --- a/src/server.rs +++ b/src/server.rs @@ -330,7 +330,7 @@ fn create_state( } async fn bearer_auth_validator(req: dev::ServiceRequest, credentials: BearerAuth) -> Result { - let secret = "zzzz"; + let secret = "aaaa"; let try_catch_block = || -> Result<(Verifier, Algorithm), jwt::error::Error> { let raw::TokenSlices {header, .. } = raw::split_token(credentials.token())?; From 1211fa83484b04f2ce0f6edf5e18ce11f10b6fc4 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Fri, 26 Feb 2021 12:12:03 +0100 Subject: [PATCH 06/20] Fixed the warnings of clippy (from pre-push hook). --- src/server.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server.rs b/src/server.rs index ce052e5a3..ed36d6018 100755 --- a/src/server.rs +++ b/src/server.rs @@ -5,8 +5,8 @@ use std::rc::Rc; use actix::{Actor, Addr, SyncArbiter, SystemRunner}; use actix_cors::Cors; -use actix_web::{dev, - error, http, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, Result, +use actix_web::{ + dev, error, http, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, Result, }; use actix_web_httpauth::{extractors::bearer::BearerAuth, middleware::HttpAuthentication}; @@ -21,9 +21,9 @@ use crate::table_source::TableSources; use crate::worker_actor::WorkerActor; // For JWT -use std::str::FromStr; use jsonwebtokens as jwt; use jwt::{Algorithm, AlgorithmID, Verifier, raw}; +use std::str::FromStr; pub struct AppState { pub db: Addr, From f7c719ed18890ce1bcc34dfe8571d622c8bf9716 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Fri, 26 Feb 2021 12:12:58 +0100 Subject: [PATCH 07/20] Fixed another warnings of clippy (from pre-push hook). --- src/server.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/server.rs b/src/server.rs index ed36d6018..db4edfabc 100755 --- a/src/server.rs +++ b/src/server.rs @@ -329,7 +329,10 @@ fn create_state( } } -async fn bearer_auth_validator(req: dev::ServiceRequest, credentials: BearerAuth) -> Result { +async fn bearer_auth_validator( + req: dev::ServiceRequest, + credentials: BearerAuth + ) -> Result { let secret = "aaaa"; let try_catch_block = || -> Result<(Verifier, Algorithm), jwt::error::Error> { From 4779300465a73c42d55a4b7fd311e28b25d9e11a Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Fri, 26 Feb 2021 12:14:54 +0100 Subject: [PATCH 08/20] Fixed another warnings of clippy (from pre-push hook). --- src/server.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server.rs b/src/server.rs index db4edfabc..37a9177c4 100755 --- a/src/server.rs +++ b/src/server.rs @@ -22,7 +22,7 @@ use crate::worker_actor::WorkerActor; // For JWT use jsonwebtokens as jwt; -use jwt::{Algorithm, AlgorithmID, Verifier, raw}; +use jwt::{raw, Algorithm, AlgorithmID, Verifier}; use std::str::FromStr; pub struct AppState { @@ -331,12 +331,12 @@ fn create_state( async fn bearer_auth_validator( req: dev::ServiceRequest, - credentials: BearerAuth + credentials: BearerAuth, ) -> Result { let secret = "aaaa"; let try_catch_block = || -> Result<(Verifier, Algorithm), jwt::error::Error> { - let raw::TokenSlices {header, .. } = raw::split_token(credentials.token())?; + let raw::TokenSlices { header, .. } = raw::split_token(credentials.token())?; let header = raw::decode_json_token_slice(header)?; let alg_name = header["alg"].as_str().unwrap_or(""); let alg_id = AlgorithmID::from_str(alg_name)?; From 356cc22a5524127fdbed894e7b59550be61fe3ad Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Fri, 26 Feb 2021 12:24:51 +0100 Subject: [PATCH 09/20] Fixed another warnings of clippy (from pre-push hook). --- src/server.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server.rs b/src/server.rs index 37a9177c4..25a01be7c 100755 --- a/src/server.rs +++ b/src/server.rs @@ -332,7 +332,8 @@ fn create_state( async fn bearer_auth_validator( req: dev::ServiceRequest, credentials: BearerAuth, - ) -> Result { + ) + -> Result { let secret = "aaaa"; let try_catch_block = || -> Result<(Verifier, Algorithm), jwt::error::Error> { From 24c2ae0298ed1199dd11b34bb86015bf93c0dffc Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Fri, 26 Feb 2021 12:25:01 +0100 Subject: [PATCH 10/20] Fixed another warnings of clippy (from pre-push hook). --- src/server.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/server.rs b/src/server.rs index 25a01be7c..77ce605b2 100755 --- a/src/server.rs +++ b/src/server.rs @@ -342,19 +342,23 @@ async fn bearer_auth_validator( let alg_name = header["alg"].as_str().unwrap_or(""); let alg_id = AlgorithmID::from_str(alg_name)?; - Ok((Verifier::create().build()?, Algorithm::new_hmac(alg_id, secret)?)) + Ok(( + Verifier::create().build()?, + Algorithm::new_hmac(alg_id, secret)? + )) }; match try_catch_block() { Ok((verifier, alg)) => { // Only check the exp claim/field from jwt. match verifier.verify(&credentials.token(), &alg) { - Ok(_) => { - Ok(req) - }, + Ok(_) => Ok(req), Err(e) => { - info!("Error verify JWT: token \"{}\" error \"{}\".", - credentials.token(), e.to_string()); + info!( + "Error verify JWT: token \"{}\" error \"{}\".", + credentials.token(), + e.to_string() + ); Err(error::ErrorForbidden(e.to_string())) } } From 343e7ba71c06b17cfd525d998c580f0e6d7811c0 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Fri, 26 Feb 2021 12:27:40 +0100 Subject: [PATCH 11/20] Fixed another warnings of clippy (from pre-push hook). --- src/server.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/server.rs b/src/server.rs index 77ce605b2..67083bcf4 100755 --- a/src/server.rs +++ b/src/server.rs @@ -333,7 +333,7 @@ async fn bearer_auth_validator( req: dev::ServiceRequest, credentials: BearerAuth, ) - -> Result { +-> Result { let secret = "aaaa"; let try_catch_block = || -> Result<(Verifier, Algorithm), jwt::error::Error> { @@ -344,7 +344,7 @@ async fn bearer_auth_validator( Ok(( Verifier::create().build()?, - Algorithm::new_hmac(alg_id, secret)? + Algorithm::new_hmac(alg_id, secret)?, )) }; @@ -360,11 +360,15 @@ async fn bearer_auth_validator( e.to_string() ); Err(error::ErrorForbidden(e.to_string())) - } + }, } }, Err(e) => { - info!("Error generate algorith and verifier JWT:token \"{}\" error \"{}\".", credentials.token(), e.to_string()); + info!( + "Error generate algorith and verifier JWT:token \"{}\" error \"{}\".", + credentials.token(), + e.to_string() + ); Err(error::ErrorForbidden(e.to_string())) } } @@ -384,7 +388,7 @@ pub fn new(pool: Pool, config: Config) -> SystemRunner { let state = create_state(db.clone(), coordinator.clone(), config.clone()); let cors_middleware = Cors::default().allow_any_origin(); - + let auth = HttpAuthentication::bearer(bearer_auth_validator); App::new() From 633b54d72d8628b7233fb7edeb880497737c30ea Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Fri, 26 Feb 2021 12:30:05 +0100 Subject: [PATCH 12/20] Fixed another warnings of clippy (from pre-push hook). --- src/server.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server.rs b/src/server.rs index 67083bcf4..bbd2ad087 100755 --- a/src/server.rs +++ b/src/server.rs @@ -335,13 +335,13 @@ async fn bearer_auth_validator( ) -> Result { let secret = "aaaa"; - + let try_catch_block = || -> Result<(Verifier, Algorithm), jwt::error::Error> { let raw::TokenSlices { header, .. } = raw::split_token(credentials.token())?; let header = raw::decode_json_token_slice(header)?; let alg_name = header["alg"].as_str().unwrap_or(""); let alg_id = AlgorithmID::from_str(alg_name)?; - + Ok(( Verifier::create().build()?, Algorithm::new_hmac(alg_id, secret)?, @@ -360,9 +360,9 @@ async fn bearer_auth_validator( e.to_string() ); Err(error::ErrorForbidden(e.to_string())) - }, + } } - }, + } Err(e) => { info!( "Error generate algorith and verifier JWT:token \"{}\" error \"{}\".", From 3b088ccfc377a74406cc357fc5740695f36746a8 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Fri, 26 Feb 2021 12:31:05 +0100 Subject: [PATCH 13/20] Fixed another warnings of clippy (from pre-push hook). --- src/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server.rs b/src/server.rs index bbd2ad087..d70a1d925 100755 --- a/src/server.rs +++ b/src/server.rs @@ -333,7 +333,7 @@ async fn bearer_auth_validator( req: dev::ServiceRequest, credentials: BearerAuth, ) --> Result { + -> Result { let secret = "aaaa"; let try_catch_block = || -> Result<(Verifier, Algorithm), jwt::error::Error> { @@ -347,7 +347,7 @@ async fn bearer_auth_validator( Algorithm::new_hmac(alg_id, secret)?, )) }; - + match try_catch_block() { Ok((verifier, alg)) => { // Only check the exp claim/field from jwt. From a1a125ffc51cbef49a2c14a3ceab4cbdd939a90d Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Fri, 26 Feb 2021 12:32:47 +0100 Subject: [PATCH 14/20] Fixed another warnings of clippy (from pre-push hook). --- src/server.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server.rs b/src/server.rs index d70a1d925..bf653fe49 100755 --- a/src/server.rs +++ b/src/server.rs @@ -333,7 +333,7 @@ async fn bearer_auth_validator( req: dev::ServiceRequest, credentials: BearerAuth, ) - -> Result { + -> Result { let secret = "aaaa"; let try_catch_block = || -> Result<(Verifier, Algorithm), jwt::error::Error> { From 344d77b5d2f400c64bec9171e1e573fea8e1c340 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Sat, 27 Feb 2021 04:14:34 +0100 Subject: [PATCH 15/20] Now the flag jwt (enable/disable...by default disabled) and jwt_secret from arg or config file. --- README.md | 2 ++ src/bin/main.rs | 6 ++++++ src/config.rs | 6 ++++++ src/server.rs | 11 +++++------ tests/config.yaml | 6 ++++++ 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3b78fe6f0..cae800747 100755 --- a/README.md +++ b/README.md @@ -251,6 +251,8 @@ Options: --watch Scan for new sources on sources list requests. --workers= Number of web server workers. --danger-accept-invalid-certs Trust invalid certificates. This introduces significant vulnerabilities, and should only be used as a last resort. + --jwt Enable secure endpoints with JWT. + --jwt-secret= A secret to verify signature (need JWT enabled). ``` ## Environment Variables diff --git a/src/bin/main.rs b/src/bin/main.rs index 65389a84a..d8e77c1b9 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -33,6 +33,8 @@ Options: --watch Scan for new sources on sources list requests. --workers= Number of web server workers. --danger-accept-invalid-certs Trust invalid certificates. This introduces significant vulnerabilities, and should only be used as a last resort. + --jwt Enable secure endpoints with JWT. + --jwt-secret= A secret to verify signature (need JWT enabled). "; #[derive(Debug, Deserialize)] @@ -47,6 +49,8 @@ pub struct Args { pub flag_version: bool, pub flag_workers: Option, pub flag_danger_accept_invalid_certs: bool, + pub flag_jwt: bool, + pub flag_jwt_secret: Option, } pub fn generate_config(args: Args, pool: &Pool) -> io::Result { @@ -71,6 +75,8 @@ pub fn generate_config(args: Args, pool: &Pool) -> io::Result { table_sources: Some(table_sources), function_sources: Some(function_sources), danger_accept_invalid_certs: Some(args.flag_danger_accept_invalid_certs), + jwt: Some(args.flag_jwt), + jwt_secret: args.flag_jwt_secret, }; let config = config.finalize(); diff --git a/src/config.rs b/src/config.rs index 24bc88fea..daac227d1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -17,6 +17,8 @@ pub struct Config { pub table_sources: Option, pub function_sources: Option, pub danger_accept_invalid_certs: bool, + pub jwt: bool, + pub jwt_secret: String, } #[derive(Deserialize)] @@ -30,6 +32,8 @@ pub struct ConfigBuilder { pub table_sources: Option, pub function_sources: Option, pub danger_accept_invalid_certs: Option, + pub jwt: Option, + pub jwt_secret: Option, } impl ConfigBuilder { @@ -46,6 +50,8 @@ impl ConfigBuilder { table_sources: self.table_sources, function_sources: self.function_sources, danger_accept_invalid_certs: self.danger_accept_invalid_certs.unwrap_or(false), + jwt: self.jwt.unwrap_or(false), + jwt_secret: self.jwt_secret.unwrap_or_else(|| "".to_owned()), } } } diff --git a/src/server.rs b/src/server.rs index bf653fe49..007591921 100755 --- a/src/server.rs +++ b/src/server.rs @@ -332,11 +332,10 @@ fn create_state( async fn bearer_auth_validator( req: dev::ServiceRequest, credentials: BearerAuth, - ) - -> Result { - let secret = "aaaa"; +) -> Result { let try_catch_block = || -> Result<(Verifier, Algorithm), jwt::error::Error> { + let secret = req.app_data::().unwrap().as_str(); let raw::TokenSlices { header, .. } = raw::split_token(credentials.token())?; let header = raw::decode_json_token_slice(header)?; let alg_name = header["alg"].as_str().unwrap_or(""); @@ -365,7 +364,7 @@ async fn bearer_auth_validator( } Err(e) => { info!( - "Error generate algorith and verifier JWT:token \"{}\" error \"{}\".", + "Error generate algorith and verifier JWT: token \"{}\" error \"{}\".", credentials.token(), e.to_string() ); @@ -388,10 +387,10 @@ pub fn new(pool: Pool, config: Config) -> SystemRunner { let state = create_state(db.clone(), coordinator.clone(), config.clone()); let cors_middleware = Cors::default().allow_any_origin(); - let auth = HttpAuthentication::bearer(bearer_auth_validator); App::new() + .app_data(config.jwt_secret.clone()) .data(state) .wrap(cors_middleware) .wrap(middleware::NormalizePath::new( @@ -399,7 +398,7 @@ pub fn new(pool: Pool, config: Config) -> SystemRunner { )) .wrap(middleware::Logger::default()) .wrap(middleware::Compress::default()) - .wrap(auth) + .wrap(middleware::Condition::new(config.jwt, auth)) .configure(router) }) .bind(listen_addresses.clone()) diff --git a/tests/config.yaml b/tests/config.yaml index dbfa788f2..19cce356f 100644 --- a/tests/config.yaml +++ b/tests/config.yaml @@ -20,6 +20,12 @@ danger_accept_invalid_certs: false # Number of web server workers worker_processes: 8 +# Enable secure endpoints with JWT. +jwt: false + +#A secret to verify signature (need JWT enabled). +jwt_secret: "" + # associative arrays of table sources table_sources: public.table_source: From d611e35ed0ba91ec89f12f24400d28136c029be6 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Sat, 27 Feb 2021 04:23:57 +0100 Subject: [PATCH 16/20] Fixed a warning from cargo fmt. --- src/server.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/server.rs b/src/server.rs index 007591921..c98d80707 100755 --- a/src/server.rs +++ b/src/server.rs @@ -333,7 +333,6 @@ async fn bearer_auth_validator( req: dev::ServiceRequest, credentials: BearerAuth, ) -> Result { - let try_catch_block = || -> Result<(Verifier, Algorithm), jwt::error::Error> { let secret = req.app_data::().unwrap().as_str(); let raw::TokenSlices { header, .. } = raw::split_token(credentials.token())?; From 0b00f79cb30c92769e54a1c2aca07f0996da5339 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Mon, 1 Mar 2021 13:44:09 +0100 Subject: [PATCH 17/20] Added the parameter (in shell and as config) jwt_algorithm to set the algorithm to check jwt. --- README.md | 1 + src/bin/main.rs | 3 +++ src/config.rs | 3 +++ src/server.rs | 27 +++++++++++++++++++++------ tests/config.yaml | 5 ++++- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a1988811a..ed5d46eda 100755 --- a/README.md +++ b/README.md @@ -305,6 +305,7 @@ Options: --danger-accept-invalid-certs Trust invalid certificates. This introduces significant vulnerabilities, and should only be used as a last resort. --jwt Enable secure endpoints with JWT. --jwt-secret= A secret to verify signature (need JWT enabled). + --jwt-algorithm= Algorithm can be: empty (autodetect from jwt token dangerous), HS256, HS384, HS512, ES256, ES384, RS256, RS384, RS512, PS256, PS384 or PS512. ``` ## Environment Variables diff --git a/src/bin/main.rs b/src/bin/main.rs index d8e77c1b9..b9da9242e 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -35,6 +35,7 @@ Options: --danger-accept-invalid-certs Trust invalid certificates. This introduces significant vulnerabilities, and should only be used as a last resort. --jwt Enable secure endpoints with JWT. --jwt-secret= A secret to verify signature (need JWT enabled). + --jwt-algorithm= Algorithm can be: empty (autodetect from jwt token dangerous), HS256, HS384, HS512, ES256, ES384, RS256, RS384, RS512, PS256, PS384 or PS512. "; #[derive(Debug, Deserialize)] @@ -51,6 +52,7 @@ pub struct Args { pub flag_danger_accept_invalid_certs: bool, pub flag_jwt: bool, pub flag_jwt_secret: Option, + pub flag_jwt_algorithm: Option, } pub fn generate_config(args: Args, pool: &Pool) -> io::Result { @@ -77,6 +79,7 @@ pub fn generate_config(args: Args, pool: &Pool) -> io::Result { danger_accept_invalid_certs: Some(args.flag_danger_accept_invalid_certs), jwt: Some(args.flag_jwt), jwt_secret: args.flag_jwt_secret, + jwt_algorithm: args.flag_jwt_algorithm, }; let config = config.finalize(); diff --git a/src/config.rs b/src/config.rs index daac227d1..d74ecbc2d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -19,6 +19,7 @@ pub struct Config { pub danger_accept_invalid_certs: bool, pub jwt: bool, pub jwt_secret: String, + pub jwt_algorithm: String, } #[derive(Deserialize)] @@ -34,6 +35,7 @@ pub struct ConfigBuilder { pub danger_accept_invalid_certs: Option, pub jwt: Option, pub jwt_secret: Option, + pub jwt_algorithm: Option, } impl ConfigBuilder { @@ -52,6 +54,7 @@ impl ConfigBuilder { danger_accept_invalid_certs: self.danger_accept_invalid_certs.unwrap_or(false), jwt: self.jwt.unwrap_or(false), jwt_secret: self.jwt_secret.unwrap_or_else(|| "".to_owned()), + jwt_algorithm: self.jwt_algorithm.unwrap_or_else(|| "".to_owned()), } } } diff --git a/src/server.rs b/src/server.rs index c98d80707..56cd2e237 100755 --- a/src/server.rs +++ b/src/server.rs @@ -25,6 +25,11 @@ use jsonwebtokens as jwt; use jwt::{raw, Algorithm, AlgorithmID, Verifier}; use std::str::FromStr; +pub struct JWTConfig { + pub jwt_secret: String, + pub jwt_algorithm: String, +} + pub struct AppState { pub db: Addr, pub coordinator: Addr, @@ -334,15 +339,21 @@ async fn bearer_auth_validator( credentials: BearerAuth, ) -> Result { let try_catch_block = || -> Result<(Verifier, Algorithm), jwt::error::Error> { - let secret = req.app_data::().unwrap().as_str(); - let raw::TokenSlices { header, .. } = raw::split_token(credentials.token())?; - let header = raw::decode_json_token_slice(header)?; - let alg_name = header["alg"].as_str().unwrap_or(""); + let jwt_config = req.app_data::().unwrap(); + + let header_json; + let alg_name = if jwt_config.jwt_algorithm == "" { + let raw::TokenSlices { header, .. } = raw::split_token(credentials.token())?; + header_json = raw::decode_json_token_slice(header)?; + header_json["alg"].as_str().unwrap_or("") + } else { + jwt_config.jwt_algorithm.as_str() + }; let alg_id = AlgorithmID::from_str(alg_name)?; Ok(( Verifier::create().build()?, - Algorithm::new_hmac(alg_id, secret)?, + Algorithm::new_hmac(alg_id, jwt_config.jwt_secret.as_str())?, )) }; @@ -384,12 +395,16 @@ pub fn new(pool: Pool, config: Config) -> SystemRunner { HttpServer::new(move || { let state = create_state(db.clone(), coordinator.clone(), config.clone()); + let jwt_config = JWTConfig { + jwt_secret: config.jwt_secret.clone(), + jwt_algorithm: config.jwt_algorithm.clone(), + }; let cors_middleware = Cors::default().allow_any_origin(); let auth = HttpAuthentication::bearer(bearer_auth_validator); App::new() - .app_data(config.jwt_secret.clone()) + .app_data(jwt_config) .data(state) .wrap(cors_middleware) .wrap(middleware::NormalizePath::new( diff --git a/tests/config.yaml b/tests/config.yaml index 19cce356f..9d572be0b 100644 --- a/tests/config.yaml +++ b/tests/config.yaml @@ -23,9 +23,12 @@ worker_processes: 8 # Enable secure endpoints with JWT. jwt: false -#A secret to verify signature (need JWT enabled). +# A secret to verify signature (need JWT enabled). jwt_secret: "" +# Algorithm can be: empty (autodetect from jwt token dangerous), HS256, HS384, HS512, ES256, ES384, RS256, RS384, RS512, PS256, PS384 or PS512.. +jwt_algorithm: "" + # associative arrays of table sources table_sources: public.table_source: From 88f628baa44f0048510e6a280fc73d6078b2e726 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Mon, 1 Mar 2021 13:45:26 +0100 Subject: [PATCH 18/20] Fix cargo clippy warning. --- src/server.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server.rs b/src/server.rs index 56cd2e237..2b0d31793 100755 --- a/src/server.rs +++ b/src/server.rs @@ -342,7 +342,7 @@ async fn bearer_auth_validator( let jwt_config = req.app_data::().unwrap(); let header_json; - let alg_name = if jwt_config.jwt_algorithm == "" { + let alg_name = if jwt_config.jwt_algorithm.is_empty() { let raw::TokenSlices { header, .. } = raw::split_token(credentials.token())?; header_json = raw::decode_json_token_slice(header)?; header_json["alg"].as_str().unwrap_or("") From 3fd133176474545239ce3d09c3e69e76e24af161 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Mon, 1 Mar 2021 16:09:38 +0100 Subject: [PATCH 19/20] Added feature to check exp time in jwt. --- README.md | 1 + src/bin/main.rs | 3 +++ src/config.rs | 3 +++ src/server.rs | 36 ++++++++++++++++++++++++++++++------ tests/config.yaml | 5 ++++- 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ed5d46eda..75bfc4d0b 100755 --- a/README.md +++ b/README.md @@ -306,6 +306,7 @@ Options: --jwt Enable secure endpoints with JWT. --jwt-secret= A secret to verify signature (need JWT enabled). --jwt-algorithm= Algorithm can be: empty (autodetect from jwt token dangerous), HS256, HS384, HS512, ES256, ES384, RS256, RS384, RS512, PS256, PS384 or PS512. + --jwt-check-exp-time Enable check expiration time in claims, by default disabled. ``` ## Environment Variables diff --git a/src/bin/main.rs b/src/bin/main.rs index b9da9242e..3e392bf0f 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -36,6 +36,7 @@ Options: --jwt Enable secure endpoints with JWT. --jwt-secret= A secret to verify signature (need JWT enabled). --jwt-algorithm= Algorithm can be: empty (autodetect from jwt token dangerous), HS256, HS384, HS512, ES256, ES384, RS256, RS384, RS512, PS256, PS384 or PS512. + --jwt-check-exp-time Enable check expiration time in claims, by default disabled. "; #[derive(Debug, Deserialize)] @@ -53,6 +54,7 @@ pub struct Args { pub flag_jwt: bool, pub flag_jwt_secret: Option, pub flag_jwt_algorithm: Option, + pub flag_jwt_check_exp_time: bool, } pub fn generate_config(args: Args, pool: &Pool) -> io::Result { @@ -80,6 +82,7 @@ pub fn generate_config(args: Args, pool: &Pool) -> io::Result { jwt: Some(args.flag_jwt), jwt_secret: args.flag_jwt_secret, jwt_algorithm: args.flag_jwt_algorithm, + jwt_check_exp_time: Some(args.flag_jwt_check_exp_time), }; let config = config.finalize(); diff --git a/src/config.rs b/src/config.rs index d74ecbc2d..711427b0e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -20,6 +20,7 @@ pub struct Config { pub jwt: bool, pub jwt_secret: String, pub jwt_algorithm: String, + pub jwt_check_exp_time: bool, } #[derive(Deserialize)] @@ -36,6 +37,7 @@ pub struct ConfigBuilder { pub jwt: Option, pub jwt_secret: Option, pub jwt_algorithm: Option, + pub jwt_check_exp_time: Option, } impl ConfigBuilder { @@ -55,6 +57,7 @@ impl ConfigBuilder { jwt: self.jwt.unwrap_or(false), jwt_secret: self.jwt_secret.unwrap_or_else(|| "".to_owned()), jwt_algorithm: self.jwt_algorithm.unwrap_or_else(|| "".to_owned()), + jwt_check_exp_time: self.jwt_check_exp_time.unwrap_or(false), } } } diff --git a/src/server.rs b/src/server.rs index 2b0d31793..8419db35e 100755 --- a/src/server.rs +++ b/src/server.rs @@ -24,10 +24,12 @@ use crate::worker_actor::WorkerActor; use jsonwebtokens as jwt; use jwt::{raw, Algorithm, AlgorithmID, Verifier}; use std::str::FromStr; +use std::time::SystemTime; pub struct JWTConfig { pub jwt_secret: String, pub jwt_algorithm: String, + pub jwt_check_exp_time: bool, } pub struct AppState { @@ -338,12 +340,13 @@ async fn bearer_auth_validator( req: dev::ServiceRequest, credentials: BearerAuth, ) -> Result { - let try_catch_block = || -> Result<(Verifier, Algorithm), jwt::error::Error> { - let jwt_config = req.app_data::().unwrap(); + let jwt_config = req.app_data::().unwrap(); + let try_catch_block = || -> Result<(Verifier, Algorithm, bool), jwt::error::Error> { let header_json; + let raw::TokenSlices { header, claims, .. } = raw::split_token(credentials.token())?; + let claims_json = raw::decode_json_token_slice(claims)?; let alg_name = if jwt_config.jwt_algorithm.is_empty() { - let raw::TokenSlices { header, .. } = raw::split_token(credentials.token())?; header_json = raw::decode_json_token_slice(header)?; header_json["alg"].as_str().unwrap_or("") } else { @@ -354,13 +357,32 @@ async fn bearer_auth_validator( Ok(( Verifier::create().build()?, Algorithm::new_hmac(alg_id, jwt_config.jwt_secret.as_str())?, + claims_json["exp"].is_null(), )) }; match try_catch_block() { - Ok((verifier, alg)) => { - // Only check the exp claim/field from jwt. - match verifier.verify(&credentials.token(), &alg) { + Ok((verifier, alg, exp_is_null)) => { + let result = if jwt_config.jwt_check_exp_time { + if exp_is_null { + return Err(error::ErrorForbidden("Claim exp does not exist.")); + } + + let now_unixtimestamp = SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .unwrap() + .as_secs(); + match verifier.verify_for_time(&credentials.token(), &alg, now_unixtimestamp) { + Ok(_) => Ok(true), + Err(e) => Err(e), + } + } else { + match verifier.verify(&credentials.token(), &alg) { + Ok(_) => Ok(true), + Err(e) => Err(e), + } + }; + match result { Ok(_) => Ok(req), Err(e) => { info!( @@ -395,9 +417,11 @@ pub fn new(pool: Pool, config: Config) -> SystemRunner { HttpServer::new(move || { let state = create_state(db.clone(), coordinator.clone(), config.clone()); + let jwt_config = JWTConfig { jwt_secret: config.jwt_secret.clone(), jwt_algorithm: config.jwt_algorithm.clone(), + jwt_check_exp_time: config.jwt_check_exp_time.clone(), }; let cors_middleware = Cors::default().allow_any_origin(); diff --git a/tests/config.yaml b/tests/config.yaml index 9d572be0b..4b706e7b5 100644 --- a/tests/config.yaml +++ b/tests/config.yaml @@ -26,9 +26,12 @@ jwt: false # A secret to verify signature (need JWT enabled). jwt_secret: "" -# Algorithm can be: empty (autodetect from jwt token dangerous), HS256, HS384, HS512, ES256, ES384, RS256, RS384, RS512, PS256, PS384 or PS512.. +# Algorithm can be: empty (autodetect from jwt token dangerous), HS256, HS384, HS512, ES256, ES384, RS256, RS384, RS512, PS256, PS384 or PS512. jwt_algorithm: "" +# Enable check expiration time in claims, by default disabled. +jwt_check_exp_time: false + # associative arrays of table sources table_sources: public.table_source: From 4e5e0334d9a4d2ba3349c907dbb03ba1b3e14737 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Matias Date: Mon, 1 Mar 2021 16:11:59 +0100 Subject: [PATCH 20/20] Fixed clippy warning. --- src/server.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server.rs b/src/server.rs index 8419db35e..945a5a4cd 100755 --- a/src/server.rs +++ b/src/server.rs @@ -421,7 +421,7 @@ pub fn new(pool: Pool, config: Config) -> SystemRunner { let jwt_config = JWTConfig { jwt_secret: config.jwt_secret.clone(), jwt_algorithm: config.jwt_algorithm.clone(), - jwt_check_exp_time: config.jwt_check_exp_time.clone(), + jwt_check_exp_time: config.jwt_check_exp_time, }; let cors_middleware = Cors::default().allow_any_origin();