diff --git a/Cargo.lock b/Cargo.lock index e9da32a..0b3cac3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,7 +11,7 @@ dependencies = [ "actix-macros", "actix-rt", "actix_derive", - "bitflags", + "bitflags 2.6.0", "bytes", "crossbeam-channel", "futures-core", @@ -33,7 +33,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" dependencies = [ - "bitflags", + "bitflags 2.6.0", "bytes", "futures-core", "futures-sink", @@ -55,8 +55,8 @@ dependencies = [ "actix-service", "actix-utils", "ahash", - "base64", - "bitflags", + "base64 0.22.1", + "bitflags 2.6.0", "brotli", "bytes", "bytestring", @@ -324,7 +324,7 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -334,7 +334,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -372,7 +372,7 @@ dependencies = [ "miniz_oxide", "object", "rustc-demangle", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -381,6 +381,18 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "base64" version = "0.22.1" @@ -393,6 +405,12 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.6.0" @@ -485,7 +503,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -531,6 +549,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -598,6 +626,41 @@ dependencies = [ "typenum", ] +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "der" version = "0.7.9" @@ -616,6 +679,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -721,6 +785,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "fallible-iterator" version = "0.3.0" @@ -733,6 +807,12 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" +[[package]] +name = "fastrand" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" + [[package]] name = "ff" version = "0.13.0" @@ -759,6 +839,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -908,13 +1003,19 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 2.5.0", "slab", "tokio", "tokio-util", "tracing", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hashbrown" version = "0.14.5" @@ -930,7 +1031,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" dependencies = [ - "hashbrown", + "hashbrown 0.14.5", ] [[package]] @@ -939,6 +1040,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "hmac" version = "0.12.1" @@ -959,6 +1066,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + [[package]] name = "httparse" version = "1.9.4" @@ -977,6 +1095,43 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "hyper" +version = "0.14.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + [[package]] name = "hyperflake-rs" version = "0.1.1" @@ -1006,6 +1161,12 @@ dependencies = [ "cc", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.5.0" @@ -1022,6 +1183,17 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206ca75c9c03ba3d4ace2460e57b189f39f43de612c2f85836e65c929701bb2d" +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + [[package]] name = "indexmap" version = "2.5.0" @@ -1029,9 +1201,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.14.5", + "serde", ] +[[package]] +name = "ipnet" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -1062,6 +1241,24 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jwtk" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f968792e4a4e8ffd2fcd6adab9a096c6bdb42eb584a0ee7068ec91c62a08ff65" +dependencies = [ + "base64 0.13.1", + "foreign-types", + "openssl", + "openssl-sys", + "reqwest", + "serde", + "serde_json", + "serde_with", + "smallvec", + "tokio", +] + [[package]] name = "language-tags" version = "0.3.2" @@ -1091,6 +1288,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + [[package]] name = "listenfd" version = "1.0.1" @@ -1171,6 +1374,7 @@ dependencies = [ "dotenv", "env_logger", "hyperflake-rs", + "jwtk", "lazy_static", "listenfd", "min_jwt", @@ -1253,7 +1457,7 @@ dependencies = [ "libc", "log", "wasi", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1262,6 +1466,23 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d02c0b00610773bb7fc61d85e13d86c7858cbdf00e1a120bfc41bc055dbaa0e" +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "num-bigint" version = "0.4.6" @@ -1311,6 +1532,50 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl" +version = "0.10.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "p256" version = "0.13.2" @@ -1343,7 +1608,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1520,7 +1785,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags", + "bitflags 2.6.0", ] [[package]] @@ -1558,6 +1823,46 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -1574,7 +1879,7 @@ version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e" dependencies = [ - "bitflags", + "bitflags 2.6.0", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -1597,12 +1902,43 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.38.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + [[package]] name = "ryu" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "schannel" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1623,6 +1959,29 @@ dependencies = [ "zeroize", ] +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.23" @@ -1673,6 +2032,36 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.5.0", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "sha1" version = "0.10.6" @@ -1748,7 +2137,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1761,6 +2150,12 @@ dependencies = [ "der", ] +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "subtle" version = "2.6.1" @@ -1778,6 +2173,46 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +dependencies = [ + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + [[package]] name = "time" version = "0.3.36" @@ -1839,7 +2274,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1853,6 +2288,16 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.12" @@ -1866,6 +2311,12 @@ dependencies = [ "tokio", ] +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + [[package]] name = "tracing" version = "0.1.40" @@ -1911,6 +2362,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "typenum" version = "1.17.0" @@ -1976,6 +2433,15 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2008,6 +2474,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.93" @@ -2037,6 +2515,16 @@ version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +[[package]] +name = "web-sys" +version = "0.3.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.3.9" @@ -2065,7 +2553,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", ] [[package]] @@ -2074,7 +2571,31 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -2083,28 +2604,46 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -2117,30 +2656,64 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "zerocopy" version = "0.7.35" diff --git a/crates/http/Cargo.toml b/crates/http/Cargo.toml index f98784b..07ad2de 100644 --- a/crates/http/Cargo.toml +++ b/crates/http/Cargo.toml @@ -22,4 +22,5 @@ rusqlite = { version = "0.32.0", features = ["bundled"] } chrono = { version = "0.4.34", features = ["serde", "clock"] } min_jwt = { version = "0.10.0", features = [ "p256", "serde", "serde_json"] } p256 = { version = "0.13.0", features = [ "ecdsa"] } -rand = "0.8" \ No newline at end of file +rand = "0.8" +jwtk = "0.3.0" \ No newline at end of file diff --git a/crates/http/src/controller/data.rs b/crates/http/src/controller/data.rs index e965c49..25a3984 100644 --- a/crates/http/src/controller/data.rs +++ b/crates/http/src/controller/data.rs @@ -1,7 +1,7 @@ use crate::config::env::get_env; use crate::libs::db::{self, Node, NodeRegistration}; use crate::libs::http::AppState; -use crate::libs::jwt::{generate_jwt, verify_jwt}; +use crate::libs::jwt::{self, generate_jwt}; use actix_web::{get, post, web, HttpRequest}; use serde::Deserialize; @@ -20,10 +20,6 @@ struct NodeVerify { token: String, } -#[derive(Deserialize, serde::Serialize)] -struct VerifyResult { - success: bool, -} #[derive(Deserialize, serde::Serialize)] struct ListNodesResult { @@ -123,7 +119,7 @@ async fn verify_node( req: HttpRequest, body: web::Json, data: web::Data, -) -> actix_web::web::Json { +) -> actix_web::web::Json { let register_token: Option<&str> = get_register_token(&req); let register_token: String = match register_token { @@ -132,23 +128,39 @@ async fn verify_node( }; if register_token == "" { - return actix_web::web::Json(VerifyResult { success: false }); + return actix_web::web::Json(jwt::VerifyNDecodedResult { + success: false, + app_node: None, + node_id: None, + }); } if register_token != get_env().registration_token { - return actix_web::web::Json(VerifyResult { success: false }); + return actix_web::web::Json(jwt::VerifyNDecodedResult { + success: false, + app_node: None, + node_id: None, + }); } let token = body.token.clone(); if token == "" { - return actix_web::web::Json(VerifyResult { success: false }); + return actix_web::web::Json(jwt::VerifyNDecodedResult { + success:false, + node_id: None, + app_node: None, + }); } - let jwt_result = verify_jwt(&token, &data.public_key); + let public_key = jwt::generate_public_key(data.private_key.clone()); + + let jwt_result = jwt::verify_jwt(&token, public_key); - actix_web::web::Json(VerifyResult { - success: jwt_result, + actix_web::web::Json(jwt::VerifyNDecodedResult { + success: jwt_result.success, + app_node: jwt_result.app_node, + node_id: jwt_result.node_id, }) } diff --git a/crates/http/src/controller/root.rs b/crates/http/src/controller/root.rs index 3ab04bb..c479e8c 100644 --- a/crates/http/src/controller/root.rs +++ b/crates/http/src/controller/root.rs @@ -1,5 +1,8 @@ use actix_web::{get, web}; use serde::Serialize; +use crate::libs::{http::AppState, jwt::generate_jwks}; +use jwtk; + #[derive(Serialize)] pub struct Status { @@ -13,6 +16,24 @@ async fn health() -> web::Json { }) } +#[derive(Serialize)] +pub struct Jwks { + keys: Vec, +} + +#[get("/jwks.json")] +async fn jwks( + data: web::Data, +) -> web::Json { + let private_key = data.private_key.clone(); + let jwks: jwtk::jwk::Jwk = generate_jwks(private_key); + + web::Json(Jwks { + keys: vec![jwks], + }) +} + pub fn init_root_routes(config: &mut web::ServiceConfig) { config.service(health); + config.service(jwks); } diff --git a/crates/http/src/libs/db.rs b/crates/http/src/libs/db.rs index d5c0b71..3cf6567 100644 --- a/crates/http/src/libs/db.rs +++ b/crates/http/src/libs/db.rs @@ -73,90 +73,4 @@ pub async fn get_all_nodes(connection: &mut redis::aio::MultiplexedConnection) - } NodeList { nodes: Some(nodes) } -} - -// Get Node by Name -pub async fn get_node_by_name( - connection: &mut redis::aio::MultiplexedConnection, - app_node: &str, -) -> Node { - let hash_key: String = "node_".to_owned() + &app_node; - let id: String = connection.hget(&hash_key, "id").await.unwrap(); - let app_node: String = connection.hget(&hash_key, "app_node").await.unwrap(); - let last_token_issue_at: String = connection - .hget(&hash_key, "last_token_issue_at") - .await - .unwrap(); - let last_ping_on: String = connection.hget(&hash_key, "last_ping_on").await.unwrap(); - - Node { - id: id, - app_node: app_node, - last_token_issue_at: last_token_issue_at, - last_ping_on: last_ping_on, - } -} - -// Update last_token_issue_at Node by Name -pub async fn update_last_token_issue_at_node_by_name( - connection: &mut redis::aio::MultiplexedConnection, - app_node: &str, - last_token_issue_at: &str, -) -> Node { - let hash_key: String = "node_".to_owned() + &app_node; - let _: () = connection - .hset(&hash_key, "last_token_issue_at", last_token_issue_at) - .await - .unwrap(); - - let id: String = connection.hget(&hash_key, "id").await.unwrap(); - let app_node: String = connection.hget(&hash_key, "app_node").await.unwrap(); - let last_token_issue_at: String = connection - .hget(&hash_key, "last_token_issue_at") - .await - .unwrap(); - let last_ping_on: String = connection.hget(&hash_key, "last_ping_on").await.unwrap(); - - Node { - id: id, - app_node: app_node, - last_token_issue_at: last_token_issue_at, - last_ping_on: last_ping_on, - } -} - -// Update last_ping_on Node by Name -pub async fn update_last_ping_on_node_by_name( - connection: &mut redis::aio::MultiplexedConnection, - app_node: &str, - last_ping_on: &str, -) -> Node { - let hash_key: String = "node_".to_owned() + &app_node; - let _: () = connection - .hset(&hash_key, "last_ping_on", last_ping_on) - .await - .unwrap(); - - let id: String = connection.hget(&hash_key, "id").await.unwrap(); - let app_node: String = connection.hget(&hash_key, "app_node").await.unwrap(); - let last_token_issue_at: String = connection - .hget(&hash_key, "last_token_issue_at") - .await - .unwrap(); - let last_ping_on: String = connection.hget(&hash_key, "last_ping_on").await.unwrap(); - - Node { - id: id, - app_node: app_node, - last_token_issue_at: last_token_issue_at, - last_ping_on: last_ping_on, - } -} - -pub async fn delete_node_by_name( - connection: &mut redis::aio::MultiplexedConnection, - app_node: &str, -) { - let hash_key: String = "node_".to_owned() + &app_node; - let _: () = connection.del(&hash_key).await.unwrap(); -} +} \ No newline at end of file diff --git a/crates/http/src/libs/http.rs b/crates/http/src/libs/http.rs index 0e73c04..f2a0ad9 100644 --- a/crates/http/src/libs/http.rs +++ b/crates/http/src/libs/http.rs @@ -5,14 +5,12 @@ use crate::libs::jwt; use actix_web::{web, App, HttpServer}; use env_logger::Env; use listenfd::ListenFd; -use p256::ecdsa; use tracing_actix_web::TracingLogger; #[derive(Clone)] pub struct AppState { pub redis_client: redis::Client, - pub private_key: ecdsa::SigningKey, - pub public_key: ecdsa::VerifyingKey, + pub private_key: jwtk::ecdsa::EcdsaPrivateKey, } #[actix_web::main] @@ -22,11 +20,10 @@ pub async fn start_web_server() -> std::io::Result<()> { let redis_client: redis::Client = crate::libs::redis::connection_to_redis(&env_config.redis_url).await; - let key_pair = jwt::generate_keys(); + let private_key = jwt::generate_private_key(); let app_state: AppState = AppState { redis_client: redis_client, - private_key: key_pair.0, - public_key: key_pair.1, + private_key: private_key, }; env_logger::init_from_env(Env::default().default_filter_or(env_config.log_level)); diff --git a/crates/http/src/libs/jwt.rs b/crates/http/src/libs/jwt.rs index da7e2a2..571e2e2 100644 --- a/crates/http/src/libs/jwt.rs +++ b/crates/http/src/libs/jwt.rs @@ -1,68 +1,117 @@ use core::str; +use jwtk::{self, PublicKeyToJwk}; +use chrono::Duration; -use min_jwt::encode_and_sign; -use p256::ecdsa; -use serde_json::json; - -#[derive(serde::Deserialize, serde::Serialize)] -pub struct Header { - alg: String, - typ: String, +pub fn generate_private_key() -> jwtk::ecdsa::EcdsaPrivateKey{ + let private_key = jwtk::ecdsa::EcdsaPrivateKey::generate(jwtk::ecdsa::EcdsaAlgorithm::ES512).unwrap(); + private_key } -#[derive(serde::Deserialize, serde::Serialize)] -pub struct Claims { - sub: String, - name: String, - iat: i64, -} +pub fn generate_public_key( + private_key: jwtk::ecdsa::EcdsaPrivateKey +) -> jwtk::ecdsa::EcdsaPublicKey { + let public_key = jwtk::ecdsa::EcdsaPublicKey::from_coordinates( + &private_key.coordinates().unwrap().0, + &private_key.coordinates().unwrap().1, + jwtk::ecdsa::EcdsaAlgorithm::ES512 + ).unwrap(); -pub fn generate_keys() -> (ecdsa::SigningKey, ecdsa::VerifyingKey) { - let private_key = ecdsa::SigningKey::random(&mut rand::thread_rng()); - let public_key = ecdsa::VerifyingKey::from(&private_key); - (private_key, public_key) + public_key } -pub fn generate_jwt(node_id: String, app_node: String, private_key: &ecdsa::SigningKey) -> String { - let binding = serde_json::to_value(json!({ - "alg": "ES256", - "typ": "JWT", - })) - .unwrap() - .to_string(); - - let header = binding.as_bytes(); +pub fn generate_jwks( + private_key: jwtk::ecdsa::EcdsaPrivateKey, +) -> jwtk::jwk::Jwk { + let jwks = private_key.public_key_to_jwk().unwrap(); - let binding = serde_json::to_value(json!({ - "sub": node_id, - "name": app_node, - "iat": chrono::Utc::now().timestamp(), - })) - .unwrap() - .to_string(); - - let claims = binding.as_bytes(); + jwks +} - let jwt = encode_and_sign(header, claims, &private_key).unwrap(); +pub fn generate_jwt(node_id: String, app_node: String, private_key: &jwtk::ecdsa::EcdsaPrivateKey) -> String { + let mut header_and_claims: jwtk::HeaderAndClaims> = jwtk::HeaderAndClaims::new_dynamic(); + header_and_claims.set_sub("m2m-service"); + header_and_claims.set_iss("auth-registry"); + header_and_claims.set_iat_now(); + header_and_claims.set_nbf_from_now(std::time::Duration::from_secs(0)); + header_and_claims.set_exp_from_now(std::time::Duration::from_secs(Duration::days(1).num_seconds() as u64)); + header_and_claims.insert("node_id", node_id); + header_and_claims.insert("app_node", app_node); + + let jwt = jwtk::sign(&mut header_and_claims, private_key).unwrap(); jwt } -pub fn verify_jwt(jwt: &str, public_key: &ecdsa::VerifyingKey) -> bool { - let jwt = match min_jwt::verify(jwt, public_key) { +#[derive(serde::Deserialize, serde::Serialize)] +pub struct VerifyNDecodedResult { + pub success: bool, + pub node_id: Option, + pub app_node: Option, +} + +pub fn verify_jwt(jwt: &str, public_key: jwtk::ecdsa::EcdsaPublicKey) -> VerifyNDecodedResult { + let jwt = match jwtk::verify::>(jwt, &public_key) { Ok(jwt) => jwt, - Err(_) => return false, + Err(_) => return VerifyNDecodedResult { + success: false, + node_id: None, + app_node: None, + }, }; - let header: Vec = jwt.decode_header().unwrap(); - let header = str::from_utf8(&header).unwrap(); - let header: Header = serde_json::from_str(header).unwrap(); - let claims: Vec = jwt.decode_claims().unwrap(); - let claims = str::from_utf8(&claims).unwrap(); - let claims: Claims = serde_json::from_str(claims).unwrap(); + struct ExtraClaims { + app_node: Option, + node_id: Option, + } - if header.alg != "ES256" { - return false; + #[allow(dead_code)] + struct Claims { + sub: Option, + iss: Option, + iat: Option, + nbf: Option, + exp: Option, + aud: Option>, + jti: Option, + extra: ExtraClaims, } - true -} + #[allow(dead_code)] + struct Header { + alg: String, + typ: Option, + kid: Option + } + + let header = jwt.header(); + let claims = jwt.claims(); + + #[allow(unused_variables)] + let header = Header { + alg: header.alg.to_string(), + typ: header.typ.clone().map(|x| x.to_string()), + kid: header.kid.clone().map(|x| x.to_string()) + }; + + let claims = Claims { + sub: claims.sub.clone().map(|x| x.to_string()), + iss: claims.iss.clone().map(|x| x.to_string()), + iat: claims.iat.map(|x| x.as_secs() as i64), + nbf: claims.nbf.map(|x| x.as_secs() as i64), + exp: claims.exp.map(|x| x.as_secs() as i64), + aud: None, + jti: claims.jti.clone().map(|x| x.to_string()), + extra: ExtraClaims { + app_node: claims.extra.get("app_node").map(|x| x.to_string()), + node_id: claims.extra.get("node_id").map(|x| x.to_string()), + } + }; + + let node_id = claims.extra.node_id.clone().map(|x| x.replace("\"", "")); + let app_node = claims.extra.app_node.clone().map(|x| x.replace("\"", "")); + + VerifyNDecodedResult { + success: true, + node_id, + app_node, + } +} \ No newline at end of file diff --git a/crates/http/src/libs/redis.rs b/crates/http/src/libs/redis.rs index 247f9f7..19e6c59 100644 --- a/crates/http/src/libs/redis.rs +++ b/crates/http/src/libs/redis.rs @@ -1,73 +1,4 @@ -use redis::AsyncCommands; - pub async fn connection_to_redis(redis_url: &str) -> redis::Client { let client: redis::Client = redis::Client::open(redis_url).unwrap(); client -} - -pub async fn start_pub_sub_pinger() { - let env_config = crate::config::env::get_env(); - - let redis_client: redis::Client = - crate::libs::redis::connection_to_redis(&env_config.redis_url).await; - - let mut connection = redis_client.clone().get_connection().unwrap(); - let mut pubsub = connection.as_pubsub(); - - pubsub.psubscribe("m2m:auth").unwrap(); - - loop { - let mut redis_multiplex_connection: redis::aio::MultiplexedConnection = redis_client - .get_multiplexed_async_connection() - .await - .unwrap(); - - let all_nodes = crate::libs::db::get_all_nodes(&mut redis_multiplex_connection).await; - - for node in all_nodes.nodes.unwrap() { - let key: String = format!("m2m:auth:{}", &node.app_node); - let _: () = redis_multiplex_connection - .publish(key, "ping") - .await - .unwrap(); - } - - std::thread::sleep(std::time::Duration::from_secs(5)); - } -} - -pub async fn start_pub_sub_attendence_marker() { - let env_config = crate::config::env::get_env(); - - let redis_client: redis::Client = - crate::libs::redis::connection_to_redis(&env_config.redis_url).await; - - let mut connection = redis_client.clone().get_connection().unwrap(); - let mut pubsub = connection.as_pubsub(); - - pubsub.psubscribe("m2m:auth:ping").unwrap(); - - loop { - let msg = pubsub.get_message().unwrap(); - let payload: String = msg.get_payload().unwrap(); - - let payload_parts: Vec<&str> = payload.split(":").collect(); - let node_id: &str = payload_parts[0]; - - let key: String = format!("m2m:auth:{}", &node_id); - - let mut redis_multiplex_connection: redis::aio::MultiplexedConnection = redis_client - .get_multiplexed_async_connection() - .await - .unwrap(); - - let _: () = redis_multiplex_connection - .publish(key, "pong") - .await - .unwrap(); - - println!("Ponged to {}", node_id); - - std::thread::sleep(std::time::Duration::from_secs(5)); - } -} +} \ No newline at end of file