diff --git a/.github/workflows/example_docker_image_gen.yaml b/.github/workflows/example_docker_image_gen.yaml index db46b28c..287b6320 100644 --- a/.github/workflows/example_docker_image_gen.yaml +++ b/.github/workflows/example_docker_image_gen.yaml @@ -13,6 +13,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: + ref: "demo" fetch-depth: 0 token: ${{ secrets.SUPERPOSITION_TOKEN }} @@ -40,6 +41,6 @@ jobs: with: push: true context: . - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 file: ./example.Dockerfile - tags: ghcr.io/juspay/superposition-demo-app:latest, ghcr.io/juspay/superposition-demo-app:${{ steps.git_tag.outputs.docker_tag }}, datron1/superposition-demo-app:${{ steps.git_tag.outputs.docker_tag }}, datron1/superposition-demo-app:latest + tags: datron1/superposition-demo-app:demo-${{ steps.git_tag.outputs.docker_tag }} diff --git a/Cargo.lock b/Cargo.lock index f4b58583..b119dc79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,7 +54,7 @@ dependencies = [ "actix-utils", "ahash", "base64 0.21.2", - "bitflags 2.3.1", + "bitflags 2.6.0", "brotli", "bytes", "bytestring", @@ -384,7 +384,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -395,7 +395,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -409,7 +409,7 @@ dependencies = [ "manyhow", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -425,7 +425,7 @@ dependencies = [ "proc-macro2", "quote", "quote-use", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -848,6 +848,29 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags 2.6.0", + "cexpr", + "clang-sys", + "itertools 0.10.5", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.58", + "which", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -871,9 +894,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6776fc96284a0bb647b615056fc496d1fe1644a7ab01829818a6d91cae888b84" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "blake3" @@ -1022,7 +1045,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c878c71c2821aa2058722038a59a67583a4240524687c6028571c9b395ded61f" dependencies = [ - "darling", + "darling 0.14.4", "proc-macro2", "quote", "syn 1.0.109", @@ -1094,6 +1117,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -1142,6 +1174,17 @@ dependencies = [ "half", ] +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "3.2.25" @@ -1152,7 +1195,7 @@ dependencies = [ "bitflags 1.3.2", "clap_lex 0.2.4", "indexmap 1.9.3", - "strsim", + "strsim 0.10.0", "termcolor", "textwrap", ] @@ -1178,7 +1221,7 @@ dependencies = [ "anstyle", "bitflags 1.3.2", "clap_lex 0.5.0", - "strsim", + "strsim 0.10.0", ] [[package]] @@ -1190,7 +1233,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -1441,7 +1484,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -1458,7 +1501,7 @@ checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -1467,8 +1510,18 @@ version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" dependencies = [ - "darling_core", - "darling_macro", + "darling_core 0.14.4", + "darling_macro 0.14.4", +] + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core 0.20.10", + "darling_macro 0.20.10", ] [[package]] @@ -1481,21 +1534,46 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] +[[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 0.11.1", + "syn 2.0.58", +] + [[package]] name = "darling_macro" version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ - "darling_core", + "darling_core 0.14.4", "quote", "syn 1.0.109", ] +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core 0.20.10", + "quote", + "syn 2.0.58", +] + [[package]] name = "dashmap" version = "5.4.0" @@ -1509,6 +1587,12 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + [[package]] name = "derive-where" version = "1.2.5" @@ -1517,7 +1601,38 @@ checksum = "146398d62142a0f35248a608f17edf0dde57338354966d6e41d0eb2d16980ccb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", +] + +[[package]] +name = "derive_builder" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" +dependencies = [ + "darling 0.20.10", + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" +dependencies = [ + "derive_builder_core", + "syn 2.0.58", ] [[package]] @@ -1540,7 +1655,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7a532c1f99a0f596f6960a60d1e119e91582b24b39e2d83a190e61262c3ef0c" dependencies = [ "bigdecimal", - "bitflags 2.3.1", + "bitflags 2.6.0", "byteorder", "chrono", "diesel_derives", @@ -1575,7 +1690,7 @@ dependencies = [ "diesel_table_macro_syntax", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -1584,7 +1699,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" dependencies = [ - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -1598,6 +1713,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "dotenv" version = "0.15.0" @@ -1846,7 +1972,7 @@ checksum = "1458c6e22d36d61507034d5afecc64f105c1d39712b7ac6ec3b352c423f715cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -1893,9 +2019,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1903,9 +2029,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" @@ -1920,38 +2046,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -2126,6 +2252,15 @@ dependencies = [ "digest", ] +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "html-escape" version = "0.2.13" @@ -2292,6 +2427,124 @@ dependencies = [ "cxx-build", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -2300,12 +2553,23 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -2380,7 +2644,7 @@ checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.9", "io-lifetimes", - "rustix", + "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -2475,6 +2739,21 @@ dependencies = [ "uuid", ] +[[package]] +name = "jsonwebtoken" +version = "9.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ae10193d25051e74945f1ea2d0b42e03cc3b890f7e4cc5faa44997d808193f" +dependencies = [ + "base64 0.21.2", + "js-sys", + "pem", + "ring 0.17.8", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "language-tags" version = "0.3.2" @@ -2487,6 +2766,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "leptos" version = "0.6.11" @@ -2586,7 +2871,7 @@ dependencies = [ "quote", "rstml", "serde", - "syn 2.0.48", + "syn 2.0.58", "walkdir", ] @@ -2622,7 +2907,7 @@ dependencies = [ "quote", "rstml", "server_fn_macro", - "syn 2.0.48", + "syn 2.0.58", "tracing", "uuid", ] @@ -2722,6 +3007,27 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +[[package]] +name = "libloading" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +dependencies = [ + "cfg-if", + "windows-targets 0.52.0", +] + +[[package]] +name = "libxml" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fe73cdec2bcb36d25a9fe3f607ffcd44bb8907ca0100c4098d1aa342d1e7bec" +dependencies = [ + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linear-map" version = "1.2.0" @@ -2747,6 +3053,18 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + [[package]] name = "local-channel" version = "0.1.3" @@ -2803,7 +3121,7 @@ dependencies = [ "manyhow-macros", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -3071,7 +3389,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -3145,6 +3463,16 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +[[package]] +name = "pem" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" +dependencies = [ + "base64 0.22.1", + "serde", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -3182,7 +3510,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -3213,7 +3541,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -3256,7 +3584,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -3310,7 +3638,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", "version_check", "yansi", ] @@ -3321,11 +3649,21 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b" dependencies = [ - "bitflags 2.3.1", + "bitflags 2.6.0", "memchr", "unicase", ] +[[package]] +name = "quick-xml" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca7dd09b5f4a9029c35e323b086d0a68acdc673317b9c4d002c6f1d4a7278c6" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "quote" version = "1.0.35" @@ -3355,7 +3693,7 @@ dependencies = [ "proc-macro-utils", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -3548,7 +3886,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.48", + "syn 2.0.58", "syn_derive", "thiserror", ] @@ -3584,7 +3922,20 @@ dependencies = [ "errno", "io-lifetimes", "libc", - "linux-raw-sys", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustix" +version = "0.38.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys 0.4.14", "windows-sys 0.48.0", ] @@ -3643,6 +3994,33 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +[[package]] +name = "samael" +version = "0.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c3e9664150c82db0eba06db746594e1e8e092c5c91986ee0fe46c0619fb159f" +dependencies = [ + "base64 0.22.1", + "bindgen", + "chrono", + "data-encoding", + "derive_builder", + "flate2", + "lazy_static", + "libc", + "libxml", + "openssl", + "openssl-probe", + "openssl-sys", + "pkg-config", + "quick-xml", + "rand", + "serde", + "thiserror", + "url", + "uuid", +] + [[package]] name = "same-file" version = "1.0.6" @@ -3767,7 +4145,7 @@ checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -3872,7 +4250,7 @@ dependencies = [ "convert_case 0.6.0", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", "xxhash-rust", ] @@ -3883,7 +4261,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4ad11700cbccdbd313703916eb8c97301ee423c4a06e5421b77956fdcb36a9f" dependencies = [ "server_fn_macro", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -3935,6 +4313,12 @@ dependencies = [ "digest", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -3944,6 +4328,18 @@ dependencies = [ "libc", ] +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time", +] + [[package]] name = "skeptic" version = "0.13.7" @@ -3980,9 +4376,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" @@ -4016,12 +4412,24 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "strum" version = "0.25.0" @@ -4038,7 +4446,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -4061,14 +4469,19 @@ dependencies = [ "experimentation_platform", "fred", "frontend", + "futures-util", + "jsonwebtoken", "leptos", "leptos_actix", "reqwest", "rs-snowflake", + "samael", + "serde", "serde_json", "service_utils", "superposition_types", "toml 0.8.8", + "url", ] [[package]] @@ -4088,7 +4501,7 @@ version = "0.1.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -4197,9 +4610,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -4215,7 +4628,18 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", ] [[package]] @@ -4234,7 +4658,7 @@ dependencies = [ "cfg-if", "fastrand 1.9.0", "redox_syscall 0.3.5", - "rustix", + "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -4270,7 +4694,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -4300,6 +4724,16 @@ dependencies = [ "time-core", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -4341,7 +4775,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -4460,7 +4894,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -4501,7 +4935,7 @@ checksum = "563b3b88238ec95680aef36bdece66896eaa7ce3c0f1b4f39d38fb2435261352" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", ] [[package]] @@ -4525,12 +4959,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "unicode-bidi" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" - [[package]] name = "unicode-ident" version = "1.0.8" @@ -4578,9 +5006,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -4593,12 +5021,24 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + [[package]] name = "utf8-width" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.1" @@ -4716,7 +5156,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -4750,7 +5190,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4784,6 +5224,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix 0.38.25", +] + [[package]] name = "winapi" version = "0.3.9" @@ -5056,6 +5508,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "xmlparser" version = "0.13.6" @@ -5074,12 +5538,79 @@ version = "1.0.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", + "synstructure", +] + [[package]] name = "zeroize" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "zstd" version = "0.13.0" diff --git a/Cargo.toml b/Cargo.toml index 3e216cf5..99a4fea2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ members = [ "examples/cac_client_integration_example", "examples/superposition-demo-app", "crates/superposition_macros", - "crates/superposition_derives", + "crates/superposition_derives" ] [[workspace.metadata.leptos]] diff --git a/crates/superposition/Cargo.toml b/crates/superposition/Cargo.toml index 2481c6d2..e49d34ce 100644 --- a/crates/superposition/Cargo.toml +++ b/crates/superposition/Cargo.toml @@ -16,14 +16,19 @@ env_logger = "0.8" experimentation_platform = { path = "../experimentation_platform" } fred = { workspace = true, optional = true } frontend = { path = "../frontend" } +futures-util = "0.3.31" +jsonwebtoken = "9.3.0" leptos = { workspace = true } leptos_actix = { version = "0.6.11" } reqwest = { workspace = true } rs-snowflake = { workspace = true } -serde_json = { workspace = true } +samael = { version = "0.0.17", features = ["xmlsec"] } +serde.workspace = true +serde_json.workspace = true service_utils = { path = "../service_utils" } superposition_types = { path = "../superposition_types" } toml = { workspace = true } +url = "2.5.4" [features] high-performance-mode = [ diff --git a/crates/superposition/src/auth/mod.rs b/crates/superposition/src/auth/mod.rs new file mode 100644 index 00000000..24ac381f --- /dev/null +++ b/crates/superposition/src/auth/mod.rs @@ -0,0 +1,45 @@ +use samael::{ + metadata::{ContactPerson, ContactType, EntityDescriptor}, + service_provider::ServiceProviderBuilder, +}; +use std::{env, fs}; +use url::Url; + +mod saml2; + +pub fn init_auth() -> saml2::SAMLAuthProvider { + let var = env::var("AUTH_PROVIDER") + .ok() + .expect("Env 'AUTH_PROVIDER' not declared, unable to initalize auth provider."); + let mut auth = var.split('+'); + assert_eq!(auth.next(), Some("SAML2")); + let idp_url = auth + .next() + .ok_or(String::from("URL not set in auth env.")) + .and_then(|u| Url::parse(u).map_err(|e| e.to_string())) + .unwrap(); + let md_xml = fs::read_to_string("saml-idp-meta.xml").unwrap(); + let md: EntityDescriptor = samael::metadata::de::from_str(md_xml.as_str()).unwrap(); + let sp = ServiceProviderBuilder::default() + .entity_id("test-saml-sso-app".to_string()) + .idp_metadata(md) + .allow_idp_initiated(true) + .contact_person(ContactPerson { + contact_type: Some(ContactType::Technical.value().to_string()), + sur_name: Some("Doe".to_string()), + ..ContactPerson::default() + }) + .acs_url("https://test.devspaceworks.net/saml/acs".to_string()) + .slo_url("/saml/slo".to_string()) + .build() + .unwrap(); + saml2::SAMLAuthProvider { + metadata: sp.metadata().unwrap(), + idp_url: idp_url, + service_provider: sp, + jwt_key_pair: ( + jsonwebtoken::EncodingKey::from_secret("secret".as_ref()), + jsonwebtoken::DecodingKey::from_secret("secret".as_ref()), + ), + } +} diff --git a/crates/superposition/src/auth/saml2.rs b/crates/superposition/src/auth/saml2.rs new file mode 100644 index 00000000..17537b40 --- /dev/null +++ b/crates/superposition/src/auth/saml2.rs @@ -0,0 +1,206 @@ +use actix_web::{ + body::{BoxBody, EitherBody}, + cookie::{time::Duration, Cookie}, + dev::{forward_ready, Service, ServiceRequest, ServiceResponse, Transform}, + error::InternalError, + get, + http::{ + header::{self, ContentType}, + StatusCode, + }, + post, + web::{self, Data}, + Error, HttpResponse, Responder, Scope, +}; +use futures_util::future::LocalBoxFuture; +use jsonwebtoken::{ + decode, Algorithm, DecodingKey, EncodingKey, Header, TokenData, Validation, +}; +use samael::{ + attribute::Attribute, metadata::EntityDescriptor, schema::AttributeStatement, + service_provider::ServiceProvider, traits::ToXml, +}; +use serde::{Deserialize, Serialize}; +use std::{ + collections::{HashMap, HashSet}, + future::{ready, Ready}, +}; +use url::Url; + +#[derive(Clone)] +pub struct SAMLAuthProvider { + pub service_provider: ServiceProvider, + pub idp_url: Url, + pub metadata: EntityDescriptor, + pub jwt_key_pair: (EncodingKey, DecodingKey), +} + +#[derive(Clone, Serialize, Deserialize)] +struct User { + first_name: String, + last_name: String, + email: String, +} + +impl SAMLAuthProvider { + fn authentication_request(&self, relay: &str) -> Result { + let areq = self + .service_provider + .make_authentication_request(self.idp_url.as_str()); + match areq.and_then(|ar| ar.redirect(relay)) { + Ok(url) => url.ok_or(String::from("DUDE WHERE IS MY REDIRECT???")), + Err(e) => Err(e.to_string()), + } + } + + pub fn routes(&self) -> Scope { + web::scope("saml") + .app_data(Data::new(self.to_owned())) + .service(assertion_consumer_service) + .service(metadata) + } + + fn decode_jwt(&self, cookie: &str) -> Option> { + let dkey = &self.jwt_key_pair.1; + let mut vds = Validation::new(Algorithm::HS256); + vds.validate_exp = false; + vds.required_spec_claims = HashSet::new(); + let result = decode::(cookie, dkey, &vds); + match result { + Ok(td) => Some(td), + Err(e) => { + eprintln!("Failed to decode jwt: {}", e); + None + } + } + } +} + +pub struct SAMLMiddleware { + service: S, + auth_provider: SAMLAuthProvider, +} + +impl Service for SAMLMiddleware +where + S: Service, Error = Error>, + S::Future: 'static, +{ + type Response = ServiceResponse>; + type Error = Error; + type Future = LocalBoxFuture<'static, Result>; + + // Generate polling fn. + forward_ready!(service); + + fn call(&self, req: ServiceRequest) -> Self::Future { + let td = req + .cookie("user") + .and_then(|c| self.auth_provider.decode_jwt(c.value())); + let exp = req.path().matches("saml/acs").count() > 0 + || req.path().matches("health").count() > 0 + || req.path().matches("ready").count() > 0; + if td.is_some() || exp { + let fut = self.service.call(req); + Box::pin(async move { fut.await.map(|sr| sr.map_into_left_body()) }) + } else { + // TODO Add query params to relay. + match self.auth_provider.authentication_request(req.path()) { + Ok(redirect) => Box::pin(async move { + let resp = HttpResponse::Found() + .insert_header((header::LOCATION, redirect.to_string())) + .finish() + .map_into_right_body(); + Ok(ServiceResponse::new(req.request().clone(), resp)) + }), + Err(e) => Box::pin(async move { + Err(InternalError::new(e, StatusCode::INTERNAL_SERVER_ERROR).into()) + }), + } + } + } +} + +impl Transform for SAMLAuthProvider +where + S: Service, Error = Error>, + S::Future: 'static, +{ + type Response = ServiceResponse>; + type Error = Error; + type InitError = (); + type Transform = SAMLMiddleware; + type Future = Ready>; + + fn new_transform(&self, service: S) -> Self::Future { + ready(Ok(SAMLMiddleware { + service, + auth_provider: self.to_owned(), + })) + } +} + +#[get("/metadata")] +async fn metadata(ctx: web::Data) -> impl Responder { + HttpResponse::Ok() + .content_type(ContentType::xml()) + .body(ctx.metadata.to_string().unwrap()) +} + +fn try_into_pair(attribute: Attribute) -> Option<(String, String)> { + match ( + attribute.name, + attribute.values.first().and_then(|v| v.value.clone()), + ) { + (Some(n), Some(v)) => Some((n, v)), + _ => None, + } +} + +fn simplify_attribute_statments( + attribute_statements: Vec, +) -> HashMap { + attribute_statements + .into_iter() + .map(|ast| ast.attributes.into_iter()) + .flatten() + .map(try_into_pair) + .filter_map(|x| x) + .collect() +} + +#[post("/acs")] +async fn assertion_consumer_service( + auth_provider: web::Data, + form: web::Form>, +) -> impl Responder { + let sr_b64 = form + .get("SAMLResponse") + .expect("No SAMLResponse found in body."); + let asrn = auth_provider + .service_provider + .parse_base64_response(sr_b64, None) + .unwrap(); + let attrs = asrn + .attribute_statements + .map(simplify_attribute_statments) + .unwrap_or_default(); + let data = User { + first_name: attrs.get("first_name").unwrap().to_string(), + last_name: attrs.get("last_name").unwrap().to_string(), + email: attrs.get("email").unwrap().to_string(), + }; + let jwt = + jsonwebtoken::encode(&Header::default(), &data, &auth_provider.jwt_key_pair.0) + .unwrap(); + let cookie = Cookie::build("user", jwt) + .path("/") + .http_only(true) + .max_age(Duration::days(1)) + .finish(); + let redirect = form.get("RelayState").map(|r| r.as_str()).unwrap_or("/"); + HttpResponse::Found() + .cookie(cookie) + .insert_header(("Location", redirect)) + .finish() +} diff --git a/crates/superposition/src/main.rs b/crates/superposition/src/main.rs index 649fe4e3..997366f7 100644 --- a/crates/superposition/src/main.rs +++ b/crates/superposition/src/main.rs @@ -1,15 +1,14 @@ #![deny(unused_crate_dependencies)] mod app_state; +mod auth; use std::{collections::HashSet, io::Result, time::Duration}; use actix_files::Files; use actix_web::{ - dev::Service, - http::header, middleware::Compress, web::{self, get, scope, Data, PathConfig}, - App, HttpMessage, HttpResponse, HttpServer, + App, HttpResponse, HttpServer, }; use context_aware_config::api::*; use experimentation_platform::api::*; @@ -19,12 +18,8 @@ use leptos::*; use leptos_actix::{generate_route_list, LeptosRoutes}; use service_utils::{ helpers::get_from_env_unsafe, - middlewares::{ - app_scope::AppExecutionScopeMiddlewareFactory, tenant::TenantMiddlewareFactory, - }, - service::types::{AppScope, AppState}, + middlewares::app_scope::AppExecutionScopeMiddlewareFactory, service::types::AppScope, }; -use superposition_types::User; #[actix_web::get("favicon.ico")] async fn favicon( @@ -92,30 +87,33 @@ async fn main() -> Result<()> { let app_state = Data::new(app_state::get(service_prefix_str.to_owned(), &base, &tenants).await); + let auth = auth::init_auth(); + HttpServer::new(move || { let leptos_options = &conf.leptos_options; let site_root = &leptos_options.site_root; let leptos_envs = ui_envs.clone(); App::new() .wrap(Compress::default()) + .wrap(auth.to_owned()) .app_data(app_state.clone()) - .wrap_fn(|req, srv| { - let state = req.app_data::>().unwrap(); - let user = req.headers().get(header::AUTHORIZATION).and_then(|auth| auth.to_str().ok()).and_then(|auth| { - let mut token = auth.split(' ').into_iter(); - match (token.next(), token.next()) { - (Some("Internal"), Some(token)) if token == state.superposition_token => - req.headers().get("x-user").and_then(|auth| auth.to_str().ok()).and_then(|user_str| { - serde_json::from_str::(user_str).ok() - }), - (_, _) => None - } - }).unwrap_or_default(); - - req.extensions_mut().insert::(user); - srv.call(req) - }) - .wrap(TenantMiddlewareFactory) + // .wrap_fn(|req, srv| { + // let state = req.app_data::>().unwrap(); + // let user = req.headers().get(header::AUTHORIZATION).and_then(|auth| auth.to_str().ok()).and_then(|auth| { + // let mut token = auth.split(' ').into_iter(); + // match (token.next(), token.next()) { + // (Some("Internal"), Some(token)) if token == state.superposition_token => + // req.headers().get("x-user").and_then(|auth| auth.to_str().ok()).and_then(|user_str| { + // serde_json::from_str::(user_str).ok() + // }), + // (_, _) => None + // } + // }).unwrap_or_default(); + + // req.extensions_mut().insert::(user); + // srv.call(req) + // }) + // .wrap(TenantMiddlewareFactory) .app_data(PathConfig::default().error_handler(|err, _| { actix_web::error::ErrorBadRequest(err) })) @@ -124,6 +122,7 @@ async fn main() -> Result<()> { .add(("X-SERVER-VERSION", app_state.cac_version.to_string())) .add(("Cache-Control", "no-store".to_string())) ) + .service(auth.routes()) .service(web::redirect("/", ui_redirect_path.to_string())) .service(web::redirect("/admin", ui_redirect_path.to_string())) .service(web::redirect("/admin/{tenant}/", "default-config")) diff --git a/example.Dockerfile b/example.Dockerfile index 86dd4190..efdf0ce6 100644 --- a/example.Dockerfile +++ b/example.Dockerfile @@ -37,6 +37,7 @@ RUN cp .env.example target/.env RUN mkdir -p target/web RUN cp -a examples/superposition-demo-app/web/. target/web/ # building backend +RUN apt-get install -y libxmlsec1-dev libxml2 RUN cargo build --release FROM debian:bookworm-slim as runtime diff --git a/flake.nix b/flake.nix index 186044be..7cfc8326 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,8 @@ rust-flake.url = "github:juspay/rust-flake"; }; - outputs = inputs: + outputs = + inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } { systems = import inputs.systems; @@ -24,33 +25,57 @@ ./nix/om.nix ]; - perSystem = { pkgs, self', config, ... }: { - formatter = pkgs.nixpkgs-fmt; - devShells.default = pkgs.mkShell { - inputsFrom = [ - self'.devShells.rust - self'.devShells.haskell - config.pre-commit.devShell - ]; - # Add your devShell tools here - packages = with pkgs; [ - docker-compose - gnumake - # Why do we need this? - stdenv.cc - awscli2 - jq - nodejs_18 - nixpkgs-fmt - bacon - cargo-watch - diesel-cli - leptosfmt - wasm-pack - # go client - # go - ]; + perSystem = + { + pkgs, + self', + config, + ... + }: + { + formatter = pkgs.nixpkgs-fmt; + devShells.default = pkgs.mkShell { + inputsFrom = [ + self'.devShells.rust + # self'.devShells.haskell + config.pre-commit.devShell + ]; + # Add your devShell tools here + packages = with pkgs; [ + docker-compose + gnumake + # Why do we need this? + stdenv.cc + awscli2 + jq + nodejs_18 + nixpkgs-fmt + bacon + cargo-watch + diesel-cli + leptosfmt + wasm-pack + llvmPackages.libclang + xmlsec + libtool + # go client + # go + ]; + # Set C flags for Rust's bindgen program. Unlike ordinary C + # compilation, bindgen does not invoke $CC directly. Instead it + # uses LLVM's libclang. To make sure all necessary flags are + # included we need to look in a few places. + shellHook = with pkgs; '' + export LIBCLANG_PATH="${llvmPackages.libclang.lib}/lib"; + export BINDGEN_EXTRA_CLANG_ARGS="$(< ${stdenv.cc}/nix-support/libc-crt1-cflags) \ + $(< ${stdenv.cc}/nix-support/libc-cflags) \ + $(< ${stdenv.cc}/nix-support/cc-cflags) \ + $(< ${stdenv.cc}/nix-support/libcxx-cxxflags) \ + ${lib.optionalString stdenv.cc.isClang "-idirafter ${stdenv.cc.cc}/lib/clang/${lib.getVersion stdenv.cc.cc}/include"} \ + ${lib.optionalString stdenv.cc.isGNU "-isystem ${stdenv.cc.cc}/include/c++/${lib.getVersion stdenv.cc.cc} -isystem ${stdenv.cc.cc}/include/c++/${lib.getVersion stdenv.cc.cc}/${stdenv.hostPlatform.config} -idirafter ${stdenv.cc.cc}/lib/gcc/${stdenv.hostPlatform.config}/${lib.getVersion stdenv.cc.cc}/include"} \ + " + ''; + }; }; - }; }; } diff --git a/nix/rust.nix b/nix/rust.nix index c31b32b6..c8336cfb 100644 --- a/nix/rust.nix +++ b/nix/rust.nix @@ -96,6 +96,8 @@ pkgs.libiconv pkgs.openssl pkgs.postgresql_12 + pkgs.libxml2 + pkgs.xmlsec ]; nativeBuildInputs = with pkgs; [ pkg-config diff --git a/saml-idp-meta.xml b/saml-idp-meta.xml new file mode 100644 index 00000000..0559fa6a --- /dev/null +++ b/saml-idp-meta.xml @@ -0,0 +1,29 @@ + + + + + + MIIDdDCCAlygAwIBAgIGAZNiSFkTMA0GCSqGSIb3DQEBCwUAMHsxFDASBgNVBAoTC0dvb2dsZSBJ +bmMuMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MQ8wDQYDVQQDEwZHb29nbGUxGDAWBgNVBAsTD0dv +b2dsZSBGb3IgV29yazELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWEwHhcNMjQxMTI1 +MDc0NTI4WhcNMjkxMTI0MDc0NTI4WjB7MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEWMBQGA1UEBxMN +TW91bnRhaW4gVmlldzEPMA0GA1UEAxMGR29vZ2xlMRgwFgYDVQQLEw9Hb29nbGUgRm9yIFdvcmsx +CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A +MIIBCgKCAQEAhXkSiXeyp6/jv76hyle1M392CqRO34IbLf0w/nouGnsdMkP+W2c56uJ4Z32U0wS0 +7DDd3UHV1Lzyz0cLyH/mrF2KcjGYhM8XCRpvy7NLrLs6NjZMy/90iU0p2qGybe1xnPpIu9mivckT +JgnzHhDMhr0ya2WaCiiPAiH0gTUXY5tfE9jSntbdATxr11pz0AJMO3poP8rsToY2vmOReLggFSXW +NvnlQgIFHyvbyzZe7CigNywPYyvW9kWYIoimyZW3dmt3Uk68PY0EXQ2WTeYco3f+yHA2vDXV/0ng +iq9ZDHtFZH0QK218CvkPq58f56AYlgRy8KCbJQrCSGUIKq8dMwIDAQABMA0GCSqGSIb3DQEBCwUA +A4IBAQAi2Hm0ypM+Ao/Q09fAaJJoA6KXgiP/kgsl1yU7MKLOTvVondB0rIm+QCQTOUVArgIFf31Y +sX0tUk2wQadqIZysb3LKyoxaLXr/Xo9adbLsUsgge20CHCybTPpOkHDrWJIT8q9H4sLRCgYzXawn +ZUeasy3K7p7oqvd+J865TI0lI5eUClMWP3Bi9s7XJeDpr5yPeU+7p75otguqKDuK2HH1cadYa3Kn +yvQ/aiT164oCCj60WMGKNhpbwB3CQ8LvQE65822Ati54hGsYSdp4oKWrpzPixEV0TUiVq+cxCp4c +UbAScGjfpqH+5XWyENvTXAR8Mz816Bt5OSusgqZsu0zW + + + + urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress + + + +