From 7b8e1163a4a2a51fc2bc4404c6608a4d3a572ed4 Mon Sep 17 00:00:00 2001 From: Shankar Singh C <83439957+ShankarSinghC@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:15:17 +0530 Subject: [PATCH 1/2] chore(deps): update axum `0.6.20` to `0.7.3` (#66) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- Cargo.lock | 370 ++++++++++++++++++++++++++++++++-------------- Cargo.toml | 22 +-- src/app.rs | 13 +- src/bin/locker.rs | 6 +- src/bin/utils.rs | 20 ++- src/crypto/jw.rs | 12 +- src/error.rs | 2 + src/middleware.rs | 65 ++++---- 8 files changed, 335 insertions(+), 175 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a118a76..665fa67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,7 +62,7 @@ dependencies = [ "argh_shared", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -76,13 +76,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.74" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -119,8 +119,8 @@ dependencies = [ "bytes", "fastrand", "hex", - "http", - "hyper", + "http 0.2.9", + "hyper 0.14.27", "ring 0.17.5", "time", "tokio", @@ -150,8 +150,8 @@ dependencies = [ "aws-smithy-types", "aws-types", "bytes", - "http", - "http-body", + "http 0.2.9", + "http-body 0.4.5", "pin-project-lite", "tracing", ] @@ -171,7 +171,7 @@ dependencies = [ "aws-smithy-types", "aws-types", "fastrand", - "http", + "http 0.2.9", "percent-encoding", "tracing", "uuid", @@ -194,7 +194,7 @@ dependencies = [ "aws-smithy-types", "aws-types", "bytes", - "http", + "http 0.2.9", "once_cell", "regex-lite", "tracing", @@ -217,7 +217,7 @@ dependencies = [ "aws-smithy-types", "aws-types", "bytes", - "http", + "http 0.2.9", "once_cell", "regex-lite", "tracing", @@ -240,7 +240,7 @@ dependencies = [ "aws-smithy-types", "aws-types", "bytes", - "http", + "http 0.2.9", "once_cell", "regex-lite", "tracing", @@ -264,7 +264,7 @@ dependencies = [ "aws-smithy-types", "aws-smithy-xml", "aws-types", - "http", + "http 0.2.9", "once_cell", "regex-lite", "tracing", @@ -284,7 +284,7 @@ dependencies = [ "form_urlencoded", "hex", "hmac", - "http", + "http 0.2.9", "once_cell", "percent-encoding", "sha2", @@ -314,8 +314,8 @@ dependencies = [ "bytes", "bytes-utils", "futures-core", - "http", - "http-body", + "http 0.2.9", + "http-body 0.4.5", "once_cell", "percent-encoding", "pin-project-lite", @@ -354,10 +354,10 @@ dependencies = [ "aws-smithy-types", "bytes", "fastrand", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.21", + "http 0.2.9", + "http-body 0.4.5", + "hyper 0.14.27", "hyper-rustls", "once_cell", "pin-project-lite", @@ -376,7 +376,7 @@ dependencies = [ "aws-smithy-async", "aws-smithy-types", "bytes", - "http", + "http 0.2.9", "pin-project-lite", "tokio", "tracing", @@ -393,8 +393,8 @@ dependencies = [ "bytes", "bytes-utils", "futures-core", - "http", - "http-body", + "http 0.2.9", + "http-body 0.4.5", "itoa", "num-integer", "pin-project-lite", @@ -425,25 +425,26 @@ dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api", "aws-smithy-types", - "http", + "http 0.2.9", "rustc_version", "tracing", ] [[package]] name = "axum" -version = "0.6.20" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "d09dbe0e490df5da9d69b36dca48a76635288a82f92eca90024883a56202026d" dependencies = [ "async-trait", "axum-core", - "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.1.0", + "hyper-util", "itoa", "matchit", "memchr", @@ -460,30 +461,35 @@ dependencies = [ "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "e87c8503f93e6d144ee5690907ba22db7ba79ab001a932ab99034f0fe836b3df" dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "axum-test" -version = "13.1.1" +version = "14.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e559a1b9b6e81018cd95f2528fc7b333e181191175f34daa9cf3369c7a18fd5" +checksum = "e2d15e9969313df61a64e25ce39cc8e586d42432696a0c8e0cfac1d377013d9c" dependencies = [ "anyhow", "async-trait", @@ -491,9 +497,14 @@ dependencies = [ "axum", "bytes", "cookie", - "http", - "hyper", + "http 1.0.0", + "http-body-util", + "hyper 1.1.0", + "hyper-util", + "mime", + "pretty_assertions", "reserve-port", + "rust-multipart-rfc7578_2", "serde", "serde_json", "serde_urlencoded", @@ -657,9 +668,9 @@ dependencies = [ [[package]] name = "cookie" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24" +checksum = "3cd91cf61412820176e137621345ee43b3f4423e589e7ae4e50d601d93e35ef8" dependencies = [ "time", "version_check", @@ -701,9 +712,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +checksum = "82a9b73a36529d9c47029b9fb3a6f0ea3cc916a261195352ba19e770fc1748b2" dependencies = [ "cfg-if", "crossbeam-utils", @@ -711,9 +722,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c" dependencies = [ "cfg-if", ] @@ -861,7 +872,7 @@ dependencies = [ "diesel_table_macro_syntax", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -870,9 +881,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" dependencies = [ - "syn 2.0.38", + "syn 2.0.48", ] +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + [[package]] name = "digest" version = "0.9.0" @@ -981,9 +998,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -1044,7 +1061,7 @@ checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -1125,7 +1142,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.9", "indexmap 1.9.3", "slab", "tokio", @@ -1133,6 +1150,25 @@ dependencies = [ "tracing", ] +[[package]] +name = "h2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d308f63daf4181410c242d34c11f928dcb3aa105852019e043c9d1f4e4368a" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.0.0", + "indexmap 2.0.2", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -1180,6 +1216,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.5" @@ -1187,15 +1234,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", - "http", + "http 0.2.9", "pin-project-lite", ] [[package]] -name = "http-range-header" -version = "0.3.1" +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.0.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" +dependencies = [ + "bytes", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "pin-project-lite", +] [[package]] name = "httparse" @@ -1219,9 +1283,9 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.21", + "http 0.2.9", + "http-body 0.4.5", "httparse", "httpdate", "itoa", @@ -1233,6 +1297,26 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.0", + "http 1.0.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "tokio", + "want", +] + [[package]] name = "hyper-rustls" version = "0.24.2" @@ -1240,8 +1324,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", - "hyper", + "http 0.2.9", + "hyper 0.14.27", "log", "rustls", "rustls-native-certs", @@ -1249,6 +1333,26 @@ dependencies = [ "tokio-rustls", ] +[[package]] +name = "hyper-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdea9aac0dbe5a9240d68cfd9501e2db94222c6dc06843e06640b9e07f0fdc67" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "hyper 1.1.0", + "pin-project-lite", + "socket2 0.5.5", + "tokio", + "tower", + "tower-service", + "tracing", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1257,9 +1361,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1418,6 +1522,16 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -1531,7 +1645,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -1605,9 +1719,9 @@ checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" @@ -1640,7 +1754,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -1689,7 +1803,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -1760,20 +1874,30 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "pretty_assertions" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +dependencies = [ + "diff", + "yansi", +] + [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -1878,10 +2002,10 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.21", + "http 0.2.9", + "http-body 0.4.5", + "hyper 0.14.27", "hyper-rustls", "ipnet", "js-sys", @@ -1909,9 +2033,9 @@ dependencies = [ [[package]] name = "reserve-port" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b212efd3460286cd590149feedd0afabef08ee352445dd6b4452f0d136098a5f" +checksum = "9838134a2bfaa8e1f40738fcc972ac799de6e0e06b5157acb95fc2b05a0ea283" dependencies = [ "lazy_static", "thiserror", @@ -1973,6 +2097,22 @@ dependencies = [ "ordered-multimap", ] +[[package]] +name = "rust-multipart-rfc7578_2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b748410c0afdef2ebbe3685a6a862e2ee937127cdaae623336a459451c8d57" +dependencies = [ + "bytes", + "futures-core", + "futures-util", + "http 0.2.9", + "mime", + "mime_guess", + "rand", + "thiserror", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -2003,7 +2143,7 @@ dependencies = [ "anyhow", "async-trait", "bytes", - "http", + "http 0.2.9", "reqwest", "rustify_derive", "serde", @@ -2167,7 +2307,7 @@ checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -2250,9 +2390,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "socket2" @@ -2322,9 +2462,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -2391,7 +2531,8 @@ dependencies = [ "futures-util", "gethostname", "hex", - "hyper", + "http-body-util", + "hyper 1.1.0", "josekit", "masking", "once_cell", @@ -2431,7 +2572,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -2490,9 +2631,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ "backtrace", "bytes", @@ -2508,13 +2649,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -2595,17 +2736,16 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "09e12e6351354851911bdf8c2b8f2ab15050c567d70a8b9a37ae7b8301a4080d" dependencies = [ "bitflags 2.4.1", "bytes", - "futures-core", "futures-util", - "http", - "http-body", - "http-range-header", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", "pin-project-lite", "tower-layer", "tower-service", @@ -2638,11 +2778,12 @@ dependencies = [ [[package]] name = "tracing-appender" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" dependencies = [ "crossbeam-channel", + "thiserror", "time", "tracing-subscriber", ] @@ -2655,7 +2796,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] @@ -2670,9 +2811,9 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ "log", "once_cell", @@ -2691,9 +2832,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -2728,6 +2869,15 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.13" @@ -2769,9 +2919,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -2809,7 +2959,7 @@ dependencies = [ "async-trait", "bytes", "derive_builder", - "http", + "http 0.2.9", "reqwest", "rustify", "rustify_derive", @@ -2874,7 +3024,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", "wasm-bindgen-shared", ] @@ -2908,7 +3058,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3058,6 +3208,12 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + [[package]] name = "zeroize" version = "1.6.0" diff --git a/Cargo.toml b/Cargo.toml index f6cb28b..28b9c02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,10 +20,6 @@ aws-config = { version = "1.0.1", optional = true } aws-sdk-kms = { version = "1.3.0", optional = true } base64 = "0.21.2" futures = "0.3.28" -tracing = { version = "0.1.40" } -tracing-appender = { version = "0.2.2" } -tracing-attributes = "0.1.27" -tracing-subscriber = { version = "0.3.17", default-features = true, features = ["env-filter", "json", "registry"] } gethostname = "0.4.3" rustc-hash = "1.1" once_cell = "1.18.0" @@ -31,11 +27,19 @@ vaultrs = { version = "0.7.0", optional = true } # Tokio Dependencies tokio = { version = "1.33.0", features = ["macros", "rt-multi-thread"] } -axum = "0.6.20" -hyper = "0.14.27" +axum = "0.7.3" +hyper = "1.0.1" tower = { version = "0.4.13", features = ["limit", "buffer", "load-shed"] } -tower-http = { version = "0.4.4", features = ["trace"] } - +tower-http = { version = "0.5.0", features = ["trace"] } +tracing = { version = "0.1.40" } +tracing-appender = { version = "0.2.2" } +tracing-attributes = "0.1.27" +tracing-subscriber = { version = "0.3.17", default-features = true, features = [ + "env-filter", + "json", + "registry", +] } +http-body-util = "0.1.0" diesel = { version = "2.1.3", features = ["postgres", "serde_json", "time"] } diesel-async = { version = "0.4.1", features = ["postgres", "deadpool"] } @@ -61,7 +65,7 @@ argh = "0.1.12" [dev-dependencies] rand = "0.8.5" -axum-test = "13.0.1" +axum-test = "14.2.2" [build-dependencies] cargo_metadata = "0.15.4" diff --git a/src/app.rs b/src/app.rs index 02601d0..19b2b9d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,6 +1,5 @@ use axum::routing; use error_stack::ResultExt; -use hyper::server::conn; use masking::PeekInterface; #[cfg(feature = "key_custodian")] use tokio::sync::{mpsc::Sender, RwLock}; @@ -52,7 +51,7 @@ pub async fn server1_builder( state: Arc>, server_tx: Sender<()>, ) -> Result< - hyper::Server>, + axum::serve::Serve, axum::Router>, error::ConfigurationError, > where @@ -71,7 +70,9 @@ where .with_state(shared_state) .route("/health", routing::get(routes::health::health)); - let server = axum::Server::try_bind(&socket_addr)?.serve(router.into_make_service()); + let tcp_listener = tokio::net::TcpListener::bind(&socket_addr).await?; + let server = axum::serve(tcp_listener, router.into_make_service()); + Ok(server) } @@ -82,7 +83,7 @@ where pub async fn server2_builder( state: &AppState, ) -> Result< - hyper::Server>, + axum::serve::Serve, axum::Router>, error::ConfigurationError, > where @@ -121,8 +122,8 @@ where .level(tracing::Level::ERROR), ), ); - - let server = axum::Server::try_bind(&socket_addr)?.serve(router.into_make_service()); + let tcp_listener = tokio::net::TcpListener::bind(&socket_addr).await?; + let server = axum::serve(tcp_listener, router.into_make_service()); Ok(server) } diff --git a/src/bin/locker.rs b/src/bin/locker.rs index 4f460e7..7a43c5e 100644 --- a/src/bin/locker.rs +++ b/src/bin/locker.rs @@ -19,11 +19,11 @@ async fn main() -> Result<(), Box> { { let state_lock = state.clone(); - let (server1_tx, mut server1_rx) = tokio::sync::mpsc::channel::<()>(1); + let (server1_tx, server1_rx) = tokio::sync::mpsc::channel::<()>(1); let server1 = tartarus::app::server1_builder(state_lock, server1_tx.clone()) .await? - .with_graceful_shutdown(graceful_shutdown_server1(&mut server1_rx)); + .with_graceful_shutdown(graceful_shutdown_server1(server1_rx)); logger::info!( "Key Custodian started [{:?}] [{:?}]", @@ -42,7 +42,7 @@ async fn main() -> Result<(), Box> { } #[cfg(feature = "key_custodian")] -async fn graceful_shutdown_server1(recv: &mut tokio::sync::mpsc::Receiver<()>) { +async fn graceful_shutdown_server1(mut recv: tokio::sync::mpsc::Receiver<()>) { recv.recv().await; logger::info!("Shutting down the server1 gracefully."); } diff --git a/src/bin/utils.rs b/src/bin/utils.rs index 6f0e0de..e22c4dc 100644 --- a/src/bin/utils.rs +++ b/src/bin/utils.rs @@ -80,8 +80,13 @@ fn main() -> Result<(), Box> { let pub_key = read_file_to_string( &public_key.ok_or(error::CryptoError::InvalidData("public key not found"))?, )?; - jwe_operation(|x| { - JWEncryption::new(priv_key, pub_key, jwe::RSA_OAEP_256, jwe::RSA_OAEP).encrypt(x) + jwe_operation(|payload| { + JWEncryption::new(priv_key, pub_key, jwe::RSA_OAEP_256, jwe::RSA_OAEP) + .encrypt(payload) + .and_then(|payload| { + Ok(serde_json::to_vec(&payload) + .map_err(error::CryptoError::SerdeJsonError)?) + }) })?; } SubCommand::JweDecrypt(JweD { @@ -94,8 +99,15 @@ fn main() -> Result<(), Box> { let pub_key = read_file_to_string( &public_key.ok_or(error::CryptoError::InvalidData("private key not found"))?, )?; - jwe_operation(|x| { - JWEncryption::new(priv_key, pub_key, jwe::RSA_OAEP_256, jwe::RSA_OAEP).decrypt(x) + jwe_operation(|payload| { + serde_json::from_slice(&payload) + .map_err(error::CryptoError::SerdeJsonError) + .map_err(Into::into) + .and_then(|payload| { + JWEncryption::new(priv_key, pub_key, jwe::RSA_OAEP_256, jwe::RSA_OAEP) + .decrypt(payload) + }) + // (x) })?; } } diff --git a/src/crypto/jw.rs b/src/crypto/jw.rs index 2ed7374..b2509a4 100644 --- a/src/crypto/jw.rs +++ b/src/crypto/jw.rs @@ -90,10 +90,10 @@ impl JweBody { } } -impl super::Encryption, Vec> for JWEncryption { +impl super::Encryption, JweBody> for JWEncryption { type ReturnType<'a, T> = Result>; - fn encrypt(&self, input: Vec) -> Self::ReturnType<'_, Vec> { + fn encrypt(&self, input: Vec) -> Self::ReturnType<'_, JweBody> { let payload = input; let jws_encoded = jws_sign_payload(&payload, self.private_key.peek().as_bytes())?; let jws_body = JwsBody::from_dotted_str(&jws_encoded).ok_or( @@ -107,13 +107,11 @@ impl super::Encryption, Vec> for JWEncryption { )?; let jwe_body = JweBody::from_str(&jwe_encrypted) .ok_or(error::CryptoError::InvalidData("JWE data incomplete"))?; - Ok(serde_json::to_vec(&jwe_body).map_err(error::CryptoError::from)?) + Ok(jwe_body) } - fn decrypt(&self, input: Vec) -> Self::ReturnType<'_, Vec> { - let jwe_body: JweBody = serde_json::from_slice(&input).map_err(error::CryptoError::from)?; - let jwe_encoded = jwe_body.get_dotted_jwe(); - // let algo = jwe::RSA_OAEP_256; + fn decrypt(&self, input: JweBody) -> Self::ReturnType<'_, Vec> { + let jwe_encoded = input.get_dotted_jwe(); let jwe_decrypted = decrypt_jwe(&jwe_encoded, self.private_key.peek(), self.decryption_algo)?; diff --git a/src/error.rs b/src/error.rs index bba9521..6b795f5 100644 --- a/src/error.rs +++ b/src/error.rs @@ -15,6 +15,8 @@ pub enum ConfigurationError { ServerError(#[from] hyper::Error), #[error("invalid host for socket")] AddressError(#[from] std::net::AddrParseError), + #[error("invalid host for socket")] + IOError(#[from] std::io::Error), #[error("Error while connecting/creating database pool")] DatabaseError, #[error("Failed to KMS decrypt: {0}")] diff --git a/src/middleware.rs b/src/middleware.rs index 756626c..7c7f89e 100644 --- a/src/middleware.rs +++ b/src/middleware.rs @@ -1,34 +1,22 @@ use crate::app::AppState; -use crate::crypto::jw::JWEncryption; +use crate::crypto::jw::{self, JWEncryption}; use crate::crypto::Encryption; use crate::error::{self, ContainerError, ResultContainerExt}; -use axum::{ - body::BoxBody, - extract, - http::{Request, Response}, - middleware::Next, -}; -use error_stack::ResultExt; -use hyper::body::HttpBody; -use hyper::Body; +use axum::body::Body; +use axum::http::{request, response}; +use axum::{extract, http::Request, middleware::Next}; + +use http_body_util::BodyExt; use josekit::jwe; /// Middleware providing implementation to perform JWE + JWS encryption and decryption around the /// card APIs pub async fn middleware( extract::State(state): extract::State, - request: Request, - next: Next, -) -> Result, ContainerError> { - let (parts, body) = request.into_parts(); - - let request_body = - hyper::body::to_bytes(body) - .await - .change_error(error::ApiError::RequestMiddlewareError( - "Failed to read request body for jwe decryption", - ))?; - + parts: request::Parts, + axum::Json(jwe_body): axum::Json, + next: Next, +) -> Result<(response::Parts, axum::Json), ContainerError> { let keys = JWEncryption { private_key: state.config.secrets.locker_private_key, public_key: state.config.secrets.tenant_public_key, @@ -36,28 +24,27 @@ pub async fn middleware( decryption_algo: jwe::RSA_OAEP_256, }; - let jwe_decrypted = keys.decrypt(request_body.to_vec())?; + let jwe_decrypted = keys.decrypt(jwe_body)?; let next_layer_payload = Request::from_parts(parts, Body::from(jwe_decrypted)); - let response = next.run(next_layer_payload).await; - - let (parts, body) = response.into_parts(); + let (mut parts, body) = next.run(next_layer_payload).await.into_parts(); - let response_body = hyper::body::to_bytes(body).await.change_error( - error::ApiError::ResponseMiddlewareError("Failed to read response body for jws signing"), - )?; + let response_body = body + .collect() + .await + .change_error(error::ApiError::ResponseMiddlewareError( + "Failed to read response body for jws signing", + ))? + .to_bytes(); - let jws_signed = keys.encrypt(response_body.to_vec())?; + let jwe_payload = keys.encrypt(response_body.to_vec())?; - let jwt = String::from_utf8(jws_signed).change_error( - error::ApiError::ResponseMiddlewareError("Could not convert to UTF-8"), - )?; + parts.headers = hyper::HeaderMap::new(); + parts.headers.append( + hyper::header::CONTENT_TYPE, + axum::http::HeaderValue::from_static("application/json"), + ); - Ok(axum::http::response::Builder::new() - .status(parts.status) - .body(jwt.map_err(axum::Error::new).boxed_unsync()) - .change_context(error::ApiError::ResponseMiddlewareError( - "failed while generating the response", - ))?) + Ok((parts, axum::Json(jwe_payload))) } From 358cdb8d89b594a0f273dd976867879357c19ef3 Mon Sep 17 00:00:00 2001 From: Shankar Singh C <83439957+ShankarSinghC@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:19:30 +0530 Subject: [PATCH 2/2] feat(router): add `duplication_check` field in stored card response(#59) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Nishant Joshi --- src/routes/data.rs | 21 +++++++++++----- src/routes/data/transformers.rs | 43 ++++++++++++++++++++++++++++++--- src/routes/data/types.rs | 14 ++++++++--- 3 files changed, 66 insertions(+), 12 deletions(-) diff --git a/src/routes/data.rs b/src/routes/data.rs index dd5b289..a8f4349 100644 --- a/src/routes/data.rs +++ b/src/routes/data.rs @@ -8,6 +8,8 @@ use axum::middleware; use masking::ExposeInterface; +use types::StoreCardResponse; + use crate::{ app::AppState, crypto::{aes::GcmAes256, sha::Sha512}, @@ -94,7 +96,7 @@ pub async fn add_card( let optional_hash_table = state.db.find_by_data_hash(&hash_data).await?; - let output = match optional_hash_table { + let (duplication_check, output) = match optional_hash_table { Some(hash_table) => { let stored_data = state .db @@ -107,7 +109,10 @@ pub async fn add_card( ) .await?; - match stored_data { + let duplication_check = + transformers::validate_card_metadata(stored_data.as_ref(), &request.data)?; + + let output = match stored_data { Some(data) => data, None => { state @@ -123,12 +128,14 @@ pub async fn add_card( ) .await? } - } + }; + + (duplication_check, output) } None => { let hash_table = state.db.insert_hash(hash_data).await?; - state + let output = state .db .insert_or_get_from_locker( ( @@ -139,11 +146,13 @@ pub async fn add_card( .try_into()?, &merchant_dek, ) - .await? + .await?; + + (None, output) } }; - Ok(Json(output.into())) + Ok(Json(StoreCardResponse::from((duplication_check, output)))) } /// `/data/delete` handling the requirement of deleting cards diff --git a/src/routes/data/transformers.rs b/src/routes/data/transformers.rs index 8584e41..976f9c2 100644 --- a/src/routes/data/transformers.rs +++ b/src/routes/data/transformers.rs @@ -6,7 +6,7 @@ use crate::{ storage, }; -use super::types; +use super::types::{self, DataDuplicationCheck}; impl<'a> TryFrom<(super::types::StoreCardRequest, &'a str, &'a str)> for storage::types::LockerNew<'a> @@ -38,12 +38,17 @@ impl<'a> TryFrom<(super::types::StoreCardRequest, &'a str, &'a str)> } } -impl From for super::types::StoreCardResponse { - fn from(value: storage::types::Locker) -> Self { +impl From<(Option, storage::types::Locker)> + for super::types::StoreCardResponse +{ + fn from( + (duplication_check, value): (Option, storage::types::Locker), + ) -> Self { Self { status: types::Status::Ok, payload: Some(super::types::StoreCardRespPayload { card_reference: value.locker_id.expose(), + duplication_check, dedup: None, }), } @@ -71,6 +76,18 @@ impl TryFrom for super::types::RetrieveCardResponse { } } +impl std::cmp::PartialEq for super::types::StoredData { + fn eq(&self, other: &types::Data) -> bool { + match (self, other) { + (Self::EncData(request_enc_card_data), types::Data::EncData { enc_card_data }) => { + request_enc_card_data == enc_card_data + } + (Self::CardData(request_card), types::Data::Card { card }) => request_card == card, + _ => false, + } + } +} + /// Generate UUID v4 as strings to be used in storage layer pub fn generate_uuid() -> String { uuid::Uuid::new_v4().to_string() @@ -98,3 +115,23 @@ where Ok(hash_data) } + +pub fn validate_card_metadata( + stored_payload: Option<&storage::types::Locker>, + request_data: &types::Data, +) -> Result, ContainerError> { + stored_payload + .map(|stored_data| { + let stored_data = + serde_json::from_slice::(stored_data.enc_data.peek()) + .change_error(error::ApiError::DecodingError)?; + + let is_metadata_duplicated = stored_data.eq(request_data); + + Ok(match is_metadata_duplicated { + true => DataDuplicationCheck::Duplicated, + false => DataDuplicationCheck::MetaDataChanged, + }) + }) + .transpose() +} diff --git a/src/routes/data/types.rs b/src/routes/data/types.rs index 329b28d..9d06643 100644 --- a/src/routes/data/types.rs +++ b/src/routes/data/types.rs @@ -11,7 +11,7 @@ use masking::PeekInterface; use crate::error; -#[derive(serde::Serialize, serde::Deserialize, Debug)] +#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Eq)] pub struct Card { pub card_number: masking::StrongSecret, name_on_card: Option, @@ -25,9 +25,17 @@ pub struct Card { #[derive(serde::Serialize, serde::Deserialize, Debug)] pub struct StoreCardRespPayload { pub card_reference: String, + pub duplication_check: Option, pub dedup: Option, } +#[derive(serde::Serialize, serde::Deserialize, Debug)] +#[serde(rename_all = "snake_case")] +pub enum DataDuplicationCheck { + Duplicated, + MetaDataChanged, +} + #[derive(serde::Serialize, serde::Deserialize, Debug)] pub struct DedupResponsePayload { hash1_reference: Option, @@ -48,7 +56,7 @@ pub struct StoreCardRequest { pub data: Data, } -#[derive(serde::Serialize, serde::Deserialize, Debug)] +#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq)] #[serde(untagged)] pub enum Data { EncData { enc_card_data: String }, @@ -94,7 +102,7 @@ pub struct DeleteCardResponse { pub status: Status, } -#[derive(serde::Serialize, serde::Deserialize)] +#[derive(serde::Serialize, serde::Deserialize, PartialEq, Eq)] pub enum StoredData { EncData(String), CardData(Card),