From 7ac0109df3b014695917360f348396cd8f2cf56c Mon Sep 17 00:00:00 2001 From: Doni Crosby Date: Fri, 2 May 2025 20:36:03 -0400 Subject: [PATCH 1/7] feat: init mqtt-auth server --- nhmesh-mqtt-auth/.gitignore | 1 + nhmesh-mqtt-auth/Cargo.lock | 1532 +++++++++++++++++++++++++ nhmesh-mqtt-auth/Cargo.toml | 16 + nhmesh-mqtt-auth/src/lib.rs | 15 + nhmesh-mqtt-auth/src/main.rs | 8 + nhmesh-mqtt-auth/src/mqtt/mod.rs | 0 nhmesh-mqtt-auth/src/routes/health.rs | 5 + nhmesh-mqtt-auth/src/routes/mod.rs | 3 + 8 files changed, 1580 insertions(+) create mode 100644 nhmesh-mqtt-auth/.gitignore create mode 100644 nhmesh-mqtt-auth/Cargo.lock create mode 100644 nhmesh-mqtt-auth/Cargo.toml create mode 100644 nhmesh-mqtt-auth/src/lib.rs create mode 100644 nhmesh-mqtt-auth/src/main.rs create mode 100644 nhmesh-mqtt-auth/src/mqtt/mod.rs create mode 100644 nhmesh-mqtt-auth/src/routes/health.rs create mode 100644 nhmesh-mqtt-auth/src/routes/mod.rs diff --git a/nhmesh-mqtt-auth/.gitignore b/nhmesh-mqtt-auth/.gitignore new file mode 100644 index 0000000..1de5659 --- /dev/null +++ b/nhmesh-mqtt-auth/.gitignore @@ -0,0 +1 @@ +target \ No newline at end of file diff --git a/nhmesh-mqtt-auth/Cargo.lock b/nhmesh-mqtt-auth/Cargo.lock new file mode 100644 index 0000000..ab7641c --- /dev/null +++ b/nhmesh-mqtt-auth/Cargo.lock @@ -0,0 +1,1532 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "actix-codec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-sink", + "memchr", + "pin-project-lite", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "actix-http" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa882656b67966045e4152c634051e70346939fced7117d5f0b52146a7c74c9" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-utils", + "base64", + "bitflags", + "brotli", + "bytes", + "bytestring", + "derive_more", + "encoding_rs", + "flate2", + "foldhash", + "futures-core", + "h2", + "http", + "httparse", + "httpdate", + "itoa", + "language-tags", + "local-channel", + "mime", + "percent-encoding", + "pin-project-lite", + "rand", + "sha1", + "smallvec", + "tokio", + "tokio-util", + "tracing", + "zstd", +] + +[[package]] +name = "actix-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "actix-router" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d324164c51f63867b57e73ba5936ea151b8a41a1d23d1031eeb9f70d0236f8" +dependencies = [ + "bytestring", + "cfg-if", + "http", + "regex", + "regex-lite", + "serde", + "tracing", +] + +[[package]] +name = "actix-rt" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eda4e2a6e042aa4e55ac438a2ae052d3b5da0ecf83d7411e1a368946925208" +dependencies = [ + "futures-core", + "tokio", +] + +[[package]] +name = "actix-server" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6398974fd4284f4768af07965701efbbb5fdc0616bff20cade1bb14b77675e24" +dependencies = [ + "actix-rt", + "actix-service", + "actix-utils", + "futures-core", + "futures-util", + "mio", + "socket2", + "tokio", + "tracing", +] + +[[package]] +name = "actix-service" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e46f36bf0e5af44bdc4bdb36fbbd421aa98c79a9bce724e1edeb3894e10dc7f" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "actix-utils" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" +dependencies = [ + "local-waker", + "pin-project-lite", +] + +[[package]] +name = "actix-web" +version = "4.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2e3b15b3dc6c6ed996e4032389e9849d4ab002b1e92fbfe85b5f307d1479b4d" +dependencies = [ + "actix-codec", + "actix-http", + "actix-macros", + "actix-router", + "actix-rt", + "actix-server", + "actix-service", + "actix-utils", + "actix-web-codegen", + "bytes", + "bytestring", + "cfg-if", + "cookie", + "derive_more", + "encoding_rs", + "foldhash", + "futures-core", + "futures-util", + "impl-more", + "itoa", + "language-tags", + "log", + "mime", + "once_cell", + "pin-project-lite", + "regex", + "regex-lite", + "serde", + "serde_json", + "serde_urlencoded", + "smallvec", + "socket2", + "time", + "tracing", + "url", +] + +[[package]] +name = "actix-web-codegen" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f591380e2e68490b5dfaf1dd1aa0ebe78d84ba7067078512b4ea6e4492d622b8" +dependencies = [ + "actix-router", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "brotli" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a334ef7c9e23abf0ce748e8cd309037da93e606ad52eb372e4ce327a0dcfbdfd" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "bytes" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" + +[[package]] +name = "bytestring" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e465647ae23b2823b0753f50decb2d5a86d2bb2cac04788fafd1f80e45378e5f" +dependencies = [ + "bytes", +] + +[[package]] +name = "cc" +version = "1.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8691782945451c1c383942c4874dbe63814f61cb57ef773cda2972682b7bb3c0" +dependencies = [ + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cookie" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "deranged" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "derive_more" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "flate2" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d" + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7" + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2" + +[[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", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "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]] +name = "impl-more" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a5a9a0ff0086c7a148acb942baaabeadf9504d10400b5a05645853729b9cd2" + +[[package]] +name = "indexmap" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "jobserver" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" +dependencies = [ + "getrandom", + "libc", +] + +[[package]] +name = "language-tags" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" + +[[package]] +name = "libc" +version = "0.2.172" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" + +[[package]] +name = "litemap" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" + +[[package]] +name = "local-channel" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6cbc85e69b8df4b8bb8b89ec634e7189099cea8927a276b7384ce5488e53ec8" +dependencies = [ + "futures-core", + "futures-sink", + "local-waker", +] + +[[package]] +name = "local-waker" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d873d7c67ce09b42110d801813efbc9364414e356be9935700d368351657487" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys", +] + +[[package]] +name = "nhmesh-mqtt-auth" +version = "0.1.0" +dependencies = [ + "actix-web", + "tokio", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + +[[package]] +name = "rand" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-lite" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" + +[[package]] +name = "socket2" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "syn" +version = "2.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" + +[[package]] +name = "time-macros" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" +dependencies = [ + "num-conv", + "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 = "tokio" +version = "1.44.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-util" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +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_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[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.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[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.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[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.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags", +] + +[[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 = "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", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[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", +] + +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.15+zstd.1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb81183ddd97d0c74cedf1d50d85c8d08c1b8b68ee863bdee9e706eedba1a237" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/nhmesh-mqtt-auth/Cargo.toml b/nhmesh-mqtt-auth/Cargo.toml new file mode 100644 index 0000000..6907ada --- /dev/null +++ b/nhmesh-mqtt-auth/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "nhmesh-mqtt-auth" +version = "0.1.0" +edition = "2024" + +[lib] +name = "nhmesh_mqtt_auth" +path = "src/lib.rs" + +[[bin]] +name = "nhmesh-mqtt-auth" +path = "src/main.rs" + +[dependencies] +actix-web = "4" +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } \ No newline at end of file diff --git a/nhmesh-mqtt-auth/src/lib.rs b/nhmesh-mqtt-auth/src/lib.rs new file mode 100644 index 0000000..495ab77 --- /dev/null +++ b/nhmesh-mqtt-auth/src/lib.rs @@ -0,0 +1,15 @@ +use actix_web::{web, App, HttpServer}; +use actix_web::dev::Server; + +mod routes; + +pub fn run() -> Result { + let server = HttpServer::new(|| { + App::new() + .route("/health", web::get().to(routes::health)) + }) + .bind("127.0.0.1:8080")? + .run(); + + Ok(server) +} \ No newline at end of file diff --git a/nhmesh-mqtt-auth/src/main.rs b/nhmesh-mqtt-auth/src/main.rs new file mode 100644 index 0000000..fc24382 --- /dev/null +++ b/nhmesh-mqtt-auth/src/main.rs @@ -0,0 +1,8 @@ +use nhmesh_mqtt_auth::run; + + +#[tokio::main] +async fn main() -> Result<(), std::io::Error> { + run()?.await?; + Ok(()) +} diff --git a/nhmesh-mqtt-auth/src/mqtt/mod.rs b/nhmesh-mqtt-auth/src/mqtt/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/nhmesh-mqtt-auth/src/routes/health.rs b/nhmesh-mqtt-auth/src/routes/health.rs new file mode 100644 index 0000000..9944857 --- /dev/null +++ b/nhmesh-mqtt-auth/src/routes/health.rs @@ -0,0 +1,5 @@ +use actix_web::HttpResponse; + +pub async fn health() -> HttpResponse { + HttpResponse::Ok().body("OK") +} diff --git a/nhmesh-mqtt-auth/src/routes/mod.rs b/nhmesh-mqtt-auth/src/routes/mod.rs new file mode 100644 index 0000000..d10f4b4 --- /dev/null +++ b/nhmesh-mqtt-auth/src/routes/mod.rs @@ -0,0 +1,3 @@ +mod health; + +pub use health::*; \ No newline at end of file From cf905a6ed98c78e262a388ea7a62e8fce2ee4fc4 Mon Sep 17 00:00:00 2001 From: Doni Crosby Date: Fri, 2 May 2025 20:50:05 -0400 Subject: [PATCH 2/7] feat: health check tests --- nhmesh-mqtt-auth/Cargo.lock | 797 +++++++++++++++++++++++++- nhmesh-mqtt-auth/Cargo.toml | 7 +- nhmesh-mqtt-auth/src/lib.rs | 5 +- nhmesh-mqtt-auth/src/main.rs | 5 +- nhmesh-mqtt-auth/src/mqtt/mod.rs | 0 nhmesh-mqtt-auth/src/routes/health.rs | 6 +- nhmesh-mqtt-auth/tests/api/health.rs | 10 + nhmesh-mqtt-auth/tests/api/main.rs | 2 + nhmesh-mqtt-auth/tests/api/util.rs | 14 + 9 files changed, 820 insertions(+), 26 deletions(-) delete mode 100644 nhmesh-mqtt-auth/src/mqtt/mod.rs create mode 100644 nhmesh-mqtt-auth/tests/api/health.rs create mode 100644 nhmesh-mqtt-auth/tests/api/main.rs create mode 100644 nhmesh-mqtt-auth/tests/api/util.rs diff --git a/nhmesh-mqtt-auth/Cargo.lock b/nhmesh-mqtt-auth/Cargo.lock index ab7641c..32c0378 100644 --- a/nhmesh-mqtt-auth/Cargo.lock +++ b/nhmesh-mqtt-auth/Cargo.lock @@ -39,8 +39,8 @@ dependencies = [ "flate2", "foldhash", "futures-core", - "h2", - "http", + "h2 0.3.26", + "http 0.2.12", "httparse", "httpdate", "itoa", @@ -76,7 +76,7 @@ checksum = "13d324164c51f63867b57e73ba5936ea151b8a41a1d23d1031eeb9f70d0236f8" dependencies = [ "bytestring", "cfg-if", - "http", + "http 0.2.12", "regex", "regex-lite", "serde", @@ -224,6 +224,12 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.4.0" @@ -242,7 +248,7 @@ dependencies = [ "miniz_oxide", "object", "rustc-demangle", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -287,6 +293,12 @@ dependencies = [ "alloc-stdlib", ] +[[package]] +name = "bumpalo" +version = "3.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" + [[package]] name = "bytes" version = "1.10.1" @@ -330,6 +342,22 @@ 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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -424,6 +452,22 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]] +name = "errno" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + [[package]] name = "flate2" version = "1.1.1" @@ -446,6 +490,21 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[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" @@ -455,6 +514,15 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", +] + [[package]] name = "futures-core" version = "0.3.31" @@ -495,6 +563,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.3.2" @@ -524,7 +603,26 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75249d144030531f8dee69fe9cea04d3edf809a017ae445e2abdff6629e86633" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.3.1", "indexmap", "slab", "tokio", @@ -549,6 +647,40 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.3.1", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http 1.3.1", + "http-body", + "pin-project-lite", +] + [[package]] name = "httparse" version = "1.10.1" @@ -561,6 +693,79 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "hyper" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.9", + "http 1.3.1", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" +dependencies = [ + "futures-util", + "http 1.3.1", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.3.1", + "http-body", + "hyper", + "libc", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + [[package]] name = "icu_collections" version = "1.5.0" @@ -716,6 +921,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + [[package]] name = "itoa" version = "1.0.15" @@ -728,10 +939,20 @@ version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" dependencies = [ - "getrandom", + "getrandom 0.3.2", "libc", ] +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + [[package]] name = "language-tags" version = "0.3.2" @@ -744,6 +965,12 @@ version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + [[package]] name = "litemap" version = "0.7.5" @@ -813,7 +1040,24 @@ dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "native-tls" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", ] [[package]] @@ -821,6 +1065,9 @@ name = "nhmesh-mqtt-auth" version = "0.1.0" dependencies = [ "actix-web", + "reqwest", + "serde", + "serde_json", "tokio", ] @@ -845,6 +1092,50 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "openssl" +version = "0.10.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" +dependencies = [ + "bitflags", + "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.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "openssl-sys" +version = "0.9.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e145e1651e858e820e4860f7b9c5e169bc1d8ce1c86043be79fa7b7634821847" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "parking_lot" version = "0.12.3" @@ -865,7 +1156,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -957,7 +1248,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom", + "getrandom 0.3.2", ] [[package]] @@ -1004,24 +1295,172 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "reqwest" +version = "0.12.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2 0.4.9", + "http 1.3.1", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "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", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-registry", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.16", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rustc-demangle" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustix" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.23.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df51b5869f3a441595eac5e8ff14d486ff285f7b8c0df8770e49c3b56351f0f0" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" + +[[package]] +name = "rustls-webpki" +version = "0.103.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fef8b8769aaccf73098557a87cd1816b4f9c7c16811c9c77142aa695c16f2c03" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + [[package]] name = "ryu" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +[[package]] +name = "schannel" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "serde" version = "1.0.219" @@ -1114,7 +1553,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1123,6 +1562,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.101" @@ -1134,6 +1579,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + [[package]] name = "synstructure" version = "0.13.2" @@ -1145,6 +1599,40 @@ dependencies = [ "syn", ] +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" +dependencies = [ + "fastrand", + "getrandom 0.3.2", + "once_cell", + "rustix", + "windows-sys 0.52.0", +] + [[package]] name = "time" version = "0.3.41" @@ -1201,7 +1689,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1215,6 +1703,26 @@ 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-rustls" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +dependencies = [ + "rustls", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.15" @@ -1228,6 +1736,33 @@ dependencies = [ "tokio", ] +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[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.41" @@ -1260,6 +1795,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.18.0" @@ -1278,6 +1819,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.5.4" @@ -1301,12 +1848,27 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" 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" @@ -1322,13 +1884,138 @@ dependencies = [ "wit-bindgen-rt", ] +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "windows-link" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" + +[[package]] +name = "windows-registry" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.53.0", +] + +[[package]] +name = "windows-result" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319" +dependencies = [ + "windows-link", +] + [[package]] name = "windows-sys" 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]] @@ -1337,14 +2024,30 @@ 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_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "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-targets" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", ] [[package]] @@ -1353,48 +2056,96 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[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_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[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_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "wit-bindgen-rt" version = "0.39.0" @@ -1481,6 +2232,12 @@ dependencies = [ "synstructure", ] +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + [[package]] name = "zerovec" version = "0.10.4" diff --git a/nhmesh-mqtt-auth/Cargo.toml b/nhmesh-mqtt-auth/Cargo.toml index 6907ada..2fccec7 100644 --- a/nhmesh-mqtt-auth/Cargo.toml +++ b/nhmesh-mqtt-auth/Cargo.toml @@ -13,4 +13,9 @@ path = "src/main.rs" [dependencies] actix-web = "4" -tokio = { version = "1", features = ["macros", "rt-multi-thread"] } \ No newline at end of file +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } +serde_json = "1" +serde = { version = "1", features = ["derive"] } + +[dev-dependencies] +reqwest = { version = "0.12", features = ["json"] } diff --git a/nhmesh-mqtt-auth/src/lib.rs b/nhmesh-mqtt-auth/src/lib.rs index 495ab77..a962a49 100644 --- a/nhmesh-mqtt-auth/src/lib.rs +++ b/nhmesh-mqtt-auth/src/lib.rs @@ -1,14 +1,15 @@ use actix_web::{web, App, HttpServer}; use actix_web::dev::Server; +use std::net::TcpListener; mod routes; -pub fn run() -> Result { +pub fn run(listener: TcpListener) -> Result { let server = HttpServer::new(|| { App::new() .route("/health", web::get().to(routes::health)) }) - .bind("127.0.0.1:8080")? + .listen(listener)? .run(); Ok(server) diff --git a/nhmesh-mqtt-auth/src/main.rs b/nhmesh-mqtt-auth/src/main.rs index fc24382..db0d7fa 100644 --- a/nhmesh-mqtt-auth/src/main.rs +++ b/nhmesh-mqtt-auth/src/main.rs @@ -1,8 +1,9 @@ use nhmesh_mqtt_auth::run; - +use std::net::TcpListener; #[tokio::main] async fn main() -> Result<(), std::io::Error> { - run()?.await?; + let listener = TcpListener::bind("127.0.0.1:8080")?; + run(listener)?.await?; Ok(()) } diff --git a/nhmesh-mqtt-auth/src/mqtt/mod.rs b/nhmesh-mqtt-auth/src/mqtt/mod.rs deleted file mode 100644 index e69de29..0000000 diff --git a/nhmesh-mqtt-auth/src/routes/health.rs b/nhmesh-mqtt-auth/src/routes/health.rs index 9944857..7d811e5 100644 --- a/nhmesh-mqtt-auth/src/routes/health.rs +++ b/nhmesh-mqtt-auth/src/routes/health.rs @@ -1,5 +1,9 @@ use actix_web::HttpResponse; +use serde_json::json; + pub async fn health() -> HttpResponse { - HttpResponse::Ok().body("OK") + HttpResponse::Ok().json(json!({ + "status": "ok" + })) } diff --git a/nhmesh-mqtt-auth/tests/api/health.rs b/nhmesh-mqtt-auth/tests/api/health.rs new file mode 100644 index 0000000..d356334 --- /dev/null +++ b/nhmesh-mqtt-auth/tests/api/health.rs @@ -0,0 +1,10 @@ +use crate::util::spawn_app; +use reqwest::StatusCode; + +#[tokio::test] +async fn test_health() { + let app_url = spawn_app(); + let client = reqwest::Client::new(); + let response = client.get(format!("{}/health", app_url)).send().await.unwrap(); + assert_eq!(response.status(), StatusCode::OK); +} diff --git a/nhmesh-mqtt-auth/tests/api/main.rs b/nhmesh-mqtt-auth/tests/api/main.rs new file mode 100644 index 0000000..261b977 --- /dev/null +++ b/nhmesh-mqtt-auth/tests/api/main.rs @@ -0,0 +1,2 @@ +mod util; +mod health; \ No newline at end of file diff --git a/nhmesh-mqtt-auth/tests/api/util.rs b/nhmesh-mqtt-auth/tests/api/util.rs new file mode 100644 index 0000000..0cf0e29 --- /dev/null +++ b/nhmesh-mqtt-auth/tests/api/util.rs @@ -0,0 +1,14 @@ +use std::net::TcpListener; +use nhmesh_mqtt_auth::run; + +pub fn spawn_app() -> String { + // Bind to random port + let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind to random port"); + // Get port + let port = listener.local_addr().unwrap().port(); + // Run server + let server = run(listener).expect("Failed to bind address"); + let _ = tokio::spawn(server); + // Return test url + format!("http://127.0.0.1:{}", port) +} \ No newline at end of file From ae3e32b861f43435c047543ebfad484a7dd4a0d6 Mon Sep 17 00:00:00 2001 From: Doni Crosby Date: Sun, 4 May 2025 10:19:45 -0400 Subject: [PATCH 3/7] feat: add telemetry to server --- nhmesh-mqtt-auth/Cargo.lock | 479 +++++++++++++++++++++++++- nhmesh-mqtt-auth/Cargo.toml | 4 + nhmesh-mqtt-auth/config.yaml | 4 + nhmesh-mqtt-auth/src/config.rs | 30 ++ nhmesh-mqtt-auth/src/lib.rs | 17 +- nhmesh-mqtt-auth/src/main.rs | 12 +- nhmesh-mqtt-auth/src/models/mod.rs | 3 + nhmesh-mqtt-auth/src/models/mqtt.rs | 11 + nhmesh-mqtt-auth/src/routes/health.rs | 6 +- nhmesh-mqtt-auth/src/routes/mod.rs | 2 +- nhmesh-mqtt-auth/tests/api/health.rs | 6 +- nhmesh-mqtt-auth/tests/api/main.rs | 2 +- nhmesh-mqtt-auth/tests/api/util.rs | 6 +- 13 files changed, 555 insertions(+), 27 deletions(-) create mode 100644 nhmesh-mqtt-auth/config.yaml create mode 100644 nhmesh-mqtt-auth/src/config.rs create mode 100644 nhmesh-mqtt-auth/src/models/mod.rs create mode 100644 nhmesh-mqtt-auth/src/models/mqtt.rs diff --git a/nhmesh-mqtt-auth/Cargo.lock b/nhmesh-mqtt-auth/Cargo.lock index 32c0378..e8ddf8b 100644 --- a/nhmesh-mqtt-auth/Cargo.lock +++ b/nhmesh-mqtt-auth/Cargo.lock @@ -29,7 +29,7 @@ dependencies = [ "actix-rt", "actix-service", "actix-utils", - "base64", + "base64 0.22.1", "bitflags", "brotli", "bytes", @@ -224,6 +224,23 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "arraydeque" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" + +[[package]] +name = "async-trait" +version = "0.1.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atomic-waker" version = "1.1.2" @@ -251,6 +268,12 @@ dependencies = [ "windows-targets 0.52.6", ] +[[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" @@ -262,6 +285,9 @@ name = "bitflags" version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +dependencies = [ + "serde", +] [[package]] name = "block-buffer" @@ -331,6 +357,54 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "config" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595aae20e65c3be792d05818e8c63025294ac3cb7e200f11459063a352a6ef80" +dependencies = [ + "async-trait", + "convert_case", + "json5", + "pathdiff", + "ron", + "rust-ini", + "serde", + "serde_json", + "toml", + "winnow", + "yaml-rust2", +] + +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.16", + "once_cell", + "tiny-keccak", +] + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "cookie" version = "0.16.2" @@ -376,6 +450,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crunchy" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" + [[package]] name = "crypto-common" version = "0.1.6" @@ -437,6 +517,15 @@ dependencies = [ "syn", ] +[[package]] +name = "dlv-list" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" +dependencies = [ + "const-random", +] + [[package]] name = "encoding_rs" version = "0.8.35" @@ -459,7 +548,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -630,11 +719,29 @@ dependencies = [ "tracing", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + [[package]] name = "hashbrown" version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashlink" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +dependencies = [ + "hashbrown 0.15.3", +] [[package]] name = "http" @@ -918,7 +1025,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.3", ] [[package]] @@ -953,12 +1060,29 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "json5" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1" +dependencies = [ + "pest", + "pest_derive", + "serde", +] + [[package]] name = "language-tags" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "libc" version = "0.2.172" @@ -1010,6 +1134,15 @@ version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "memchr" version = "2.7.4" @@ -1065,10 +1198,24 @@ name = "nhmesh-mqtt-auth" version = "0.1.0" dependencies = [ "actix-web", + "config", "reqwest", "serde", "serde_json", "tokio", + "tracing", + "tracing-log 0.1.4", + "tracing-subscriber", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", ] [[package]] @@ -1136,6 +1283,22 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "ordered-multimap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79" +dependencies = [ + "dlv-list", + "hashbrown 0.14.5", +] + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parking_lot" version = "0.12.3" @@ -1159,12 +1322,63 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "pathdiff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" + [[package]] name = "percent-encoding" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pest" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "198db74531d58c70a361c42201efde7e2591e976d518caf7662a47dc5720e7b6" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d725d9cfd79e87dccc9341a2ef39d1b6f6353d68c4b33c177febbe1a402c97c5" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db7d01726be8ab66ab32f9df467ae8b1148906685bbe75c82d1e65d7f5b3f841" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pest_meta" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9f832470494906d1fca5329f8ab5791cc60beb230c74815dff541cbd2b5ca0" +dependencies = [ + "once_cell", + "pest", + "sha2", +] + [[package]] name = "pin-project-lite" version = "0.2.16" @@ -1268,8 +1482,17 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] @@ -1280,7 +1503,7 @@ checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.5", ] [[package]] @@ -1289,6 +1512,12 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.5" @@ -1301,7 +1530,7 @@ version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" dependencies = [ - "base64", + "base64 0.22.1", "bytes", "encoding_rs", "futures-core", @@ -1353,6 +1582,29 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "ron" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" +dependencies = [ + "base64 0.21.7", + "bitflags", + "serde", + "serde_derive", +] + +[[package]] +name = "rust-ini" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e310ef0e1b6eeb79169a1171daf9abcb87a2e17c03bee2c4bb100b55c75409f" +dependencies = [ + "cfg-if", + "ordered-multimap", + "trim-in-place", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -1369,7 +1621,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1493,6 +1745,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1516,6 +1777,26 @@ dependencies = [ "digest", ] +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.3.0" @@ -1630,7 +1911,37 @@ dependencies = [ "getrandom 0.3.2", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", ] [[package]] @@ -1664,6 +1975,15 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinystr" version = "0.7.6" @@ -1736,6 +2056,40 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tower" version = "0.5.2" @@ -1793,8 +2147,55 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" +dependencies = [ + "log", + "once_cell", + "tracing-core", ] +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log 0.2.0", +] + +[[package]] +name = "trim-in-place" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc" + [[package]] name = "try-lock" version = "0.2.5" @@ -1807,12 +2208,24 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + [[package]] name = "unicode-ident" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -1848,6 +2261,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + [[package]] name = "vcpkg" version = "0.2.15" @@ -1965,6 +2384,28 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows-link" version = "0.1.1" @@ -2146,6 +2587,15 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" +[[package]] +name = "winnow" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9fb597c990f03753e08d3c29efbfcf2019a003b4bf4ba19225c158e1549f0f3" +dependencies = [ + "memchr", +] + [[package]] name = "wit-bindgen-rt" version = "0.39.0" @@ -2167,6 +2617,17 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" +[[package]] +name = "yaml-rust2" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "818913695e83ece1f8d2a1c52d54484b7b46d0f9c06beeb2649b9da50d9b512d" +dependencies = [ + "arraydeque", + "encoding_rs", + "hashlink", +] + [[package]] name = "yoke" version = "0.7.5" diff --git a/nhmesh-mqtt-auth/Cargo.toml b/nhmesh-mqtt-auth/Cargo.toml index 2fccec7..40ab013 100644 --- a/nhmesh-mqtt-auth/Cargo.toml +++ b/nhmesh-mqtt-auth/Cargo.toml @@ -16,6 +16,10 @@ actix-web = "4" tokio = { version = "1", features = ["macros", "rt-multi-thread"] } serde_json = "1" serde = { version = "1", features = ["derive"] } +config = { version = "0.15", features = ["yaml"] } +tracing = { version = "0.1", features = ["log"] } +tracing-subscriber = { version = "0.3", features = ["env-filter", "registry"] } +tracing-log = "0.1" [dev-dependencies] reqwest = { version = "0.12", features = ["json"] } diff --git a/nhmesh-mqtt-auth/config.yaml b/nhmesh-mqtt-auth/config.yaml new file mode 100644 index 0000000..3c92154 --- /dev/null +++ b/nhmesh-mqtt-auth/config.yaml @@ -0,0 +1,4 @@ +--- +app: + host: 127.0.0.1 + port: 8000 diff --git a/nhmesh-mqtt-auth/src/config.rs b/nhmesh-mqtt-auth/src/config.rs new file mode 100644 index 0000000..d8ce695 --- /dev/null +++ b/nhmesh-mqtt-auth/src/config.rs @@ -0,0 +1,30 @@ +use config::Config; +use serde::Deserialize; + +#[derive(Debug, Deserialize)] +pub struct Settings { + pub app: AppConfig, +} + +#[derive(Debug, Deserialize)] +pub struct AppConfig { + pub port: u16, + pub host: String, +} + +impl Default for AppConfig { + fn default() -> Self { + Self { + port: 8080, + host: "127.0.0.1".to_string(), + } + } +} + +pub fn get_config() -> Result { + let config = Config::builder() + .add_source(config::File::with_name("config.yaml").format(config::FileFormat::Yaml)) + .build()?; + + config.try_deserialize::() +} diff --git a/nhmesh-mqtt-auth/src/lib.rs b/nhmesh-mqtt-auth/src/lib.rs index a962a49..b959f8b 100644 --- a/nhmesh-mqtt-auth/src/lib.rs +++ b/nhmesh-mqtt-auth/src/lib.rs @@ -1,16 +1,17 @@ -use actix_web::{web, App, HttpServer}; use actix_web::dev::Server; +use actix_web::{App, HttpServer}; use std::net::TcpListener; +mod config; +mod models; mod routes; +pub use config::*; + pub fn run(listener: TcpListener) -> Result { - let server = HttpServer::new(|| { - App::new() - .route("/health", web::get().to(routes::health)) - }) - .listen(listener)? - .run(); + let server = HttpServer::new(|| App::new().service(routes::health)) + .listen(listener)? + .run(); Ok(server) -} \ No newline at end of file +} diff --git a/nhmesh-mqtt-auth/src/main.rs b/nhmesh-mqtt-auth/src/main.rs index db0d7fa..3afad01 100644 --- a/nhmesh-mqtt-auth/src/main.rs +++ b/nhmesh-mqtt-auth/src/main.rs @@ -1,9 +1,17 @@ -use nhmesh_mqtt_auth::run; +use nhmesh_mqtt_auth::{get_config, run}; use std::net::TcpListener; +use tracing_log::LogTracer; +use tracing_subscriber::{EnvFilter, Registry, fmt, layer::SubscriberExt}; #[tokio::main] async fn main() -> Result<(), std::io::Error> { - let listener = TcpListener::bind("127.0.0.1:8080")?; + LogTracer::init().expect("Failed to set logger"); + let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")); + let subscriber = Registry::default().with(env_filter).with(fmt::layer()); + tracing::subscriber::set_global_default(subscriber).expect("Failed to set subscriber"); + + let config = get_config().expect("Failed to read config."); + let listener = TcpListener::bind(format!("{}:{}", config.app.host, config.app.port))?; run(listener)?.await?; Ok(()) } diff --git a/nhmesh-mqtt-auth/src/models/mod.rs b/nhmesh-mqtt-auth/src/models/mod.rs new file mode 100644 index 0000000..6da18d7 --- /dev/null +++ b/nhmesh-mqtt-auth/src/models/mod.rs @@ -0,0 +1,3 @@ +mod mqtt; + +pub(crate) use mqtt::*; diff --git a/nhmesh-mqtt-auth/src/models/mqtt.rs b/nhmesh-mqtt-auth/src/models/mqtt.rs new file mode 100644 index 0000000..141383e --- /dev/null +++ b/nhmesh-mqtt-auth/src/models/mqtt.rs @@ -0,0 +1,11 @@ +use serde::Deserialize; +use std::net::IpAddr; + +#[derive(Debug, Deserialize)] +pub struct MqttAuth { + #[serde(rename = "clientid")] + pub client_id: String, + pub username: String, + pub password: String, + pub ip: IpAddr, +} diff --git a/nhmesh-mqtt-auth/src/routes/health.rs b/nhmesh-mqtt-auth/src/routes/health.rs index 7d811e5..743568b 100644 --- a/nhmesh-mqtt-auth/src/routes/health.rs +++ b/nhmesh-mqtt-auth/src/routes/health.rs @@ -1,7 +1,9 @@ -use actix_web::HttpResponse; +use actix_web::{HttpResponse, get}; use serde_json::json; +use tracing::instrument; - +#[get("/health")] +#[instrument(level = "debug")] pub async fn health() -> HttpResponse { HttpResponse::Ok().json(json!({ "status": "ok" diff --git a/nhmesh-mqtt-auth/src/routes/mod.rs b/nhmesh-mqtt-auth/src/routes/mod.rs index d10f4b4..401fafc 100644 --- a/nhmesh-mqtt-auth/src/routes/mod.rs +++ b/nhmesh-mqtt-auth/src/routes/mod.rs @@ -1,3 +1,3 @@ mod health; -pub use health::*; \ No newline at end of file +pub(crate) use health::*; diff --git a/nhmesh-mqtt-auth/tests/api/health.rs b/nhmesh-mqtt-auth/tests/api/health.rs index d356334..14df398 100644 --- a/nhmesh-mqtt-auth/tests/api/health.rs +++ b/nhmesh-mqtt-auth/tests/api/health.rs @@ -5,6 +5,10 @@ use reqwest::StatusCode; async fn test_health() { let app_url = spawn_app(); let client = reqwest::Client::new(); - let response = client.get(format!("{}/health", app_url)).send().await.unwrap(); + let response = client + .get(format!("{}/health", app_url)) + .send() + .await + .unwrap(); assert_eq!(response.status(), StatusCode::OK); } diff --git a/nhmesh-mqtt-auth/tests/api/main.rs b/nhmesh-mqtt-auth/tests/api/main.rs index 261b977..e799ab0 100644 --- a/nhmesh-mqtt-auth/tests/api/main.rs +++ b/nhmesh-mqtt-auth/tests/api/main.rs @@ -1,2 +1,2 @@ +mod health; mod util; -mod health; \ No newline at end of file diff --git a/nhmesh-mqtt-auth/tests/api/util.rs b/nhmesh-mqtt-auth/tests/api/util.rs index 0cf0e29..3d65540 100644 --- a/nhmesh-mqtt-auth/tests/api/util.rs +++ b/nhmesh-mqtt-auth/tests/api/util.rs @@ -1,5 +1,5 @@ -use std::net::TcpListener; use nhmesh_mqtt_auth::run; +use std::net::TcpListener; pub fn spawn_app() -> String { // Bind to random port @@ -9,6 +9,6 @@ pub fn spawn_app() -> String { // Run server let server = run(listener).expect("Failed to bind address"); let _ = tokio::spawn(server); - // Return test url + // Return test url format!("http://127.0.0.1:{}", port) -} \ No newline at end of file +} From be6caf6b74193501d5e4528af8e7d417a3a8eae8 Mon Sep 17 00:00:00 2001 From: Doni Crosby Date: Mon, 5 May 2025 08:28:15 -0400 Subject: [PATCH 4/7] feat: create user in db --- docker/docker-compose.yml | 13 + .../rmqtt/rmqtt/rmqtt-plugins/rmqtt-acl.toml | 18 + .../rmqtt/rmqtt-plugins/rmqtt-auth-http.toml | 69 + .../rmqtt/rmqtt-plugins/rmqtt-auth-jwt.toml | 78 + .../rmqtt-auto-subscription.toml | 14 + .../rmqtt-bridge-egress-kafka.toml | 43 + .../rmqtt-bridge-egress-mqtt.toml | 153 ++ .../rmqtt-bridge-egress-nats.toml | 53 + .../rmqtt-bridge-egress-pulsar.toml | 75 + .../rmqtt-bridge-egress-reductstore.toml | 54 + .../rmqtt-bridge-ingress-kafka.toml | 58 + .../rmqtt-bridge-ingress-mqtt.toml | 146 ++ .../rmqtt-bridge-ingress-pulsar.toml | 216 ++ .../rmqtt-cluster-broadcast.toml | 10 + .../rmqtt-plugins/rmqtt-cluster-raft.toml | 65 + .../rmqtt/rmqtt-plugins/rmqtt-http-api.toml | 24 + .../rmqtt-plugins/rmqtt-message-storage.toml | 22 + .../rmqtt/rmqtt-plugins/rmqtt-retainer.toml | 30 + .../rmqtt-plugins/rmqtt-session-storage.toml | 18 + .../rmqtt/rmqtt-plugins/rmqtt-sys-topic.toml | 12 + .../rmqtt-plugins/rmqtt-topic-rewrite.toml | 22 + .../rmqtt/rmqtt-plugins/rmqtt-web-hook.toml | 45 + docker/rmqtt/rmqtt/rmqtt.toml | 239 ++ nhmesh-mqtt-auth/Cargo.lock | 2221 +++++++++++++++-- nhmesh-mqtt-auth/Cargo.toml | 27 +- nhmesh-mqtt-auth/api/Cargo.toml | 33 + nhmesh-mqtt-auth/{ => api}/src/config.rs | 16 +- nhmesh-mqtt-auth/api/src/lib.rs | 29 + nhmesh-mqtt-auth/{ => api}/src/main.rs | 12 +- nhmesh-mqtt-auth/{ => api}/src/models/mod.rs | 2 + nhmesh-mqtt-auth/{ => api}/src/models/mqtt.rs | 6 +- nhmesh-mqtt-auth/api/src/models/user.rs | 79 + .../{ => api}/src/routes/health.rs | 0 nhmesh-mqtt-auth/api/src/routes/mod.rs | 6 + nhmesh-mqtt-auth/api/src/routes/mqtt/mod.rs | 10 + nhmesh-mqtt-auth/api/src/routes/user.rs | 27 + .../{ => api}/tests/api/health.rs | 2 +- nhmesh-mqtt-auth/{ => api}/tests/api/main.rs | 2 + nhmesh-mqtt-auth/api/tests/api/mqtt.rs | 22 + nhmesh-mqtt-auth/api/tests/api/user.rs | 22 + nhmesh-mqtt-auth/api/tests/api/util.rs | 44 + nhmesh-mqtt-auth/config.yaml | 3 + nhmesh-mqtt-auth/entity/Cargo.toml | 8 + nhmesh-mqtt-auth/entity/src/lib.rs | 7 + nhmesh-mqtt-auth/entity/src/prelude.rs | 3 + nhmesh-mqtt-auth/entity/src/user.rs | 20 + nhmesh-mqtt-auth/migration/Cargo.toml | 24 + nhmesh-mqtt-auth/migration/README.md | 41 + nhmesh-mqtt-auth/migration/src/lib.rs | 16 + .../m20220101_000001_create_users_table.rs | 37 + .../src/m20250504_231730_create_superuser.rs | 32 + nhmesh-mqtt-auth/migration/src/main.rs | 6 + nhmesh-mqtt-auth/src/lib.rs | 17 - nhmesh-mqtt-auth/src/routes/mod.rs | 3 - nhmesh-mqtt-auth/tests/api/util.rs | 14 - 55 files changed, 4053 insertions(+), 215 deletions(-) create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-acl.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-auth-http.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-auth-jwt.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-auto-subscription.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-kafka.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-mqtt.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-nats.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-pulsar.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-reductstore.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-ingress-kafka.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-ingress-mqtt.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-ingress-pulsar.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-cluster-broadcast.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-cluster-raft.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-http-api.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-message-storage.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-retainer.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-session-storage.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-sys-topic.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-topic-rewrite.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-web-hook.toml create mode 100644 docker/rmqtt/rmqtt/rmqtt.toml create mode 100644 nhmesh-mqtt-auth/api/Cargo.toml rename nhmesh-mqtt-auth/{ => api}/src/config.rs (68%) create mode 100644 nhmesh-mqtt-auth/api/src/lib.rs rename nhmesh-mqtt-auth/{ => api}/src/main.rs (61%) rename nhmesh-mqtt-auth/{ => api}/src/models/mod.rs (50%) rename nhmesh-mqtt-auth/{ => api}/src/models/mqtt.rs (61%) create mode 100644 nhmesh-mqtt-auth/api/src/models/user.rs rename nhmesh-mqtt-auth/{ => api}/src/routes/health.rs (100%) create mode 100644 nhmesh-mqtt-auth/api/src/routes/mod.rs create mode 100644 nhmesh-mqtt-auth/api/src/routes/mqtt/mod.rs create mode 100644 nhmesh-mqtt-auth/api/src/routes/user.rs rename nhmesh-mqtt-auth/{ => api}/tests/api/health.rs (89%) rename nhmesh-mqtt-auth/{ => api}/tests/api/main.rs (53%) create mode 100644 nhmesh-mqtt-auth/api/tests/api/mqtt.rs create mode 100644 nhmesh-mqtt-auth/api/tests/api/user.rs create mode 100644 nhmesh-mqtt-auth/api/tests/api/util.rs create mode 100644 nhmesh-mqtt-auth/entity/Cargo.toml create mode 100644 nhmesh-mqtt-auth/entity/src/lib.rs create mode 100644 nhmesh-mqtt-auth/entity/src/prelude.rs create mode 100644 nhmesh-mqtt-auth/entity/src/user.rs create mode 100644 nhmesh-mqtt-auth/migration/Cargo.toml create mode 100644 nhmesh-mqtt-auth/migration/README.md create mode 100644 nhmesh-mqtt-auth/migration/src/lib.rs create mode 100644 nhmesh-mqtt-auth/migration/src/m20220101_000001_create_users_table.rs create mode 100644 nhmesh-mqtt-auth/migration/src/m20250504_231730_create_superuser.rs create mode 100644 nhmesh-mqtt-auth/migration/src/main.rs delete mode 100644 nhmesh-mqtt-auth/src/lib.rs delete mode 100644 nhmesh-mqtt-auth/src/routes/mod.rs delete mode 100644 nhmesh-mqtt-auth/tests/api/util.rs diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 4208dd9..3d49dc7 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -43,7 +43,20 @@ services: - xpack.security.enabled=false ports: - "5601:5601" + + mqtt: + image: rmqtt/rmqtt:latest + ports: + - "1883:1883" + - "8883:8883" + - "11883:11883" + - "6060:6060" + volumes: + - mqttdata:/var/log/rmqtt + - ./rmqtt/rmqtt/rmqtt-plugins:/app/rmqtt/rmqtt-plugins:ro + - ./rmqtt/rmqtt/rmqtt.toml:/app/rmqtt/rmqtt.toml:ro volumes: esdata: + mqttdata: diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-acl.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-acl.toml new file mode 100644 index 0000000..4bc4377 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-acl.toml @@ -0,0 +1,18 @@ +##-------------------------------------------------------------------- +## rmqtt-acl +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/acl.md + +#Disconnect if publishing is rejected +disconnect_if_pub_rejected = true + +rules = [ + #["deny", "all", "subscribe", ["test/nosubscribe"]], + ["allow", { user = "dashboard" }, "subscribe", ["$SYS/#"]], + ["allow", { ipaddr = "127.0.0.1" }, "pubsub", ["$SYS/#", "#"]], + ["deny", "all", "subscribe", ["$SYS/#", { eq = "#" }]], + ["allow", "all"] +# ["deny", "all"] +] + diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-auth-http.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-auth-http.toml new file mode 100644 index 0000000..017af30 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-auth-http.toml @@ -0,0 +1,69 @@ +##-------------------------------------------------------------------- +## rmqtt-auth-http +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/auth-http.md + +http_timeout = "5s" +http_headers.accept = "*/*" +http_headers.Cache-Control = "no-cache" +http_headers.User-Agent = "RMQTT/0.8.0" +http_headers.Connection = "keep-alive" + +## Disconnect if publishing is rejected +## +## Value: true | false +## Default: true +disconnect_if_pub_rejected = true + +## Disconnect After Expiration +## +## Value: true | false +## Default: false +disconnect_if_expiry = false + +## Return 'Deny' if http request error otherwise 'Ignore' +## +## Value: true | false +## Default: true +deny_if_error = true + +##-------------------------------------------------------------------- +## Authentication request. +## +## Variables: +## - %u: username +## - %c: clientid +## - %a: ipaddress +## - %r: protocol +## - %P: password +## +## Value: URL +http_auth_req.url = "http://172.20.0.1:8000/mqtt/auth" +## Value: post | get | put +http_auth_req.method = "post" +## HTTP request header of authentication request +## Content-Type Currently supported values: application/x-www-form-urlencoded, application/json +http_auth_req.headers = { content-type = "application/json" } +#http_auth_req.headers.content-type="application/json" +## Value: Params +http_auth_req.params = { clientid = "%c", username = "%u", password = "%P", ipaddr = "%a" } + + +##-------------------------------------------------------------------- +## ACL request. +## +## Variables: +## - %A: 1 | 2, 1 = sub, 2 = pub +## - %u: username +## - %c: clientid +## - %a: ipaddress +## - %r: protocol +## - %t: topic +## +## Value: URL +http_acl_req.url = "http://172.20.0.1:8000/mqtt/acl" +## Value: post | get | put +http_acl_req.method = "post" +## Value: Params +http_acl_req.params = { access = "%A", username = "%u", clientid = "%c", ipaddr = "%a", topic = "%t", protocol = "%r" } diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-auth-jwt.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-auth-jwt.toml new file mode 100644 index 0000000..1bbef6c --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-auth-jwt.toml @@ -0,0 +1,78 @@ +##-------------------------------------------------------------------- +## rmqtt-auth-jwt +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/auth-jwt.md + +## Disconnect if publishing is rejected +## +## Value: true | false +## Default: true +disconnect_if_pub_rejected = true + +## Disconnect After Expiration +## +## Value: true | false +## Default: false +disconnect_if_expiry = false + +## From where the JWT string can be got +## Value: username | password +## Default: password +from = "password" + +## Encryption method +## Value: hmac-based | public-key +## Default: hmac-based +encrypt = "hmac-based" + +## HMAC Hash Secret. +## +## Value: String +hmac_secret = "rmqttsecret" +#hmac_secret = "cm1xdHRzZWNyZXQ=" + +## Secret Base64 Encode +## +## Value: true | false +## Default: false +hmac_base64 = false + +## RSA or ECDSA public key file. +## +## Value: File +#public_key = "./rmqtt-bin/jwt_public_key_rsa.pem" +#public_key = "./rmqtt-bin/jwt_public_key_es256.pem" +#public_key = "./rmqtt-bin/jwt_public_key_es384.pem" + + +## The checklist of claims to validate +## +## Value: String +## validate_claims.$name = expected +## +## Placeholder: +## - ${username}: username +## - ${clientid}: clientid +## - ${ipaddr}: client ip addr +## - ${protocol}: MQTT protocol version: 3 = 3.1, 4 = 3.1.1, or 5 = 5.0 + +### Basic Validation +## > Validate the token's expiration by comparing the exp claim to the current UTC time. +validate_claims.exp = true +## < Ensure the token is not used before its nbf claim. +#validate_claims.nbf = true +## Ensure the token's subject (sub claim) is as expected. +#validate_claims.sub = "user@rmqtt.com" +## Validate the token's issuer by comparing the iss claim to the known issuer. +#validate_claims.iss = ["https://rmqtt.com1", "https://rmqtt.com"] +## Verify that the token's audience (aud claim) matches the intended recipient. +#validate_claims.aud = ["https://your-api.com", "mobile_app", "web_app"] + +### Extended Validation +#validate_claims.clientid = "${clientid}" +#validate_claims.username = "${username}" +#validate_claims.ipaddr = "${ipaddr}" +#validate_claims.protocol = "${protocol}" + + diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-auto-subscription.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-auto-subscription.toml new file mode 100644 index 0000000..1b50c33 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-auto-subscription.toml @@ -0,0 +1,14 @@ +##-------------------------------------------------------------------- +## rmqtt-auto-subscription +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/auto-subscription.md + +# Expressions can use ${clientid} to represent the client ID and ${username} to represent the client username. + +subscribes = [ +# { topic_filter = "x/+/#", qos = 1, no_local = false, retain_as_published = false, retain_handling = 0 }, +# { topic_filter = "foo/${clientid}/#", qos = 1, no_local = false, retain_as_published = false, retain_handling = 0 }, +# { topic_filter = "iot/${username}/#", qos = 1 } +] + diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-kafka.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-kafka.toml new file mode 100644 index 0000000..d1fcc59 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-kafka.toml @@ -0,0 +1,43 @@ +##-------------------------------------------------------------------- +## rmqtt-bridge-egress-kafka +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/bridge-egress-kafka.md + +[[bridges]] +# Whether to enable +enable = true +# Bridge name +name = "bridge_kafka_1" + +# The list of broker (server) addresses for the Kafka cluster. +#servers = "127.0.0.1:9092,127.0.0.1:9093,127.0.0.1:9094" +servers = "127.0.0.1:9092" +# client.id +client_id_prefix = "kafka_001" + +# Maximum limit of clients connected to the remote kafka broker +concurrent_client_limit = 3 + +# See more properties and their definitions at https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md +[bridges.properties] +"message.timeout.ms" = "5000" + +[[bridges.entries]] +#Local topic filter: All messages matching this topic filter will be forwarded. +local.topic_filter = "local/topic1/egress/#" + +remote.topic = "remote-topic1-egress-${local.topic}" +#The queue_timeout parameter controls how long to retry for if the librdkafka producer queue is full. 0 to never block. +remote.queue_timeout = "0m" +#Sets the destination partition of the record. +#remote.partition = 0 + +[[bridges.entries]] +#Local topic filter: All messages matching this topic filter will be forwarded. +local.topic_filter = "local/topic2/egress/#" + +remote.topic = "remote-topic2-egress" +#remote.queue_timeout = "0m" +#remote.partition = 0 + diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-mqtt.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-mqtt.toml new file mode 100644 index 0000000..93c3efa --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-mqtt.toml @@ -0,0 +1,153 @@ +##-------------------------------------------------------------------- +## rmqtt-bridge-egress-mqtt +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/bridge-egress-mqtt.md + +[[bridges]] +# Whether to enable +enable = true +# Bridge name +name = "bridge_name_1" +# Client ID prefix +client_id_prefix = "prefix" +# Address and port of the remote MQTT broker +server = "tcp://127.0.0.1:3883" +#server = "tls://127.0.0.1:9883" +##SSL / TLS Certificate Type +#CA signed server certificate +#root_cert = "./rmqtt-bin/root.pem" +##CA or Self signed certificates +#Client Certificate File +#client_cert = "./rmqtt-bin/client.pem" +#Client key file +#client_key = "./rmqtt-bin/client.key" + +# Username to connect to the remote MQTT broker +username = "rmqtt_u" +# Password to connect to the remote MQTT broker +password = "public" + +# Maximum limit of clients connected to the remote MQTT broker +concurrent_client_limit = 5 +# Connection timeout +connect_timeout = "20s" +# Keepalive interval +keepalive = "60s" +# Automatic reconnection interval +reconnect_interval = "5s" +# Specifies the maximum number of messages that the channel can hold simultaneously. +message_channel_capacity = 100_000 +# MQTT protocol version to use: v4, v5 corresponding to MQTT 3.1.1, 5.0 +mqtt_ver = "v5" + +# The following configurations are specific to the protocol version +# Clear session state +v4.clean_session = true +# Last will message configuration, optional +# Message encoding method, supports plain and base64, default: plain +v4.last_will = {qos = 0, retain = false, topic = "a/b/c", message = "message content", encoding = "plain"} +# Or +# Clear session state on connection +v5.clean_start = true +# Session expiry interval, 0 means the session will end immediately upon network disconnection +v5.session_expiry_interval = "0s" +# Limit the maximum number of QoS 1 and QoS 2 messages the client can handle simultaneously +v5.receive_maximum = 16 +# Negotiate the maximum packet size with the client and server +v5.maximum_packet_size = "1M" +# Negotiate the maximum number of topic aliases with the client and server +v5.topic_alias_maximum = 0 +# Last will message configuration, optional +v5.last_will = {qos = 0, retain = false, topic = "a/b/c", message = "message content", encoding = "plain"} + +[[bridges.entries]] +#Local topic filter: All messages matching this topic filter will be forwarded. +local.topic_filter = "local/topic/egress/#" + +# Choose 0, 1, 2, or not set (follow message QoS) +remote.qos = 1 +# true/false, default: false +remote.retain = false +# Topic for messages forwarded to the remote MQTT server, where ${local.topic} represents the original topic of the forwarded message. +remote.topic = "remote/topic/egress/${local.topic}" + +[[bridges.entries]] +#Local topic filter: All messages matching this topic filter will be forwarded. +local.topic_filter = "local/topic/egress/a" + +# Choose 0, 1, 2, or not set (follow message QoS) +remote.qos = 1 +# true/false, default: false +remote.retain = false +# Topic for messages forwarded to the remote MQTT server, where ${local.topic} represents the original topic of the forwarded message. +remote.topic = "remote/topic/egress/a/${local.topic}" + +[[bridges.entries]] +#Local topic filter: All messages matching this topic filter will be forwarded. +local.topic_filter = "local/topic/egress/a/#" + +# Choose 0, 1, 2, or not set (follow message QoS) +remote.qos = 1 +# true/false, default: false +remote.retain = false +# Topic for messages forwarded to the remote MQTT server, where ${local.topic} represents the original topic of the forwarded message. +remote.topic = "remote/topic/egress/a/a/${local.topic}" + + +#----------------------------------------------------------- +[[bridges]] +# Whether to enable +enable = false +# Bridge name +name = "bridge_name_2" +# Client ID prefix +client_id_prefix = "prefix" +# Address and port of the remote MQTT broker +server = "tcp://127.0.0.1:3883" +#server = "tls://127.0.0.1:9883" +##SSL / TLS Certificate Type +#CA signed server certificate +#root_cert = "./rmqtt-bin/root.pem" +##CA or Self signed certificates +#Client Certificate File +#client_cert = "./rmqtt-bin/client.pem" +#Client key file +#client_key = "./rmqtt-bin/client.key" + +# Username to connect to the remote MQTT broker +username = "rmqtt_u" +# Password to connect to the remote MQTT broker +password = "public" + +# Maximum limit of clients connected to the remote MQTT broker +concurrent_client_limit = 5 +# Connection timeout +connect_timeout = "20s" +# Keepalive interval +keepalive = "60s" +# Automatic reconnection interval +reconnect_interval = "5s" +# MQTT protocol version to use: v4, v5 corresponding to MQTT 3.1.1, 5.0 +mqtt_ver = "v4" + +# The following configurations are specific to the protocol version +# Clear session state +v4.clean_session = true + +[[bridges.entries]] +#Local topic filter: All messages matching this topic filter will be forwarded. +local.topic_filter = "local/topic/egress/#" + +# Choose 0, 1, 2, or not set (follow message QoS) +#remote.qos = 1 +# true/false, default: false +#remote.retain = false +# Topic for messages forwarded to the remote MQTT server, where ${local.topic} represents the original topic of the forwarded message. +remote.topic = "remote/topic2/egress/${local.topic}" + + + + + + diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-nats.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-nats.toml new file mode 100644 index 0000000..8671292 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-nats.toml @@ -0,0 +1,53 @@ +##-------------------------------------------------------------------- +## rmqtt-bridge-egress-nats +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/bridge-egress-nats.md + +[[bridges]] +# Whether to enable +enable = true +# Bridge name +name = "bridge_nats_1" +# The address of the NATS broker that the client will connect to using plain TCP. +# In this case, it's connecting to the local broker at port 4222. +servers = "nats://127.0.0.1:4222" +#servers = "tls://127.0.0.1:4433" + +# producer name prefix +producer_name_prefix = "producer_1" + +## See https://github.com/nats-io/nats.rs/blob/main/async-nats/src/options.rs +#no_echo = true +#ping_interval = "60s" +#connection_timeout = "10s" +#tls_required = true +#tls_first = true +#root_certificates = "" +#client_cert = "" +#client_key = "" +#sender_capacity = 256 +#auth.jwt = "" +#auth.jwt_seed = "" +#auth.nkey = "" +#auth.username = "" +#auth.password = "" +#auth.token = "" + +[[bridges.entries]] +#Local topic filter: All messages matching this topic filter will be forwarded. +local.topic_filter = "local/topic1/egress/#" + +remote.topic = "test1" +# forward all from data, including: from_type, from_node, from_ipaddress, from_clientid, from_username +#remote.forward_all_from = true +# forward all publish data, including: dup, retain, qos, packet_id, topic (required to forward), payload (required to forward) +#remote.forward_all_publish = true + +[[bridges.entries]] +#Local topic filter: All messages matching this topic filter will be forwarded. +local.topic_filter = "local/topic2/egress/#" + +remote.topic = "test2" + + diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-pulsar.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-pulsar.toml new file mode 100644 index 0000000..f08f448 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-pulsar.toml @@ -0,0 +1,75 @@ +##-------------------------------------------------------------------- +## rmqtt-bridge-egress-pulsar +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/bridge-egress-pulsar.md + +[[bridges]] +# Whether to enable +enable = true +# Bridge name +name = "bridge_pulsar_1" +# The address of the Pulsar broker that the client will connect to using plain TCP. +# In this case, it's connecting to the local broker at port 6650. +servers = "pulsar://127.0.0.1:6650" +# The address of the Pulsar broker that the client would connect to using SSL/TLS. +# Uncomment this line to enable a secure connection to the local broker at port 6651. +#servers = "pulsar+ssl://127.0.0.1:6651" + +# producer name prefix +producer_name_prefix = "producer_1" + +# add a custom certificate chain from a file to authenticate the server in TLS connections +#cert_chain_file = "./rmqtt-bin/rmqtt.fullchain.pem" +#allow insecure TLS connection if set to true, defaults to false +#allow_insecure_connection = false +#whether hostname verification is enabled when insecure TLS connection is allowed, defaults to true +#tls_hostname_verification_enabled = true + +#token(JWT, Biscuit)/ or oauth2 +#auth.name = "token" +#auth.data = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyX2lkIiwiZXhwIjoxNjI2NzY5MjAwLCJpYXQiOjE2MjY3NjU2MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" +#auth.name = "oauth2" +#auth.data = "{\"issuer_url\":\"https://example.com/oauth2/issuer\", \"credentials_url\":\"file:///path/to/credentials/file.json\"}" + +[[bridges.entries]] +#Local topic filter: All messages matching this topic filter will be forwarded. +local.topic_filter = "local/topic1/egress/#" + +remote.topic = "non-persistent://public/default/test1" +# forward all from data, including: from_type, from_node, from_ipaddress, from_clientid, from_username +#remote.forward_all_from = false +# forward all publish data, including: dup, retain, qos, packet_id, topic (required to forward), payload (required to forward) +#remote.forward_all_publish = false + +#determines the target partition of the message. Messages with the same partition_key will be sent to the same partition. +#remote.partition_key = "" + +#this affects the order of messages within a specific partition, not across partitions. If messages have the same ordering_key, they will be consumed in the order they were sent. +#Values: clientid, uuid, random or {type="random", len=10} +# clientid - use mqtt clientid +# uuid - uuid +# random - randomly generated +#remote.ordering_key = "clientid" +#remote.ordering_key = {type="random", len=10} + +#Override namespace's replication +#remote.replicate_to = [] + +#current version of the schema +#remote.schema_version = "" + +#user defined properties added to all messages +#remote.options.metadata = {} +#algorithm used to compress the messages, value: lz4,zlib,zstd,snappy +#remote.options.compression = "lz4" +#producer access mode: shared = 0, exclusive = 1, waitforexclusive = 2, exclusivewithoutfencing = 3 +#remote.options.access_mode = 0 + +[[bridges.entries]] +#Local topic filter: All messages matching this topic filter will be forwarded. +local.topic_filter = "local/topic2/egress/#" + +remote.topic = "non-persistent://public/default/test2" + + diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-reductstore.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-reductstore.toml new file mode 100644 index 0000000..0d2dce1 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-egress-reductstore.toml @@ -0,0 +1,54 @@ +##-------------------------------------------------------------------- +## rmqtt-bridge-egress-reductstore +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/bridge-egress-reductstore.md + +[[bridges]] +# Whether to enable +enable = true +# Bridge name +name = "bridge_reductstore_1" +# The address of the reductstore broker that the client will connect to using plain TCP. +# In this case, it's connecting to the local broker at port 8383. +servers = "http://127.0.0.1:8383" + +# producer name prefix +producer_name_prefix = "producer_1" + +# Set the API token to use for authentication. +#api_token = "" +# Set the timeout for HTTP requests. +#timeout = "15s" +# Set the SSL verification to false. +#verify_ssl = false + +[[bridges.entries]] +# Local topic filter: All messages matching this topic filter will be forwarded. +local.topic_filter = "local/topic1/egress/#" + +# The name of the bucket +remote.bucket = "bucket1" +remote.entry = "test1" +# Set the quota size. +remote.quota_size = 1_000_000_000 +# Don't fail if the bucket already exists. +remote.exist_ok = true +# forward all from data, including: from_type, from_node, from_ipaddress, from_clientid, from_username +remote.forward_all_from = true +# forward all publish data, including: dup, retain, qos, packet_id, topic (required to forward), payload (required to forward) +remote.forward_all_publish = true + +[[bridges.entries]] +# Local topic filter: All messages matching this topic filter will be forwarded. +local.topic_filter = "local/topic2/egress/#" + +remote.bucket = "bucket2" +remote.entry = "test2" +# Set the quota size. +remote.quota_size = 1_000_000_000 +# Don't fail if the bucket already exists. +remote.exist_ok = true + + + diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-ingress-kafka.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-ingress-kafka.toml new file mode 100644 index 0000000..9c980c0 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-ingress-kafka.toml @@ -0,0 +1,58 @@ +##-------------------------------------------------------------------- +## rmqtt-bridge-ingress-kafka +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/bridge-ingress-kafka.md + +[[bridges]] +# Whether to enable +enable = true +# Bridge name +name = "bridge_kafka_1" + +# The list of broker (server) addresses for the Kafka cluster. +#servers = "127.0.0.1:9092,127.0.0.1:9093,127.0.0.1:9094" +servers = "127.0.0.1:9092" +# client.id +client_id_prefix = "kafka_001" + +## Message expiration time, 0 means no expiration +expiry_interval = "5m" + +# See more properties and their definitions at https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md +[bridges.properties] +"message.timeout.ms" = "5000" +#"enable.auto.commit" = "false" + +[[bridges.entries]] +remote.topic = "remote-topic1-ingress" +remote.group_id = "group_id_001" +#remote.start_partition = -1 +#remote.stop_partition = -1 +# "beginning", "end", "stored" or "", "<-offset>" +#remote.offset = "beginning" + +# Choose 0, 1, 2, or not set (follow message QoS) +#local.qos = 1 +local.topic = "local/topic1/ingress/${kafka.key}" +# true/false, default: false +#local.retain = true + +[[bridges.entries]] +remote.topic = "remote-topic2-ingress" +remote.group_id = "group_id_002" +#remote.start_partition = -1 +#remote.stop_partition = -1 +# "beginning", "end", "stored" or "", "<-offset>" +#remote.offset = "beginning" + +# Choose 0, 1, 2, or not set (follow message QoS) +# local.qos = 0 +local.topic = "local/topic2/ingress" +local.retain = false + + + + + + diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-ingress-mqtt.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-ingress-mqtt.toml new file mode 100644 index 0000000..0e2236a --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-ingress-mqtt.toml @@ -0,0 +1,146 @@ +##-------------------------------------------------------------------- +## rmqtt-bridge-ingress-mqtt +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/bridge-ingress-mqtt.md + +[[bridges]] +# Whether to enable +enable = true +# Bridge name +name = "bridge_name_1" +# Client ID prefix +client_id_prefix = "prefix" +# Address and port of the remote MQTT broker +# or "tcp://127.0.0.1:1883" or "tls://127.0.0.1:8883" +server = "tcp://127.0.0.1:3883" +#server = "tls://127.0.0.1:9883" +##SSL / TLS Certificate Type +#CA signed server certificate +#root_cert = "./rmqtt-bin/root.pem" +##CA or Self signed certificates +#Client Certificate File +#client_cert = "./rmqtt-bin/client.pem" +#Client key file +#client_key = "./rmqtt-bin/client.key" + +# Username to connect to the remote MQTT broker +username = "rmqtt_u" +# Password to connect to the remote MQTT broker +password = "public" + +# Maximum limit of clients connected to the remote MQTT broker +concurrent_client_limit = 5 +# Connection timeout +connect_timeout = "20s" +# Keepalive interval +keepalive = "60s" +# Automatic reconnection interval +reconnect_interval = "5s" + +## Message expiration time, 0 means no expiration +expiry_interval = "5m" + +# MQTT protocol version to use: v4, v5 corresponding to MQTT 3.1.1, 5.0 +mqtt_ver = "v4" + +## The following configuration is related to specific protocol versions +# Clean session +v4.clean_session = true + +[[bridges.entries]] +# Choose 0, 1, 2, default: 0 +remote.qos = 1 +remote.topic = "$share/g/remote/topic1/ingress/#" + +# Choose 0, 1, 2, or not set (follow message QoS) +local.qos = 1 +local.topic = "local/topic1/ingress/${remote.topic}" +# true/false, default: false +local.retain = true + +[[bridges.entries]] +# Choose 0, 1, 2 +remote.qos = 1 +remote.topic = "$share/g/remote/topic2/ingress" + +# Choose 0, 1, 2, or not set (follow message QoS) +# local.qos = 0 +local.topic = "local/topic2/ingress" +local.retain = false + +[[bridges]] +# Whether to enable +enable = true +# Bridge name +name = "bridge_name_2" +# Client ID prefix +client_id_prefix = "prefix" +# Address and port of the remote MQTT broker +# or "tcp://127.0.0.1:1883" or "tls://127.0.0.1:8883" +server = "tcp://127.0.0.1:3883" +#server = "tls://127.0.0.1:9883" +##SSL / TLS Certificate Type +#CA signed server certificate +#root_cert = "./rmqtt-bin/root.pem" +##CA or Self signed certificates +#Client Certificate File +#client_cert = "./rmqtt-bin/client.pem" +#Client key file +#client_key = "./rmqtt-bin/client.key" + + + +# Username to connect to the remote MQTT broker +username = "rmqtt_u" +# Password to connect to the remote MQTT broker +password = "public" + +# Maximum limit of clients connected to the remote MQTT broker +concurrent_client_limit = 5 +# Connection timeout +connect_timeout = "20s" +# Keepalive interval +keepalive = "60s" +# Automatic reconnection interval +reconnect_interval = "5s" + +## Message expiration time, 0 means no expiration +expiry_interval = "5m" + +# MQTT protocol version to use: v4, v5 corresponding to MQTT 3.1.1, 5.0 +mqtt_ver = "v5" + +## The following configuration is related to specific protocol versions +# Clean start +v5.clean_start = true +# Session expiry interval, 0 means the session ends immediately after the network disconnection +v5.session_expiry_interval = "0s" +# Limit the maximum number of QoS 1 and QoS 2 messages the client can process simultaneously +v5.receive_maximum = 16 +# The maximum packet size negotiated between client and server +v5.maximum_packet_size = "1M" +# The maximum number of topic aliases negotiated between client and server +v5.topic_alias_maximum = 0 + +[[bridges.entries]] +# Choose 0, 1, 2, default: 0 +remote.qos = 0 +remote.topic = "$share/g/remote/topic3/ingress/#" + +# Choose 0, 1, 2, or not set (follow message QoS) +local.qos = 1 +local.topic = "local/topic3/ingress/${remote.topic}" +# true/false, default: false +local.retain = true + +[[bridges.entries]] +# Choose 0, 1, 2 +remote.qos = 1 +remote.topic = "$share/g/remote/topic4/ingress" + +# Choose 0, 1, 2, or not set (follow message QoS) +# local.qos = 0 +local.topic = "local/topic4/ingress" +local.retain = false + diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-ingress-pulsar.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-ingress-pulsar.toml new file mode 100644 index 0000000..555c330 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-bridge-ingress-pulsar.toml @@ -0,0 +1,216 @@ +##-------------------------------------------------------------------- +## rmqtt-bridge-ingress-pulsar +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/bridge-ingress-pulsar.md + +[[bridges]] + +## Whether to enable +## +## Value: true | false +## Default: false +enable = true + +## Bridge name +## +## Value: String +name = "bridge_pulsar_1" + +## The address of the Pulsar broker that the client will connect to using plain TCP. +## In this case, it's connecting to the local broker at port 6650. +## +## The address of the Pulsar broker that the client would connect to using SSL/TLS. +## Uncomment this line to enable a secure connection to the local broker at port 6651. +## +## Value: URL +#servers = "pulsar+ssl://127.0.0.1:6651" +servers = "pulsar://127.0.0.1:6650" + +## Consumer name prefix +## +## Value: String +consumer_name_prefix = "consumer_1" + +## Add a custom certificate chain from a file to authenticate the server in TLS connections +## +## Value: String +#cert_chain_file = "./rmqtt-bin/rmqtt.fullchain.pem" + +## Allow insecure TLS connection if set to true, defaults to false +## +## Value: true | false +## Default: false +#allow_insecure_connection = false + +## Whether hostname verification is enabled when insecure TLS connection is allowed, defaults to true +## +## Value: true | false +## Default: true +#tls_hostname_verification_enabled = true + +## Auth Configuration +## +## Value: token(JWT, Biscuit)/ or oauth2 +#auth.name = "token" +#auth.data = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyX2lkIiwiZXhwIjoxNjI2NzY5MjAwLCJpYXQiOjE2MjY3NjU2MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" +#auth.name = "oauth2" +#auth.data = "{\"issuer_url\":\"https://example.com/oauth2/issuer\", \"credentials_url\":\"file:///path/to/credentials/file.json\"}" + +## Message expiration time, 0 means no expiration +## +## Value: Duration +## Default: "5m" +expiry_interval = "5m" + +[[bridges.entries]] + +## Sets the consumer's topic or add one to the list of topics +## +## Value: String +remote.topic = "non-persistent://public/default/test" + +## Adds a list of topics to the future consumer +## +## Value: String +#remote.topics = ["non-persistent://public/default/test1", "non-persistent://public/default/test2"] + +## Sets up a consumer that will listen on all topics matching the regular expression +## +## Value: String +#remote.topic_regex = "non-persistent://public/default/.*" + +## Sets the kind of subscription +## +## Value: "exclusive", "shared", "failover", "key_shared" +#remote.subscription_type = "shared" + +## Sets the subscription's name +## +## Value: String +#remote.subscription = "" + +## Tenant/Namespace to be used when matching against a regex. For other consumers, specify namespace using the +## `//` topic format. +## +## Defaults to `public/default` if not specifid +## +## Value: String +#lookup_namespace = "" + +## Interval for refreshing the topics when using a topic regex. Unused otherwise. +## +## Value: Duration +#topic_refresh_interval = "10s" + +## Sets the consumer id for this consumer +## +## Value: u64 +#consumer_id = 1 + +## Sets the batch size +## batch messages containing more than the configured batch size will not be sent by Pulsar +## +## Value: u64 +## Default: 1000 +#batch_size = 1000 + +## Sets the dead letter policy +## +## Value: Object +#remote.dead_letter_policy = {max_redeliver_count = 10, dead_letter_topic = "test_topic"} + +## The time after which a message is dropped without being acknowledged or nacked +## that the message is resent. If `None`, messages will only be resent when a +## consumer disconnects with pending unacknowledged messages. +## +## Value: Duration +#remote.unacked_message_resend_delay = "20s" + + +### Configuration options for consumers + +## Sets the priority level +## +## Value: i32 +#remote.options.priority_level = 3 + +## Signal whether the subscription should be backed by a durable cursor or not +## +## Value: true | false +#remote.options.durable = false + +## Read compacted +## +## Value: true | false +#remote.options.read_compacted = false + +## Signal whether the subscription will initialize on latest +## or earliest message (default on latest) +## +## Value: earliest | latest +## latest - start at the most recent message +## earliest - start at the oldest message +#remote.options.initial_position = "latest" + +## User defined properties added to all messages +## +## Value: Object +#remote.options.metadata = {} + +## Payload data format +## +## Value: bytes | json +## Default: bytes +#remote.payload_format = "json" + +## Payload Path +## +## Extract the publish payload from the Pulsar message payload. This config item is only supported when +## `remote.payload_format` is set to JSON. For example: `/msg` or `/data/msg` +## +## Value: String +#remote.payload_path = "msg" + +## MQTT publish message topic, +## +## Value: String +## +## Placeholder: +## - ${remote.topic}: pulsar message topic. +## - ${remote.properties.xxxx}: user-defined properties "topic". ${remote.properties.topic} +## - ${remote.payload.xxxx}: Extract the topic from the Pulsar message payload. If the topic is an array, the message will be +## forwarded to each target topic individually. This placeholder is only supported when +## `remote.payload_format` is set to JSON. For example: `${remote.payload.topics}` +## +local.topic = "local/topic1/ingress/${remote.topic}" +#local.topics = ["local/topic1/ingress/${remote.properties.topic1}", "${remote.properties.topic2}", "${remote.payload.topic}", "${remote.payload.topics}"] + +## Choose 0, 1, 2, or not set (follow message QoS, i.e. user-defined properties "qos") +## +## Value: 0 | 1 | 2 +#local.qos = 1 + +## Choose true or false, or not set (follow message Retain, i.e. user-defined properties "retain") +## +## Value: true | false +## Default: false +#local.retain = false + +## Allow forwarding of empty messages +## +## Value: true | false +## Default: true +#local.allow_empty_forward = false + +[[bridges.entries]] + +remote.topic = "non-persistent://public/default/test9" + +local.topic = "local/topic2/ingress" +#local.qos = 0 +#local.retain = false + + + + diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-cluster-broadcast.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-cluster-broadcast.toml new file mode 100644 index 0000000..d7cd2e9 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-cluster-broadcast.toml @@ -0,0 +1,10 @@ +##-------------------------------------------------------------------- +## rmqtt-cluster-broadcast +##-------------------------------------------------------------------- + +#grpc message type +message_type = 98 +# The list of gRPC addresses for the nodes in the cluster. +# Each entry contains the node ID (e.g., 1, 2, 3) followed by the corresponding IP address and port. +# These addresses are used for inter-node communication within the cluster. +node_grpc_addrs = ["1@127.0.0.1:5363", "2@127.0.0.1:5364", "3@127.0.0.1:5365"] \ No newline at end of file diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-cluster-raft.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-cluster-raft.toml new file mode 100644 index 0000000..eea8b9d --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-cluster-raft.toml @@ -0,0 +1,65 @@ +##-------------------------------------------------------------------- +## rmqtt-cluster-raft +##-------------------------------------------------------------------- + +#grpc message type +message_type = 198 +# The list of gRPC addresses for the nodes in the cluster. +# Each entry contains the node ID (e.g., 1, 2, 3) followed by the corresponding IP address and port. +# These addresses are used for communication between the nodes using gRPC. +node_grpc_addrs = ["1@127.0.0.1:5363", "2@127.0.0.1:5364", "3@127.0.0.1:5365"] +# The list of Raft peer addresses for the nodes in the cluster. +# Each entry contains the node ID and the corresponding IP address and port for Raft consensus communication. +# These addresses are used by the Raft protocol to maintain consistency and coordination across the nodes. +raft_peer_addrs = ["1@127.0.0.1:6003", "2@127.0.0.1:6004", "3@127.0.0.1:6005"] + +#Raft cluster listening address +#If this listening address is not specified, the address of the node corresponding to `raft_peer_addrs` will be used. +#laddr = "0.0.0.0:6003" + +#Specify a leader id, when the value is 0 or not specified, the first node +#will be designated as the Leader. Default value: 0 +leader_id = 0 + +#Handshake lock timeout +try_lock_timeout = "10s" +task_exec_queue_workers = 500 +task_exec_queue_max = 100_000 + +#algorithm used to compress the snapshot, value: zstd,lz4,zlib,snappy +compression = "zstd" + +#Check the health of the node, and automatically terminate the program if the node is abnormal. +#Default value: false +health.exit_on_node_unavailable = false +#Exit code on program termination. +#Default value: -1 +health.exit_code = -1 +#When exit_on_node_unavailable is enabled, the program will terminate after a specified number of consecutive node failures. +#Default value: 2 +health.max_continuous_unavailable_count = 2 +#Cluster node unavailability check interval. +#Default value: 2 seconds +health.unavailable_check_interval = "2s" + +raft.grpc_timeout = "6s" +raft.grpc_concurrency_limit = 200 +raft.grpc_breaker_threshold = 5 +raft.grpc_breaker_retry_interval = "2500ms" +raft.proposal_batch_size = 60 +raft.proposal_batch_timeout = "200ms" +raft.snapshot_interval = "600s" +raft.heartbeat = "100ms" + +raft.election_tick = 10 +raft.heartbeat_tick = 5 +raft.max_size_per_msg = 0 +raft.max_inflight_msgs = 256 +raft.check_quorum = true +raft.pre_vote = true +raft.min_election_tick = 0 +raft.max_election_tick = 0 +raft.read_only_option = "Safe" +raft.skip_bcast_commit = false +raft.batch_append = false +raft.priority = 0 \ No newline at end of file diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-http-api.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-http-api.toml new file mode 100644 index 0000000..58838b2 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-http-api.toml @@ -0,0 +1,24 @@ +##-------------------------------------------------------------------- +## rmqtt-http-api +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/http-api.md + +##Number of worker threads +workers = 1 +## Max Row Limit +max_row_limit = 10_000 +## HTTP Listener address +http_laddr = "0.0.0.0:6060" +## Indicates whether to print HTTP request logs +http_request_log = false + +##Message expiration time, 0 means no expiration +message_expiry_interval = "5m" + +## Prometheus metrics data caching interval. +## +## Value: Duration +## Default: "5s" +prometheus_metrics_cache_interval = "5s" + diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-message-storage.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-message-storage.toml new file mode 100644 index 0000000..cbaa993 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-message-storage.toml @@ -0,0 +1,22 @@ +##-------------------------------------------------------------------- +## rmqtt-message-storage +##-------------------------------------------------------------------- + +##ram, redis, redis-cluster +storage.type = "ram" + +##ram +storage.ram.cache_capacity = "3G" +storage.ram.cache_max_count = 1_000_000 +storage.ram.encode = true + +##redis +storage.redis.url = "redis://127.0.0.1:6379/" +storage.redis.prefix = "message-{node}" + +##redis-cluster +storage.redis-cluster.urls = ["redis://127.0.0.1:6380/", "redis://127.0.0.1:6381/", "redis://127.0.0.1:6382/"] +storage.redis-cluster.prefix = "message-{node}" + +##Quantity of expired messages cleared during each cleanup cycle. +cleanup_count = 5000 diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-retainer.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-retainer.toml new file mode 100644 index 0000000..a93ffa5 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-retainer.toml @@ -0,0 +1,30 @@ +##-------------------------------------------------------------------- +## rmqtt-retainer +##-------------------------------------------------------------------- +# +# Single node mode - ram, sled, redis +# Multi-node cluster mode - redis +# + +##ram, sled, redis +storage.type = "sled" + +##sled +storage.sled.path = "/var/log/rmqtt/.cache/retain/{node}" +storage.sled.cache_capacity = "3G" + +##redis +storage.redis.url = "redis://127.0.0.1:6379/" +storage.redis.prefix = "retain" + +# The maximum number of retained messages, where 0 indicates no limit. After the number of reserved messages exceeds +# the maximum limit, existing reserved messages can be replaced, but reserved messages cannot be stored for new topics. +max_retained_messages = 0 + +# The maximum Payload value for retaining messages. After the Payload size exceeds the maximum value, the RMQTT +# message server will process the received reserved message as a regular message. +max_payload_size = "1MB" + +# TTL for retained messages. Set to 0 for no expiration. +# If not specified, the message expiration time will be used by default. +#retained_message_ttl = "0m" diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-session-storage.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-session-storage.toml new file mode 100644 index 0000000..15551ed --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-session-storage.toml @@ -0,0 +1,18 @@ +##-------------------------------------------------------------------- +## rmqtt-session-storage +##-------------------------------------------------------------------- + +##sled, redis, redis-cluster +storage.type = "sled" + +##sled +storage.sled.path = "/var/log/rmqtt/.cache/session/{node}" +storage.sled.cache_capacity = "3G" + +##redis +storage.redis.url = "redis://127.0.0.1:6379/" +storage.redis.prefix = "session-{node}" + +##redis-cluster +storage.redis-cluster.urls = ["redis://127.0.0.1:6380/", "redis://127.0.0.1:6381/", "redis://127.0.0.1:6382/"] +storage.redis-cluster.prefix = "session-{node}" diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-sys-topic.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-sys-topic.toml new file mode 100644 index 0000000..15cc4b9 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-sys-topic.toml @@ -0,0 +1,12 @@ +##-------------------------------------------------------------------- +## rmqtt-sys-topic +##-------------------------------------------------------------------- + +##$SYS system message publish QoS +publish_qos = 1 + +##$SYS system message publish period +publish_interval = "1m" + +##Message expiration time, 0 means no expiration +message_expiry_interval = "5m" \ No newline at end of file diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-topic-rewrite.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-topic-rewrite.toml new file mode 100644 index 0000000..591e6e4 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-topic-rewrite.toml @@ -0,0 +1,22 @@ +##-------------------------------------------------------------------- +## rmqtt-topic-rewrite +##-------------------------------------------------------------------- + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/topic-rewrite.md + +# action - Options are publish, subscribe, or all +# source_topic_filter - Topic filter for subscribing, unsubscribing, or publishing messages +# dest_topic - Destination topic +# regex - Regular expression + +# Expressions can use ${clientid} to represent the client ID and ${username} to represent the client username. + +rules = [ +# { action = "all", source_topic_filter = "x/+/#", dest_topic = "xx/$1/$2", regex = "^x/(.+)/(.+)$" }, +# { action = "all", source_topic_filter = "x/y/1", dest_topic = "xx/y/1" }, +# { action = "all", source_topic_filter = "x/y/#", dest_topic = "xx/y/$1", regex = "^x/y/(.+)$" }, +# { action = "all", source_topic_filter = "iot/cid/#", dest_topic = "iot/${clientid}/$1", regex = "^iot/cid/(.+)$" }, +# { action = "all", source_topic_filter = "iot/uname/#", dest_topic = "iot/${username}/$1", regex = "^iot/uname/(.+)$" }, +# { action = "all", source_topic_filter = "a/+/+/+", dest_topic = "aa/$1/$2/$3", regex = "^a/(.+)/(.+)/(.+)$" } +] + diff --git a/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-web-hook.toml b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-web-hook.toml new file mode 100644 index 0000000..e1a7206 --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt-plugins/rmqtt-web-hook.toml @@ -0,0 +1,45 @@ +##-------------------------------------------------------------------- +## rmqtt-web-hook +##-------------------------------------------------------------------- +## http +# Method: POST +# Body: +# Payload: BASE64 +## file +# None +# + +# See more keys and their definitions at https://github.com/rmqtt/rmqtt/blob/master/docs/en_US/web-hook.md + +## Hook general config +worker_threads = 3 +queue_capacity = 300_000 +concurrency_limit = 128 + +## Default urls, supports http and file protocols +#urls = ["file:///var/log/rmqtt/hook.log", "http://127.0.0.1:5656/mqtt/webhook"] +urls = ["file:///var/log/rmqtt/hook.log"] + +## Http config +http_timeout = "8s" +#If it fails, try again after approximately 2, 4, 7, 11, 18, or 42 seconds +retry_max_elapsed_time = "60s" +retry_multiplier = 2.5 + +## Hook rules config +rule.session_created = [{action = "session_created" } ] +rule.session_terminated = [{action = "session_terminated" } ] +rule.session_subscribed = [{action = "session_subscribed" } ] +rule.session_unsubscribed = [{action = "session_unsubscribed" } ] + +rule.client_connect = [{action = "client_connect"}] +rule.client_connack = [{action = "client_connack"} ] +rule.client_connected = [{action = "client_connected" } ] +rule.client_disconnected = [{action = "client_disconnected" } ] +rule.client_subscribe = [{action = "client_subscribe" } ] +rule.client_unsubscribe = [{action = "client_unsubscribe" } ] + +rule.message_publish = [{action = "message_publish", topics=["#", "$SYS/#"] }] +rule.message_delivered = [{action = "message_delivered", topics=["#", "$SYS/#"] } ] +rule.message_acked = [{action = "message_acked", topics=["#", "$SYS/#"] } ] +rule.message_dropped = [{action = "message_dropped" } ] \ No newline at end of file diff --git a/docker/rmqtt/rmqtt/rmqtt.toml b/docker/rmqtt/rmqtt/rmqtt.toml new file mode 100644 index 0000000..f64c9ed --- /dev/null +++ b/docker/rmqtt/rmqtt/rmqtt.toml @@ -0,0 +1,239 @@ +##-------------------------------------------------------------------- +## General +##-------------------------------------------------------------------- + +##-------------------------------------------------------------------- +## Task +##-------------------------------------------------------------------- +#Concurrent task count for global task executor. +task.exec_workers = 2000 +#Queue capacity for global task executor. +task.exec_queue_max = 300_000 +#Concurrent task count for global local task executor, per worker thread. +task.local_exec_workers = 50 +#Queue capacity for global local task executor, per worker thread. +task.local_exec_queue_max = 10_000 +#The rate at which messages are dequeued from the 'LocalTaskExecQueue' message queue, per worker thread. +#default value: "u32::MAX,1s" +task.local_exec_rate_limit = "1000,1s" + + +##-------------------------------------------------------------------- +## Node +##-------------------------------------------------------------------- +#Node id +node.id = 1 + +#Busy status check switch. +#default value: true +node.busy.check_enable = true +#Busy status update interval. +#default value: 2s +node.busy.update_interval = "2s" +#The threshold for the 1-minute average system load used to determine system busyness. +#Value range: 0.0-100.0, default value: 80.0 +node.busy.loadavg = 80.0 +#The threshold for average CPU load used to determine system busyness. +#Value range: 0.0-100.0, default value: 90.0 +node.busy.cpuloadavg = 90.0 +#The threshold for determining high-concurrency connection handshakes in progress. +node.busy.handshaking = 0 + +##-------------------------------------------------------------------- +## RPC +##-------------------------------------------------------------------- +#gRPC listening address +rpc.server_addr = "0.0.0.0:5363" +#Number of worker threads +rpc.server_workers = 4 +#Maximum number of messages sent in batch +rpc.batch_size = 128 +#Client concurrent request limit +rpc.client_concurrency_limit = 128 +#Connect and send to server timeout +rpc.client_timeout = "10s" + + +##-------------------------------------------------------------------- +## Log +##-------------------------------------------------------------------- +# Value: off | file | console | both +log.to = "both" +# Value: trace, debug, info, warn, error +log.level = "info" +log.dir = "/var/log/rmqtt" +log.file = "rmqtt.log" + + +##-------------------------------------------------------------------- +## Plugins +##-------------------------------------------------------------------- +#Plug in configuration file directory +plugins.dir = "rmqtt-plugins/" +#Plug in started by default, when the mqtt server is started +plugins.default_startups = [ + #"rmqtt-plugin-template", + #"rmqtt-retainer", + "rmqtt-auth-http", + #"rmqtt-cluster-broadcast", + #"rmqtt-cluster-raft", + #"rmqtt-sys-topic", + #"rmqtt-message-storage", + #"rmqtt-session-storage", + #"rmqtt-bridge-ingress-mqtt", + #"rmqtt-bridge-egress-mqtt", + #"rmqtt-bridge-ingress-kafka", + #"rmqtt-bridge-egress-kafka", + #"rmqtt-topic-rewrite", + #"rmqtt-auto-subscription", + #"rmqtt-bridge-egress-pulsar", + #"rmqtt-bridge-ingress-pulsar", + #"rmqtt-auth-jwt", + #"rmqtt-bridge-egress-nats", + #"rmqtt-bridge-egress-reductstore", + "rmqtt-web-hook", + "rmqtt-http-api" +] + + +##-------------------------------------------------------------------- +## MQTT +##-------------------------------------------------------------------- +#Delayed message send limit +mqtt.delayed_publish_max = 100_000 +#Send immediately when limit exceeded, true/false, +#true - message will be sent immediately, +#false - message will be discarded, +#default: true +mqtt.delayed_publish_immediate = true + +#Maximum session limit, 0: no limit, default value: 0. +mqtt.max_sessions = 0 + + +##-------------------------------------------------------------------- +## Listeners +##-------------------------------------------------------------------- + +##-------------------------------------------------------------------- +## MQTT/TCP - External TCP Listener for MQTT Protocol +listener.tcp.external.addr = "0.0.0.0:1883" +#Number of worker threads +listener.tcp.external.workers = 8 +#The maximum number of concurrent connections allowed by the listener. +listener.tcp.external.max_connections = 1024000 +#Maximum concurrent handshake limit, Default: 500 +listener.tcp.external.max_handshaking_limit = 500 +#Handshake timeout. +listener.tcp.external.handshake_timeout = "30s" +#Maximum allowed mqtt message length. 0 means unlimited, default: 1m +listener.tcp.external.max_packet_size = "1m" +#The maximum length of the TCP connection queue. +#It indicates the maximum number of TCP connection queues that are being handshaked three times in the system +listener.tcp.external.backlog = 1024 +#Whether anonymous login is allowed. Default: false +listener.tcp.external.allow_anonymous = false +#A value of zero indicates disabling the keep-alive feature, where the server +#doesn't need to disconnect due to client inactivity, default: true +listener.tcp.external.allow_zero_keepalive = true +#Minimum allowable keepalive value for mqtt connection, +#less than this value will reject the connection(MQTT V3), +#less than this value will set keepalive to this value in CONNACK (MQTT V5), +#default: 0, unit: seconds +listener.tcp.external.min_keepalive = 0 +#Maximum allowable keepalive value for mqtt connection, +#greater than this value will reject the connection(MQTT V3), +#greater than this value will set keepalive to this value in CONNACK (MQTT V5), +#default value: 65535, unit: seconds +listener.tcp.external.max_keepalive = 65535 +# > 0.5, Keepalive * backoff * 2 +listener.tcp.external.keepalive_backoff = 0.75 +#Flight window size. The flight window is used to store the unanswered QoS 1 and QoS 2 messages +listener.tcp.external.max_inflight = 16 +#Maximum length of message queue +listener.tcp.external.max_mqueue_len = 1000 +#The rate at which messages are ejected from the message queue, +#default value: "u32::max_value(),1s" +listener.tcp.external.mqueue_rate_limit = "1000,1s" +#Maximum length of client ID allowed, Default: 65535 +listener.tcp.external.max_clientid_len = 65535 +#The maximum QoS level that clients are allowed to publish. default value: 2 +listener.tcp.external.max_qos_allowed = 2 +#The maximum level at which clients are allowed to subscribe to topics. +#0 means unlimited. default value: 0 +listener.tcp.external.max_topic_levels = 0 +#Session timeout, default value: 2 hours +listener.tcp.external.session_expiry_interval = "2h" +#QoS 1/2 message retry interval, 0 means no resend +listener.tcp.external.message_retry_interval = "20s" +#Message expiration time, 0 means no expiration, default value: 5 minutes +listener.tcp.external.message_expiry_interval = "5m" +#The maximum number of topics that a single client is allowed to subscribe to +#0 means unlimited, default value: 0 +listener.tcp.external.max_subscriptions = 0 +#Shared subscription switch, default value: true +listener.tcp.external.shared_subscription = true +#topic alias maximum, default value: 0, topic aliases not enabled. (MQTT 5.0) +listener.tcp.external.max_topic_aliases = 32 +#Limit subscription switch, default value: false +listener.tcp.external.limit_subscription = false +#Delayed publish switch, default value: false +listener.tcp.external.delayed_publish = false + +##-------------------------------------------------------------------- +## MQTT/TCP - Internal TCP Listener for MQTT Protocol +listener.tcp.internal.enable = true +listener.tcp.internal.addr = "0.0.0.0:11883" +listener.tcp.internal.workers = 4 +listener.tcp.internal.max_connections = 102400 +listener.tcp.internal.max_handshaking_limit = 500 +listener.tcp.internal.handshake_timeout = "30s" +listener.tcp.internal.max_packet_size = "1M" +listener.tcp.internal.backlog = 512 +listener.tcp.internal.allow_anonymous = false +listener.tcp.internal.allow_zero_keepalive = true +listener.tcp.internal.min_keepalive = 0 +listener.tcp.internal.max_keepalive = 65535 +listener.tcp.internal.keepalive_backoff = 0.75 +listener.tcp.internal.max_inflight = 128 +listener.tcp.internal.max_mqueue_len = 1000 +listener.tcp.internal.mqueue_rate_limit = "5000,1s" +listener.tcp.internal.max_clientid_len = 65535 +listener.tcp.internal.max_qos_allowed = 2 +listener.tcp.internal.max_topic_levels = 0 +listener.tcp.internal.session_expiry_interval = "2h" +listener.tcp.internal.message_retry_interval = "30s" +listener.tcp.internal.message_expiry_interval = "5m" +listener.tcp.internal.max_subscriptions = 0 +listener.tcp.internal.shared_subscription = true +listener.tcp.internal.max_topic_aliases = 0 +listener.tcp.internal.limit_subscription = false + +##-------------------------------------------------------------------- +## MQTT/TLS - External TLS Listener for MQTT Protocol, (TLSv1.2) +listener.tls.external.addr = "0.0.0.0:8883" +#Whether to enable cross-certification, default value: false +listener.tls.external.cross_certificate = false +#This certificate is used to authenticate the server during TLS handshakes. +listener.tls.external.cert = "./rmqtt-bin/rmqtt.pem" +#This key is used to establish a secure connection with the client. +listener.tls.external.key = "./rmqtt-bin/rmqtt.key" + +#The following is the configuration using cross-certification +#listener.tls.external.cross_certificate = true +#listener.tls.external.cert = "./rmqtt-bin/rmqtt.fullchain.pem" +#listener.tls.external.key = "./rmqtt-bin/rmqtt.key" + +##-------------------------------------------------------------------- +## MQTT/WebSocket - External WebSocket Listener for MQTT Protocol +listener.ws.external.addr = "0.0.0.0:8080" + +##-------------------------------------------------------------------- +## MQTT/TLS-WebSocket - External TLS-WebSocket Listener for MQTT Protocol, (TLSv1.2) +listener.wss.external.addr = "0.0.0.0:8443" +listener.wss.external.cross_certificate = false +listener.wss.external.cert = "./rmqtt-bin/rmqtt.pem" +listener.wss.external.key = "./rmqtt-bin/rmqtt.key" +#listener.wss.external.cross_certificate = true +#listener.wss.external.cert = "./rmqtt-bin/rmqtt.fullchain.pem" +#listener.wss.external.key = "./rmqtt-bin/rmqtt.key" diff --git a/nhmesh-mqtt-auth/Cargo.lock b/nhmesh-mqtt-auth/Cargo.lock index e8ddf8b..a77b198 100644 --- a/nhmesh-mqtt-auth/Cargo.lock +++ b/nhmesh-mqtt-auth/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ "mime", "percent-encoding", "pin-project-lite", - "rand", + "rand 0.9.1", "sha1", "smallvec", "tokio", @@ -65,7 +65,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn", + "syn 2.0.101", ] [[package]] @@ -182,7 +182,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn", + "syn 2.0.101", ] [[package]] @@ -200,6 +200,17 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom 0.2.16", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -209,6 +220,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "aliasable" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" + [[package]] name = "alloc-no-stdlib" version = "2.0.4" @@ -224,12 +241,255 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +dependencies = [ + "anstyle", + "once_cell", + "windows-sys 0.59.0", +] + +[[package]] +name = "anyhow" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" + +[[package]] +name = "argon2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072" +dependencies = [ + "base64ct", + "blake2", + "cpufeatures", + "password-hash", +] + [[package]] name = "arraydeque" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "async-attributes" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "async-channel" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +dependencies = [ + "concurrent-queue", + "event-listener 2.5.3", + "futures-core", +] + +[[package]] +name = "async-channel" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb812ffb58524bdd10860d7d974e2f01cc0950c2438a74ee5ec2e2280c6c4ffa" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" +dependencies = [ + "async-channel 2.3.1", + "async-executor", + "async-io", + "async-lock", + "blocking", + "futures-lite", + "once_cell", + "tokio", +] + +[[package]] +name = "async-io" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" +dependencies = [ + "async-lock", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix 0.38.44", + "slab", + "tracing", + "windows-sys 0.59.0", +] + +[[package]] +name = "async-lock" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" +dependencies = [ + "event-listener 5.4.0", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-std" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "730294c1c08c2e0f85759590518f6333f0d5a0a766a27d519c1b244c3dfd8a24" +dependencies = [ + "async-attributes", + "async-channel 1.9.0", + "async-global-executor", + "async-io", + "async-lock", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + [[package]] name = "async-trait" version = "0.1.88" @@ -238,7 +498,16 @@ checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", ] [[package]] @@ -280,6 +549,26 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64ct" +version = "1.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89e25b6adfb930f02d1981565a6e5d9c547ac15a96606256d3b59040e5cd4ca3" + +[[package]] +name = "bigdecimal" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a22f228ab7a1b23027ccc6c350b72868017af7ea8356fbdf19f8d991c690013" +dependencies = [ + "autocfg", + "libm", + "num-bigint", + "num-integer", + "num-traits", + "serde", +] + [[package]] name = "bitflags" version = "2.9.0" @@ -289,6 +578,27 @@ dependencies = [ "serde", ] +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -298,6 +608,42 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blocking" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" +dependencies = [ + "async-channel 2.3.1", + "async-task", + "futures-io", + "futures-lite", + "piper", +] + +[[package]] +name = "borsh" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8646f98db542e39fc66e68a20b2144f6a732636df7c2354e74645faaa433ce" +dependencies = [ + "borsh-derive", + "cfg_aliases", +] + +[[package]] +name = "borsh-derive" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdd1d3c0c2f5833f22386f252fe8ed005c7f59fdcddeef025c01b4c3b9fd9ac3" +dependencies = [ + "once_cell", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.101", +] + [[package]] name = "brotli" version = "7.0.0" @@ -325,6 +671,34 @@ version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +[[package]] +name = "bytecheck" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "bytes" version = "1.10.1" @@ -358,67 +732,147 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "config" -version = "0.15.11" +name = "cfg_aliases" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "595aae20e65c3be792d05818e8c63025294ac3cb7e200f11459063a352a6ef80" -dependencies = [ - "async-trait", - "convert_case", - "json5", - "pathdiff", - "ron", - "rust-ini", - "serde", - "serde_json", - "toml", - "winnow", - "yaml-rust2", -] +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] -name = "const-random" -version = "0.1.18" +name = "chrono" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" dependencies = [ - "const-random-macro", + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "windows-link", ] [[package]] -name = "const-random-macro" -version = "0.1.16" +name = "clap" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" dependencies = [ - "getrandom 0.2.16", - "once_cell", - "tiny-keccak", + "clap_builder", + "clap_derive", ] [[package]] -name = "convert_case" -version = "0.6.0" +name = "clap_builder" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" dependencies = [ - "unicode-segmentation", + "anstream", + "anstyle", + "clap_lex", + "strsim", ] [[package]] -name = "cookie" -version = "0.16.2" +name = "clap_derive" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" +checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" dependencies = [ - "percent-encoding", - "time", - "version_check", + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.101", ] [[package]] -name = "core-foundation" -version = "0.9.4" +name = "clap_lex" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "config" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595aae20e65c3be792d05818e8c63025294ac3cb7e200f11459063a352a6ef80" +dependencies = [ + "async-trait", + "convert_case", + "json5", + "pathdiff", + "ron", + "rust-ini", + "serde", + "serde_json", + "toml", + "winnow", + "yaml-rust2", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.16", + "once_cell", + "tiny-keccak", +] + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "cookie" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ @@ -441,6 +895,21 @@ dependencies = [ "libc", ] +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32fast" version = "1.4.2" @@ -450,6 +919,21 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-queue" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + [[package]] name = "crunchy" version = "0.2.3" @@ -466,6 +950,51 @@ dependencies = [ "typenum", ] +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "deranged" version = "0.4.0" @@ -473,6 +1002,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -492,7 +1022,7 @@ checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", "unicode-xid", ] @@ -503,7 +1033,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", + "subtle", ] [[package]] @@ -514,7 +1046,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", ] [[package]] @@ -526,6 +1058,21 @@ dependencies = [ "const-random", ] +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +dependencies = [ + "serde", +] + [[package]] name = "encoding_rs" version = "0.8.35" @@ -535,6 +1082,14 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "entity" +version = "0.1.0" +dependencies = [ + "sea-orm", + "serde", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -551,6 +1106,44 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "event-listener" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener 5.4.0", + "pin-project-lite", +] + [[package]] name = "fastrand" version = "2.3.0" @@ -567,6 +1160,17 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "flume" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" +dependencies = [ + "futures-core", + "futures-sink", + "spin", +] + [[package]] name = "fnv" version = "1.0.7" @@ -603,6 +1207,27 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.31" @@ -610,6 +1235,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -618,6 +1244,58 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-lite" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + [[package]] name = "futures-sink" version = "0.3.31" @@ -636,10 +1314,16 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ + "futures-channel", "futures-core", + "futures-io", + "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -681,6 +1365,24 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +[[package]] +name = "glob" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" + +[[package]] +name = "gloo-timers" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "h2" version = "0.3.26" @@ -719,6 +1421,15 @@ dependencies = [ "tracing", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + [[package]] name = "hashbrown" version = "0.14.5" @@ -731,6 +1442,8 @@ version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" dependencies = [ + "allocator-api2", + "equivalent", "foldhash", ] @@ -744,23 +1457,74 @@ dependencies = [ ] [[package]] -name = "http" -version = "0.2.12" +name = "heck" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" -dependencies = [ - "bytes", - "fnv", - "itoa", -] +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] -name = "http" -version = "1.3.1" +name = "heck" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" -dependencies = [ - "bytes", +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +dependencies = [ + "bytes", "fnv", "itoa", ] @@ -873,6 +1637,30 @@ dependencies = [ "tracing", ] +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "icu_collections" version = "1.5.0" @@ -988,9 +1776,15 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "1.0.3" @@ -1028,12 +1822,29 @@ dependencies = [ "hashbrown 0.15.3", ] +[[package]] +name = "inherent" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c38228f24186d9cc68c729accb4d413be9eaed6ad07ff79e0270d9e56f3de13" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + [[package]] name = "ipnet" version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itoa" version = "1.0.15" @@ -1071,6 +1882,15 @@ dependencies = [ "serde", ] +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + [[package]] name = "language-tags" version = "0.3.2" @@ -1082,6 +1902,9 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] [[package]] name = "libc" @@ -1089,6 +1912,29 @@ version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" +[[package]] +name = "libm" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9627da5196e5d8ed0b0495e61e518847578da83483c37288316d9b2e03a7f72" + +[[package]] +name = "libsqlite3-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + [[package]] name = "linux-raw-sys" version = "0.9.4" @@ -1133,6 +1979,9 @@ name = "log" version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +dependencies = [ + "value-bag", +] [[package]] name = "matchers" @@ -1143,12 +1992,30 @@ dependencies = [ "regex-automata 0.1.10", ] +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "migration" +version = "0.1.0" +dependencies = [ + "async-std", + "sea-orm-migration", +] + [[package]] name = "mime" version = "0.3.17" @@ -1198,14 +2065,22 @@ name = "nhmesh-mqtt-auth" version = "0.1.0" dependencies = [ "actix-web", + "anyhow", + "argon2", "config", + "entity", + "futures", + "migration", + "once_cell", "reqwest", + "secrecy", "serde", "serde_json", "tokio", "tracing", "tracing-log 0.1.4", "tracing-subscriber", + "uuid", ] [[package]] @@ -1218,12 +2093,69 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand 0.8.5", + "smallvec", + "zeroize", +] + [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + [[package]] name = "object" version = "0.36.7" @@ -1262,7 +2194,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", ] [[package]] @@ -1283,6 +2215,15 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "ordered-float" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" +dependencies = [ + "num-traits", +] + [[package]] name = "ordered-multimap" version = "0.7.3" @@ -1293,12 +2234,42 @@ dependencies = [ "hashbrown 0.14.5", ] +[[package]] +name = "ouroboros" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0f050db9c44b97a94723127e6be766ac5c340c48f2c4bb3ffa11713744be59" +dependencies = [ + "aliasable", + "ouroboros_macro", + "static_assertions", +] + +[[package]] +name = "ouroboros_macro" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c7028bdd3d43083f6d8d4d5187680d0d3560d54df4cc9d752005268b41e64d0" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn 2.0.101", +] + [[package]] name = "overload" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + [[package]] name = "parking_lot" version = "0.12.3" @@ -1322,12 +2293,32 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "password-hash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" +dependencies = [ + "base64ct", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "pathdiff" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -1365,7 +2356,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn", + "syn 2.0.101", ] [[package]] @@ -1379,6 +2370,15 @@ dependencies = [ "sha2", ] +[[package]] +name = "pgvector" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0e8871b6d7ca78348c6cd29b911b94851f3429f0cd403130ca17f26c1fb91a6" +dependencies = [ + "serde", +] + [[package]] name = "pin-project-lite" version = "0.2.16" @@ -1391,12 +2391,59 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +[[package]] +name = "polling" +version = "3.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix 0.38.44", + "tracing", + "windows-sys 0.59.0", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -1413,71 +2460,171 @@ dependencies = [ ] [[package]] -name = "proc-macro2" -version = "1.0.95" +name = "proc-macro-crate" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" dependencies = [ - "unicode-ident", + "toml_edit", ] [[package]] -name = "quote" -version = "1.0.40" +name = "proc-macro-error-attr2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" dependencies = [ "proc-macro2", + "quote", ] [[package]] -name = "r-efi" -version = "5.2.0" +name = "proc-macro-error2" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn 2.0.101", +] [[package]] -name = "rand" -version = "0.9.1" +name = "proc-macro2" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ - "rand_chacha", - "rand_core", + "unicode-ident", ] [[package]] -name = "rand_chacha" -version = "0.9.0" +name = "proc-macro2-diagnostics" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ - "ppv-lite86", - "rand_core", + "proc-macro2", + "quote", + "syn 2.0.101", + "version_check", + "yansi", ] [[package]] -name = "rand_core" -version = "0.9.3" +name = "ptr_meta" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" dependencies = [ - "getrandom 0.3.2", + "ptr_meta_derive", ] [[package]] -name = "redox_syscall" -version = "0.5.11" +name = "ptr_meta_derive" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ - "bitflags", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] -name = "regex" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.16", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", @@ -1524,6 +2671,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "rend" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +dependencies = [ + "bytecheck", +] + [[package]] name = "reqwest" version = "0.12.15" @@ -1582,6 +2738,35 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rkyv" +version = "0.7.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9008cd6385b9e161d8229e1f6549dd23c3d022f132a2ea37ac3a10ac4935779b" +dependencies = [ + "bitvec", + "bytecheck", + "bytes", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "503d1d27590a2b0a3a4ca4c94755aa2875657196ecbf401a42eff41d7de532c0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "ron" version = "0.8.1" @@ -1594,6 +2779,26 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "rsa" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "signature", + "spki", + "subtle", + "zeroize", +] + [[package]] name = "rust-ini" version = "0.21.1" @@ -1605,12 +2810,41 @@ dependencies = [ "trim-in-place", ] +[[package]] +name = "rust_decimal" +version = "1.37.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faa7de2ba56ac291bd90c6b9bece784a52ae1411f9506544b3eae36dd2356d50" +dependencies = [ + "arrayvec", + "borsh", + "bytes", + "num-traits", + "rand 0.8.5", + "rkyv", + "serde", + "serde_json", +] + [[package]] name = "rustc-demangle" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + [[package]] name = "rustix" version = "1.0.7" @@ -1620,7 +2854,7 @@ dependencies = [ "bitflags", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.9.4", "windows-sys 0.59.0", ] @@ -1631,6 +2865,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df51b5869f3a441595eac5e8ff14d486ff285f7b8c0df8770e49c3b56351f0f0" dependencies = [ "once_cell", + "ring", "rustls-pki-types", "rustls-webpki", "subtle", @@ -1690,6 +2925,181 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sea-bae" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f694a6ab48f14bc063cfadff30ab551d3c7e46d8f81836c51989d548f44a2a25" +dependencies = [ + "heck 0.4.1", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "sea-orm" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21e61af841881c137d4bc8e0d8411cee9168548b404f9e4788e8af7e8f94bd4e" +dependencies = [ + "async-stream", + "async-trait", + "bigdecimal", + "chrono", + "futures-util", + "log", + "ouroboros", + "pgvector", + "rust_decimal", + "sea-orm-macros", + "sea-query", + "sea-query-binder", + "serde", + "serde_json", + "sqlx", + "strum", + "thiserror", + "time", + "tracing", + "url", + "uuid", +] + +[[package]] +name = "sea-orm-cli" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3d39b35e43a05998228f6c4abaa50b7fcaf001dea94fbdc04188a8be82a016" +dependencies = [ + "chrono", + "clap", + "dotenvy", + "glob", + "regex", + "sea-schema", + "tracing", + "tracing-subscriber", + "url", +] + +[[package]] +name = "sea-orm-macros" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6b86e3e77b548e6c6c1f612a1ca024d557dffdb81b838bf482ad3222140c77b" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "sea-bae", + "syn 2.0.101", + "unicode-ident", +] + +[[package]] +name = "sea-orm-migration" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae8b2af58a56c8f850e8d8a18a462255eb36a571f085f3405f6b83d9cf23e0f" +dependencies = [ + "async-trait", + "clap", + "dotenvy", + "sea-orm", + "sea-orm-cli", + "sea-schema", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "sea-query" +version = "0.32.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d99447c24da0cded00089e2021e1624af90878c65f7534319448d01da3df869d" +dependencies = [ + "bigdecimal", + "chrono", + "inherent", + "ordered-float", + "rust_decimal", + "sea-query-derive", + "serde_json", + "time", + "uuid", +] + +[[package]] +name = "sea-query-binder" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0019f47430f7995af63deda77e238c17323359af241233ec768aba1faea7608" +dependencies = [ + "bigdecimal", + "chrono", + "rust_decimal", + "sea-query", + "serde_json", + "sqlx", + "time", + "uuid", +] + +[[package]] +name = "sea-query-derive" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bae0cbad6ab996955664982739354128c58d16e126114fe88c2a493642502aab" +dependencies = [ + "darling", + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.101", + "thiserror", +] + +[[package]] +name = "sea-schema" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef5dd7848c993f3789d09a2616484c72c9330cae2b048df59d8c9b8c0343e95" +dependencies = [ + "futures", + "sea-query", + "sea-schema-derive", +] + +[[package]] +name = "sea-schema-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "debdc8729c37fdbf88472f97fd470393089f997a909e535ff67c544d18cfccf0" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "secrecy" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e891af845473308773346dc847b2c23ee78fe442e0472ac50e22a18a93d3ae5a" +dependencies = [ + "serde", + "zeroize", +] + [[package]] name = "security-framework" version = "2.11.1" @@ -1730,7 +3140,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", ] [[package]] @@ -1767,81 +3177,358 @@ dependencies = [ ] [[package]] -name = "sha1" -version = "0.10.6" +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core 0.6.4", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" +dependencies = [ + "serde", +] + +[[package]] +name = "socket2" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "sqlx" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c3a85280daca669cfd3bcb68a337882a8bc57ec882f72c5d13a430613a738e" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f743f2a3cea30a58cd479013f75550e879009e3a02f616f18ca699335aa248c3" +dependencies = [ + "base64 0.22.1", + "bigdecimal", + "bytes", + "chrono", + "crc", + "crossbeam-queue", + "either", + "event-listener 5.4.0", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashbrown 0.15.3", + "hashlink", + "indexmap", + "log", + "memchr", + "once_cell", + "percent-encoding", + "rust_decimal", + "rustls", + "serde", + "serde_json", + "sha2", + "smallvec", + "thiserror", + "time", + "tokio", + "tokio-stream", + "tracing", + "url", + "uuid", + "webpki-roots", +] + +[[package]] +name = "sqlx-macros" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4200e0fde19834956d4252347c12a083bdcb237d7a1a1446bffd8768417dce" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 2.0.101", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882ceaa29cade31beca7129b6beeb05737f44f82dbe2a9806ecea5a7093d00b7" +dependencies = [ + "dotenvy", + "either", + "heck 0.5.0", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn 2.0.101", + "tempfile", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +checksum = "0afdd3aa7a629683c2d750c2df343025545087081ab5942593a5288855b1b7a7" dependencies = [ - "cfg-if", - "cpufeatures", + "atoi", + "base64 0.22.1", + "bigdecimal", + "bitflags", + "byteorder", + "bytes", + "chrono", + "crc", "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand 0.8.5", + "rsa", + "rust_decimal", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "time", + "tracing", + "uuid", + "whoami", ] [[package]] -name = "sha2" -version = "0.10.9" +name = "sqlx-postgres" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +checksum = "a0bedbe1bbb5e2615ef347a5e9d8cd7680fb63e77d9dafc0f29be15e53f1ebe6" dependencies = [ - "cfg-if", - "cpufeatures", - "digest", + "atoi", + "base64 0.22.1", + "bigdecimal", + "bitflags", + "byteorder", + "chrono", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "num-bigint", + "once_cell", + "rand 0.8.5", + "rust_decimal", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "time", + "tracing", + "uuid", + "whoami", ] [[package]] -name = "sharded-slab" -version = "0.1.7" +name = "sqlx-sqlite" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +checksum = "c26083e9a520e8eb87a06b12347679b142dc2ea29e6e409f805644a7a979a5bc" dependencies = [ - "lazy_static", + "atoi", + "chrono", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "serde_urlencoded", + "sqlx-core", + "thiserror", + "time", + "tracing", + "url", + "uuid", ] [[package]] -name = "shlex" -version = "1.3.0" +name = "stable_deref_trait" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] -name = "signal-hook-registry" -version = "1.4.5" +name = "static_assertions" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" -dependencies = [ - "libc", -] +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] -name = "slab" -version = "0.4.9" +name = "stringprep" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" dependencies = [ - "autocfg", + "unicode-bidi", + "unicode-normalization", + "unicode-properties", ] [[package]] -name = "smallvec" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" - -[[package]] -name = "socket2" -version = "0.5.9" +name = "strsim" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] -name = "stable_deref_trait" -version = "1.2.0" +name = "strum" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" [[package]] name = "subtle" @@ -1849,6 +3536,17 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.101" @@ -1877,7 +3575,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", ] [[package]] @@ -1901,6 +3599,12 @@ dependencies = [ "libc", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "tempfile" version = "3.19.1" @@ -1910,7 +3614,7 @@ dependencies = [ "fastrand", "getrandom 0.3.2", "once_cell", - "rustix", + "rustix 1.0.7", "windows-sys 0.59.0", ] @@ -1931,7 +3635,7 @@ checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", ] [[package]] @@ -1994,6 +3698,21 @@ dependencies = [ "zerovec", ] +[[package]] +name = "tinyvec" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.44.2" @@ -2020,7 +3739,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", ] [[package]] @@ -2043,6 +3762,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-stream" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.15" @@ -2137,7 +3867,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", ] [[package]] @@ -2214,12 +3944,33 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + [[package]] name = "unicode-ident" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +[[package]] +name = "unicode-normalization" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-properties" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" + [[package]] name = "unicode-segmentation" version = "1.12.0" @@ -2261,12 +4012,34 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "uuid" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" +dependencies = [ + "getrandom 0.3.2", + "serde", +] + [[package]] name = "valuable" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "value-bag" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "943ce29a8a743eb10d6082545d861b24f9d1b160b7d741e0f2cdf726bec909c5" + [[package]] name = "vcpkg" version = "0.2.15" @@ -2303,6 +4076,12 @@ dependencies = [ "wit-bindgen-rt", ] +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" + [[package]] name = "wasm-bindgen" version = "0.2.100" @@ -2325,7 +4104,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn", + "syn 2.0.101", "wasm-bindgen-shared", ] @@ -2360,7 +4139,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2384,6 +4163,25 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.26.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37493cadf42a2a939ed404698ded7fb378bf301b5011f973361779a3a74f8c93" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "whoami" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6994d13118ab492c3c80c1f81928718159254c53c472bf9ce36f8dae4add02a7" +dependencies = [ + "redox_syscall", + "wasite", +] + [[package]] name = "winapi" version = "0.3.9" @@ -2406,6 +4204,41 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings 0.4.0", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + [[package]] name = "windows-link" version = "0.1.1" @@ -2419,7 +4252,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" dependencies = [ "windows-result", - "windows-strings", + "windows-strings 0.3.1", "windows-targets 0.53.0", ] @@ -2441,6 +4274,24 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-strings" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" +dependencies = [ + "windows-link", +] + +[[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]] name = "windows-sys" version = "0.52.0" @@ -2459,6 +4310,21 @@ 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]] name = "windows-targets" version = "0.52.6" @@ -2491,6 +4357,12 @@ dependencies = [ "windows_x86_64_msvc 0.53.0", ] +[[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" @@ -2503,6 +4375,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +[[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" @@ -2515,6 +4393,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +[[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" @@ -2539,6 +4423,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +[[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" @@ -2551,6 +4441,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +[[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" @@ -2563,6 +4459,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +[[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" @@ -2575,6 +4477,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +[[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" @@ -2617,6 +4525,15 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "yaml-rust2" version = "0.10.1" @@ -2628,6 +4545,12 @@ dependencies = [ "hashlink", ] +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + [[package]] name = "yoke" version = "0.7.5" @@ -2648,7 +4571,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", "synstructure", ] @@ -2669,7 +4592,7 @@ checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", ] [[package]] @@ -2689,7 +4612,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", "synstructure", ] @@ -2718,7 +4641,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", ] [[package]] diff --git a/nhmesh-mqtt-auth/Cargo.toml b/nhmesh-mqtt-auth/Cargo.toml index 40ab013..cf906d5 100644 --- a/nhmesh-mqtt-auth/Cargo.toml +++ b/nhmesh-mqtt-auth/Cargo.toml @@ -1,25 +1,2 @@ -[package] -name = "nhmesh-mqtt-auth" -version = "0.1.0" -edition = "2024" - -[lib] -name = "nhmesh_mqtt_auth" -path = "src/lib.rs" - -[[bin]] -name = "nhmesh-mqtt-auth" -path = "src/main.rs" - -[dependencies] -actix-web = "4" -tokio = { version = "1", features = ["macros", "rt-multi-thread"] } -serde_json = "1" -serde = { version = "1", features = ["derive"] } -config = { version = "0.15", features = ["yaml"] } -tracing = { version = "0.1", features = ["log"] } -tracing-subscriber = { version = "0.3", features = ["env-filter", "registry"] } -tracing-log = "0.1" - -[dev-dependencies] -reqwest = { version = "0.12", features = ["json"] } +[workspace] +members = ["api", "entity", "migration"] diff --git a/nhmesh-mqtt-auth/api/Cargo.toml b/nhmesh-mqtt-auth/api/Cargo.toml new file mode 100644 index 0000000..aae646c --- /dev/null +++ b/nhmesh-mqtt-auth/api/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "nhmesh-mqtt-auth" +version = "0.1.0" +edition = "2024" + +[lib] +name = "nhmesh_mqtt_auth" +path = "src/lib.rs" + +[[bin]] +name = "nhmesh-mqtt-auth" +path = "src/main.rs" + +[dependencies] +actix-web = "4" +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } +serde_json = "1" +serde = { version = "1", features = ["derive"] } +config = { version = "0.15", features = ["yaml"] } +tracing = { version = "0.1", features = ["log"] } +tracing-subscriber = { version = "0.3", features = ["env-filter", "registry"] } +tracing-log = "0.1" +secrecy = { version = "0.10", features = ["serde"] } +entity = { path = "../entity" } +migration = { path = "../migration" } +argon2 = { version = "0.5", features = ["std"] } +anyhow = "1" +futures = "0.3" +uuid = { version = "1", features = ["v4"] } + +[dev-dependencies] +reqwest = { version = "0.12", features = ["json"] } +once_cell = "1" diff --git a/nhmesh-mqtt-auth/src/config.rs b/nhmesh-mqtt-auth/api/src/config.rs similarity index 68% rename from nhmesh-mqtt-auth/src/config.rs rename to nhmesh-mqtt-auth/api/src/config.rs index d8ce695..d8d03ac 100644 --- a/nhmesh-mqtt-auth/src/config.rs +++ b/nhmesh-mqtt-auth/api/src/config.rs @@ -1,9 +1,10 @@ use config::Config; use serde::Deserialize; -#[derive(Debug, Deserialize)] +#[derive(Debug, Deserialize, Default)] pub struct Settings { pub app: AppConfig, + pub database: DatabaseConfig, } #[derive(Debug, Deserialize)] @@ -21,6 +22,19 @@ impl Default for AppConfig { } } +#[derive(Debug, Deserialize)] +pub struct DatabaseConfig { + pub url: String, +} + +impl Default for DatabaseConfig { + fn default() -> Self { + Self { + url: "sqlite://auth-db.sqlite?mode=rwc".to_string(), + } + } +} + pub fn get_config() -> Result { let config = Config::builder() .add_source(config::File::with_name("config.yaml").format(config::FileFormat::Yaml)) diff --git a/nhmesh-mqtt-auth/api/src/lib.rs b/nhmesh-mqtt-auth/api/src/lib.rs new file mode 100644 index 0000000..5de2f84 --- /dev/null +++ b/nhmesh-mqtt-auth/api/src/lib.rs @@ -0,0 +1,29 @@ +use actix_web::dev::Server; +use actix_web::{App, HttpServer, web}; +use std::net::TcpListener; +use entity::sea_orm::DatabaseConnection; + +mod config; +mod models; +mod routes; + +pub use config::*; + +#[derive(Clone, Debug)] +pub(crate)struct AppState { + db: DatabaseConnection, +} + +pub fn run(listener: TcpListener, db: DatabaseConnection) -> Result { + let server = HttpServer::new(move || { + App::new() + .app_data(web::Data::new(AppState { db: db.clone() })) + .service(routes::health) + .service(routes::mqtt_auth) + .service(routes::create_new_user) + }) + .listen(listener)? + .run(); + + Ok(server) +} diff --git a/nhmesh-mqtt-auth/src/main.rs b/nhmesh-mqtt-auth/api/src/main.rs similarity index 61% rename from nhmesh-mqtt-auth/src/main.rs rename to nhmesh-mqtt-auth/api/src/main.rs index 3afad01..4e955a9 100644 --- a/nhmesh-mqtt-auth/src/main.rs +++ b/nhmesh-mqtt-auth/api/src/main.rs @@ -2,16 +2,22 @@ use nhmesh_mqtt_auth::{get_config, run}; use std::net::TcpListener; use tracing_log::LogTracer; use tracing_subscriber::{EnvFilter, Registry, fmt, layer::SubscriberExt}; +use entity::sea_orm::Database; +use migration::{Migrator, MigratorTrait}; +use anyhow::{Result, Context}; #[tokio::main] -async fn main() -> Result<(), std::io::Error> { +async fn main() -> Result<()> { LogTracer::init().expect("Failed to set logger"); let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")); let subscriber = Registry::default().with(env_filter).with(fmt::layer()); tracing::subscriber::set_global_default(subscriber).expect("Failed to set subscriber"); let config = get_config().expect("Failed to read config."); - let listener = TcpListener::bind(format!("{}:{}", config.app.host, config.app.port))?; - run(listener)?.await?; + let listener = TcpListener::bind(format!("{}:{}", config.app.host, config.app.port)).context("Failed to bind to address")?; + let db = Database::connect(config.database.url).await.context("Failed to connect to database")?; + Migrator::up(&db, None).await.context("Failed to migrate database")?; + + run(listener, db)?.await?; Ok(()) } diff --git a/nhmesh-mqtt-auth/src/models/mod.rs b/nhmesh-mqtt-auth/api/src/models/mod.rs similarity index 50% rename from nhmesh-mqtt-auth/src/models/mod.rs rename to nhmesh-mqtt-auth/api/src/models/mod.rs index 6da18d7..818ca90 100644 --- a/nhmesh-mqtt-auth/src/models/mod.rs +++ b/nhmesh-mqtt-auth/api/src/models/mod.rs @@ -1,3 +1,5 @@ mod mqtt; +mod user; pub(crate) use mqtt::*; +pub(crate) use user::*; diff --git a/nhmesh-mqtt-auth/src/models/mqtt.rs b/nhmesh-mqtt-auth/api/src/models/mqtt.rs similarity index 61% rename from nhmesh-mqtt-auth/src/models/mqtt.rs rename to nhmesh-mqtt-auth/api/src/models/mqtt.rs index 141383e..5140780 100644 --- a/nhmesh-mqtt-auth/src/models/mqtt.rs +++ b/nhmesh-mqtt-auth/api/src/models/mqtt.rs @@ -1,3 +1,4 @@ +use secrecy::SecretString; use serde::Deserialize; use std::net::IpAddr; @@ -6,6 +7,7 @@ pub struct MqttAuth { #[serde(rename = "clientid")] pub client_id: String, pub username: String, - pub password: String, - pub ip: IpAddr, + pub password: SecretString, + #[serde(rename = "ipaddr")] + pub ip_addr: IpAddr, } diff --git a/nhmesh-mqtt-auth/api/src/models/user.rs b/nhmesh-mqtt-auth/api/src/models/user.rs new file mode 100644 index 0000000..2805cf1 --- /dev/null +++ b/nhmesh-mqtt-auth/api/src/models/user.rs @@ -0,0 +1,79 @@ +use entity::user::{ActiveModel as UserActiveModel, Model as UserModel}; +use entity::sea_orm::ActiveValue; +use argon2::{Argon2, Algorithm, Version, Params, password_hash::{rand_core::OsRng, PasswordHash, PasswordHasher, PasswordVerifier, SaltString}}; +use secrecy::{ExposeSecret, SecretString}; +use anyhow::Result; +use serde::Deserialize; +use uuid::Uuid; +struct PasswordManager<'key> { + argon2: Argon2<'key>, +} + +impl<'key> PasswordManager<'key> { + fn new() -> Result { + let params = Params::new(19_456u32, 2u32, 1u32, None)?; + let argon2 = Argon2::new(Algorithm::Argon2id, Version::V0x13, params); + Ok(Self { argon2 }) + } + + fn hash_password(self, password: &SecretString) -> Result { + let salt = SaltString::generate(&mut OsRng); + let key = self.argon2.hash_password(password.expose_secret().as_bytes(), &salt)?.to_string(); + tracing::debug!("Hashed password len: {}", key.len()); + Ok(key) + } + + fn verify_password(self, password: &SecretString, hash: &str) -> Result<()> { + let hash = PasswordHash::new(hash)?; + self.argon2.verify_password(password.expose_secret().as_bytes(), &hash)?; + Ok(()) + } +} + +#[derive(Debug, Deserialize)] +pub struct CreateUser { + username: String, + password: SecretString, + is_superuser: bool, +} + +impl CreateUser { + pub fn new(username: &str, password: &str, is_superuser: bool) -> Self { + Self { username: username.to_string(), password: SecretString::new(password.to_string().into()), is_superuser } + } + + pub fn to_model(self) -> Result { + let password_manager = PasswordManager::new()?; + let password = password_manager.hash_password(&self.password)?; + let user = UserActiveModel { + id: ActiveValue::Set(Uuid::new_v4()), + username: ActiveValue::Set(self.username.clone()), + password: ActiveValue::Set(Some(password)), + is_superuser: ActiveValue::Set(self.is_superuser), + }; + Ok(user) + } +} + +pub struct VerifyUser { + username: String, + password: SecretString, +} + +impl VerifyUser { + pub fn new(username: &str, password: &str) -> Self { + Self { username: username.to_string(), password: SecretString::new(password.to_string().into()) } + } + + pub fn verify(self, user: &UserModel) -> Result<()> { + if user.username != self.username { + return Err(anyhow::anyhow!("Username does not match")); + } + let password_manager = PasswordManager::new()?; + if let Some(hash) = &user.password { + password_manager.verify_password(&self.password, hash.as_str()) + } else { + Err(anyhow::anyhow!("User is disabled")) + } + } +} diff --git a/nhmesh-mqtt-auth/src/routes/health.rs b/nhmesh-mqtt-auth/api/src/routes/health.rs similarity index 100% rename from nhmesh-mqtt-auth/src/routes/health.rs rename to nhmesh-mqtt-auth/api/src/routes/health.rs diff --git a/nhmesh-mqtt-auth/api/src/routes/mod.rs b/nhmesh-mqtt-auth/api/src/routes/mod.rs new file mode 100644 index 0000000..3f8fd64 --- /dev/null +++ b/nhmesh-mqtt-auth/api/src/routes/mod.rs @@ -0,0 +1,6 @@ +mod health; +mod mqtt; +mod user; +pub(crate) use health::*; +pub(crate) use mqtt::*; +pub(crate) use user::*; \ No newline at end of file diff --git a/nhmesh-mqtt-auth/api/src/routes/mqtt/mod.rs b/nhmesh-mqtt-auth/api/src/routes/mqtt/mod.rs new file mode 100644 index 0000000..163f370 --- /dev/null +++ b/nhmesh-mqtt-auth/api/src/routes/mqtt/mod.rs @@ -0,0 +1,10 @@ +use actix_web::{HttpResponse, post, web::Json}; +use tracing::instrument; + +use crate::models::MqttAuth; + +#[post("/mqtt/auth")] +#[instrument(level = "info")] +pub async fn mqtt_auth(body: Json) -> HttpResponse { + HttpResponse::Ok().body("allow") +} diff --git a/nhmesh-mqtt-auth/api/src/routes/user.rs b/nhmesh-mqtt-auth/api/src/routes/user.rs new file mode 100644 index 0000000..aa10ac8 --- /dev/null +++ b/nhmesh-mqtt-auth/api/src/routes/user.rs @@ -0,0 +1,27 @@ +use actix_web::{HttpResponse, post, web}; +use serde_json::json; +use tracing::instrument; +use crate::models::{CreateUser, VerifyUser}; +use crate::AppState; +use anyhow::Context; +use entity::sea_orm::ActiveModelTrait; +use futures::TryFutureExt; +use tracing::debug; +#[post("/user/create")] +#[instrument(level = "info")] +pub async fn create_new_user( + state: web::Data, + user: web::Json, +) -> HttpResponse { + let user = user.into_inner(); + let user_result = async move { + user.to_model().context("Failed to convert user to model") + }.and_then(|user| async move { user.insert(&state.db).await.inspect_err(|e| debug!("Failed to insert user: {}", e)).context("Failed to insert user") }).await; + match user_result { + Ok(user) => HttpResponse::Ok().json(json!({ "id": user.id, "username": user.username })), + Err(e) => { + tracing::error!("Failed to create user: {}", e); + HttpResponse::InternalServerError().json(json!({ "error": e.to_string() })) + } + } +} \ No newline at end of file diff --git a/nhmesh-mqtt-auth/tests/api/health.rs b/nhmesh-mqtt-auth/api/tests/api/health.rs similarity index 89% rename from nhmesh-mqtt-auth/tests/api/health.rs rename to nhmesh-mqtt-auth/api/tests/api/health.rs index 14df398..159266f 100644 --- a/nhmesh-mqtt-auth/tests/api/health.rs +++ b/nhmesh-mqtt-auth/api/tests/api/health.rs @@ -3,7 +3,7 @@ use reqwest::StatusCode; #[tokio::test] async fn test_health() { - let app_url = spawn_app(); + let app_url = spawn_app().await; let client = reqwest::Client::new(); let response = client .get(format!("{}/health", app_url)) diff --git a/nhmesh-mqtt-auth/tests/api/main.rs b/nhmesh-mqtt-auth/api/tests/api/main.rs similarity index 53% rename from nhmesh-mqtt-auth/tests/api/main.rs rename to nhmesh-mqtt-auth/api/tests/api/main.rs index e799ab0..8a7565e 100644 --- a/nhmesh-mqtt-auth/tests/api/main.rs +++ b/nhmesh-mqtt-auth/api/tests/api/main.rs @@ -1,2 +1,4 @@ mod health; +mod mqtt; mod util; +mod user; \ No newline at end of file diff --git a/nhmesh-mqtt-auth/api/tests/api/mqtt.rs b/nhmesh-mqtt-auth/api/tests/api/mqtt.rs new file mode 100644 index 0000000..c89bcdd --- /dev/null +++ b/nhmesh-mqtt-auth/api/tests/api/mqtt.rs @@ -0,0 +1,22 @@ +use crate::util::spawn_app; +use reqwest::StatusCode; +use serde_json::json; + +#[tokio::test] +async fn test_mqtt_auth() { + let app_url = spawn_app().await; + let client = reqwest::Client::new(); + let response = client + .post(format!("{}/mqtt/auth", app_url)) + .json(&json!({ + "clientid": "test", + "username": "test", + "password": "test", + "ipaddr": "127.0.0.1" + })) + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::OK); + assert_eq!(response.text().await.unwrap(), "allow"); +} diff --git a/nhmesh-mqtt-auth/api/tests/api/user.rs b/nhmesh-mqtt-auth/api/tests/api/user.rs new file mode 100644 index 0000000..2128f46 --- /dev/null +++ b/nhmesh-mqtt-auth/api/tests/api/user.rs @@ -0,0 +1,22 @@ +use crate::util::spawn_app; +use reqwest::StatusCode; +use serde_json::json; + +#[tokio::test] +async fn test_create_user() { + let app_url = spawn_app().await; + let client = reqwest::Client::new(); + let response = client + .post(format!("{}/user/create", app_url)) + .json(&json!({ + "username": "nhmesh", + "password": "hunter2", + "is_superuser": true + })) + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::OK); + let body: serde_json::Value = response.json().await.unwrap(); + assert_eq!(body["username"], "nhmesh"); +} \ No newline at end of file diff --git a/nhmesh-mqtt-auth/api/tests/api/util.rs b/nhmesh-mqtt-auth/api/tests/api/util.rs new file mode 100644 index 0000000..2d0a674 --- /dev/null +++ b/nhmesh-mqtt-auth/api/tests/api/util.rs @@ -0,0 +1,44 @@ +use nhmesh_mqtt_auth::run; +use std::net::TcpListener; +use entity::sea_orm::Database; +use migration::{Migrator, MigratorTrait}; +use tracing::Subscriber; +use tracing_subscriber::{EnvFilter, Registry, fmt, layer::SubscriberExt}; +use tracing_log::LogTracer; +use once_cell::sync::Lazy; + +static TRACING: Lazy<()> = Lazy::new(|| { + let subscriber = get_subscriber("debug".to_string()); + init_subscriber(subscriber); +}); + +pub fn get_subscriber(env_filter: String) -> impl Subscriber + Send + Sync { + let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(env_filter)); + let subscriber = Registry::default().with(env_filter).with(fmt::layer()); + subscriber +} + +pub fn init_subscriber(subscriber: impl Subscriber + Send + Sync) { + LogTracer::init().expect("Failed to set logger"); + tracing::subscriber::set_global_default(subscriber).expect("Failed to set subscriber"); +} + + + + +pub async fn spawn_app() -> String { + // Initialize tracing + Lazy::force(&TRACING); + // Bind to random port + let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind to random port"); + // Get port + let port = listener.local_addr().unwrap().port(); + + let db = Database::connect("sqlite::memory:").await.expect("Failed to connect to database"); + Migrator::up(&db, None).await.expect("Failed to migrate database"); + // Run server + let server = run(listener, db).expect("Failed to bind address"); + let _ = tokio::spawn(server); + // Return test url + format!("http://127.0.0.1:{}", port) +} diff --git a/nhmesh-mqtt-auth/config.yaml b/nhmesh-mqtt-auth/config.yaml index 3c92154..6fc32d3 100644 --- a/nhmesh-mqtt-auth/config.yaml +++ b/nhmesh-mqtt-auth/config.yaml @@ -2,3 +2,6 @@ app: host: 127.0.0.1 port: 8000 + +database: + url: "sqlite://auth.db?mode=rwc" diff --git a/nhmesh-mqtt-auth/entity/Cargo.toml b/nhmesh-mqtt-auth/entity/Cargo.toml new file mode 100644 index 0000000..3b665e2 --- /dev/null +++ b/nhmesh-mqtt-auth/entity/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "entity" +version = "0.1.0" +edition = "2024" + +[dependencies] +sea-orm = { version = "1.1.10", features = ["runtime-tokio-rustls", "sqlx-postgres", "sqlx-sqlite", "sqlx-mysql"] } +serde = { version = "1.0", features = ["derive"] } diff --git a/nhmesh-mqtt-auth/entity/src/lib.rs b/nhmesh-mqtt-auth/entity/src/lib.rs new file mode 100644 index 0000000..0c41584 --- /dev/null +++ b/nhmesh-mqtt-auth/entity/src/lib.rs @@ -0,0 +1,7 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.10 + +pub mod prelude; + +pub mod user; + +pub use sea_orm; \ No newline at end of file diff --git a/nhmesh-mqtt-auth/entity/src/prelude.rs b/nhmesh-mqtt-auth/entity/src/prelude.rs new file mode 100644 index 0000000..d4ad55b --- /dev/null +++ b/nhmesh-mqtt-auth/entity/src/prelude.rs @@ -0,0 +1,3 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.10 + +pub use super::user::Entity as User; diff --git a/nhmesh-mqtt-auth/entity/src/user.rs b/nhmesh-mqtt-auth/entity/src/user.rs new file mode 100644 index 0000000..e13ec16 --- /dev/null +++ b/nhmesh-mqtt-auth/entity/src/user.rs @@ -0,0 +1,20 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.10 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] +#[sea_orm(table_name = "user")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub id: Uuid, + #[sea_orm(unique)] + pub username: String, + pub password: Option, + pub is_superuser: bool, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/nhmesh-mqtt-auth/migration/Cargo.toml b/nhmesh-mqtt-auth/migration/Cargo.toml new file mode 100644 index 0000000..015a4e4 --- /dev/null +++ b/nhmesh-mqtt-auth/migration/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "migration" +version = "0.1.0" +edition = "2021" +publish = false + +[lib] +name = "migration" +path = "src/lib.rs" + +[dependencies] +async-std = { version = "1", features = ["attributes", "tokio1"] } + +[dependencies.sea-orm-migration] +version = "1.1.10" +features = [ + # Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI. + # View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime. + # e.g. + "runtime-tokio-rustls", # `ASYNC_RUNTIME` feature + "sqlx-postgres", # `DATABASE_DRIVER` feature + "sqlx-mysql", + "sqlx-sqlite", +] diff --git a/nhmesh-mqtt-auth/migration/README.md b/nhmesh-mqtt-auth/migration/README.md new file mode 100644 index 0000000..3b438d8 --- /dev/null +++ b/nhmesh-mqtt-auth/migration/README.md @@ -0,0 +1,41 @@ +# Running Migrator CLI + +- Generate a new migration file + ```sh + cargo run -- generate MIGRATION_NAME + ``` +- Apply all pending migrations + ```sh + cargo run + ``` + ```sh + cargo run -- up + ``` +- Apply first 10 pending migrations + ```sh + cargo run -- up -n 10 + ``` +- Rollback last applied migrations + ```sh + cargo run -- down + ``` +- Rollback last 10 applied migrations + ```sh + cargo run -- down -n 10 + ``` +- Drop all tables from the database, then reapply all migrations + ```sh + cargo run -- fresh + ``` +- Rollback all applied migrations, then reapply all migrations + ```sh + cargo run -- refresh + ``` +- Rollback all applied migrations + ```sh + cargo run -- reset + ``` +- Check the status of all migrations + ```sh + cargo run -- status + ``` diff --git a/nhmesh-mqtt-auth/migration/src/lib.rs b/nhmesh-mqtt-auth/migration/src/lib.rs new file mode 100644 index 0000000..ad02cb6 --- /dev/null +++ b/nhmesh-mqtt-auth/migration/src/lib.rs @@ -0,0 +1,16 @@ +pub use sea_orm_migration::prelude::*; + +mod m20220101_000001_create_users_table; +mod m20250504_231730_create_superuser; + +pub struct Migrator; + +#[async_trait::async_trait] +impl MigratorTrait for Migrator { + fn migrations() -> Vec> { + vec![ + Box::new(m20220101_000001_create_users_table::Migration), + Box::new(m20250504_231730_create_superuser::Migration), + ] + } +} diff --git a/nhmesh-mqtt-auth/migration/src/m20220101_000001_create_users_table.rs b/nhmesh-mqtt-auth/migration/src/m20220101_000001_create_users_table.rs new file mode 100644 index 0000000..cf7b1c1 --- /dev/null +++ b/nhmesh-mqtt-auth/migration/src/m20220101_000001_create_users_table.rs @@ -0,0 +1,37 @@ +use sea_orm_migration::{prelude::*, schema::*}; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + + manager + .create_table( + Table::create() + .table(User::Table) + .if_not_exists() + .col(pk_uuid(User::Id)) + .col(string_len_uniq(User::Username, 255)) + .col(string_len_null(User::Password, 255)) + .to_owned(), + ) + .await + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + + manager + .drop_table(Table::drop().table(User::Table).to_owned()) + .await + } +} + +#[derive(DeriveIden)] +enum User { + Table, + Id, + Username, + Password, +} diff --git a/nhmesh-mqtt-auth/migration/src/m20250504_231730_create_superuser.rs b/nhmesh-mqtt-auth/migration/src/m20250504_231730_create_superuser.rs new file mode 100644 index 0000000..7a2ab7e --- /dev/null +++ b/nhmesh-mqtt-auth/migration/src/m20250504_231730_create_superuser.rs @@ -0,0 +1,32 @@ +use sea_orm_migration::{prelude::*, schema::*}; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + + manager + .alter_table( + Table::alter() + .table(User::Table) + .add_column_if_not_exists(boolean(User::IsSuperuser)) + .to_owned(), + ) + .await + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + + manager + .alter_table(Table::alter().table(User::Table).drop_column(User::IsSuperuser).to_owned()) + .await + } +} + +#[derive(DeriveIden)] +enum User { + Table, + IsSuperuser, +} diff --git a/nhmesh-mqtt-auth/migration/src/main.rs b/nhmesh-mqtt-auth/migration/src/main.rs new file mode 100644 index 0000000..c6b6e48 --- /dev/null +++ b/nhmesh-mqtt-auth/migration/src/main.rs @@ -0,0 +1,6 @@ +use sea_orm_migration::prelude::*; + +#[async_std::main] +async fn main() { + cli::run_cli(migration::Migrator).await; +} diff --git a/nhmesh-mqtt-auth/src/lib.rs b/nhmesh-mqtt-auth/src/lib.rs deleted file mode 100644 index b959f8b..0000000 --- a/nhmesh-mqtt-auth/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -use actix_web::dev::Server; -use actix_web::{App, HttpServer}; -use std::net::TcpListener; - -mod config; -mod models; -mod routes; - -pub use config::*; - -pub fn run(listener: TcpListener) -> Result { - let server = HttpServer::new(|| App::new().service(routes::health)) - .listen(listener)? - .run(); - - Ok(server) -} diff --git a/nhmesh-mqtt-auth/src/routes/mod.rs b/nhmesh-mqtt-auth/src/routes/mod.rs deleted file mode 100644 index 401fafc..0000000 --- a/nhmesh-mqtt-auth/src/routes/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod health; - -pub(crate) use health::*; diff --git a/nhmesh-mqtt-auth/tests/api/util.rs b/nhmesh-mqtt-auth/tests/api/util.rs deleted file mode 100644 index 3d65540..0000000 --- a/nhmesh-mqtt-auth/tests/api/util.rs +++ /dev/null @@ -1,14 +0,0 @@ -use nhmesh_mqtt_auth::run; -use std::net::TcpListener; - -pub fn spawn_app() -> String { - // Bind to random port - let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind to random port"); - // Get port - let port = listener.local_addr().unwrap().port(); - // Run server - let server = run(listener).expect("Failed to bind address"); - let _ = tokio::spawn(server); - // Return test url - format!("http://127.0.0.1:{}", port) -} From e2dfa93be38365876d01089e09cfaded52468ece Mon Sep 17 00:00:00 2001 From: Doni Crosby Date: Tue, 6 May 2025 11:18:36 -0400 Subject: [PATCH 5/7] feat: auth server complete --- nhmesh-mqtt-auth/.gitignore | 3 +- nhmesh-mqtt-auth/api/src/lib.rs | 1 + nhmesh-mqtt-auth/api/src/models/mqtt.rs | 3 +- nhmesh-mqtt-auth/api/src/models/user.rs | 70 +++++++++++++++++++-- nhmesh-mqtt-auth/api/src/routes/mqtt/mod.rs | 25 ++++++-- nhmesh-mqtt-auth/api/src/routes/user.rs | 34 ++++++---- nhmesh-mqtt-auth/api/tests/api/mqtt.rs | 32 +++++++++- nhmesh-mqtt-auth/api/tests/api/user.rs | 44 ++++++++++--- 8 files changed, 179 insertions(+), 33 deletions(-) diff --git a/nhmesh-mqtt-auth/.gitignore b/nhmesh-mqtt-auth/.gitignore index 1de5659..2fb5714 100644 --- a/nhmesh-mqtt-auth/.gitignore +++ b/nhmesh-mqtt-auth/.gitignore @@ -1 +1,2 @@ -target \ No newline at end of file +target +auth-db.sqlite \ No newline at end of file diff --git a/nhmesh-mqtt-auth/api/src/lib.rs b/nhmesh-mqtt-auth/api/src/lib.rs index 5de2f84..55b1ecb 100644 --- a/nhmesh-mqtt-auth/api/src/lib.rs +++ b/nhmesh-mqtt-auth/api/src/lib.rs @@ -21,6 +21,7 @@ pub fn run(listener: TcpListener, db: DatabaseConnection) -> Result { argon2: Argon2<'key>, } @@ -77,3 +78,64 @@ impl VerifyUser { } } } + +#[derive(Debug, Serialize)] +pub struct UserResponse { + pub id: Uuid, + pub username: String, + pub is_superuser: bool, +} + +impl From for UserResponse { + fn from(user: UserModel) -> Self { + Self { + id: user.id, + username: user.username, + is_superuser: user.is_superuser, + } + } +} + +pub struct UserService<'db> { + db: &'db DatabaseConnection, +} + +impl<'db> UserService<'db> { + pub fn new(db: &'db DatabaseConnection) -> Self { + Self { db } + } + + pub async fn create_user(&self, create_user: CreateUser) -> Result { + let user_model = create_user.to_model()?; + let user = user_model.insert(self.db) + .await + .context("Failed to insert user")?; + Ok(user.into()) + } + + pub async fn find_by_username(&self, username: &str) -> Result> { + User::find() + .filter(entity::user::Column::Username.eq(username)) + .one(self.db) + .await + .context("Failed to query user") + } + + pub async fn find_by_id(&self, id: Uuid) -> Result> { + User::find_by_id(id) + .one(self.db) + .await + .context("Failed to query user") + } + + pub async fn verify_user(&self, username: &str, password: &str) -> Result { + let user = self.find_by_username(username) + .await? + .ok_or_else(|| anyhow::anyhow!("User not found"))?; + + let verify = VerifyUser::new(username, password); + verify.verify(&user)?; + + Ok(user.into()) + } +} diff --git a/nhmesh-mqtt-auth/api/src/routes/mqtt/mod.rs b/nhmesh-mqtt-auth/api/src/routes/mqtt/mod.rs index 163f370..32ada97 100644 --- a/nhmesh-mqtt-auth/api/src/routes/mqtt/mod.rs +++ b/nhmesh-mqtt-auth/api/src/routes/mqtt/mod.rs @@ -1,10 +1,25 @@ -use actix_web::{HttpResponse, post, web::Json}; +use actix_web::{HttpResponse, post, web}; use tracing::instrument; - -use crate::models::MqttAuth; +use crate::AppState; +use secrecy::ExposeSecret; +use crate::models::{MqttAuth, UserService}; #[post("/mqtt/auth")] #[instrument(level = "info")] -pub async fn mqtt_auth(body: Json) -> HttpResponse { - HttpResponse::Ok().body("allow") +pub async fn mqtt_auth(state: web::Data, body: web::Json) -> HttpResponse { + let user_service = UserService::new(&state.db); + let auth_req = body.into_inner(); + match user_service.verify_user(&auth_req.username, &auth_req.password.expose_secret()) + .await + .map_err(|e| { + tracing::warn!("Failed to verify user: {}", e); + HttpResponse::Unauthorized().body(e.to_string()) + }) { + Ok(user) => { + HttpResponse::Ok().body("allow") + } + Err(e) => { + HttpResponse::Ok().body("deny") + } + } } diff --git a/nhmesh-mqtt-auth/api/src/routes/user.rs b/nhmesh-mqtt-auth/api/src/routes/user.rs index aa10ac8..69da81b 100644 --- a/nhmesh-mqtt-auth/api/src/routes/user.rs +++ b/nhmesh-mqtt-auth/api/src/routes/user.rs @@ -1,27 +1,39 @@ -use actix_web::{HttpResponse, post, web}; +use actix_web::{HttpResponse, post, web, get}; use serde_json::json; use tracing::instrument; -use crate::models::{CreateUser, VerifyUser}; +use crate::models::{CreateUser, UserService}; use crate::AppState; use anyhow::Context; -use entity::sea_orm::ActiveModelTrait; -use futures::TryFutureExt; -use tracing::debug; + #[post("/user/create")] #[instrument(level = "info")] pub async fn create_new_user( state: web::Data, user: web::Json, ) -> HttpResponse { - let user = user.into_inner(); - let user_result = async move { - user.to_model().context("Failed to convert user to model") - }.and_then(|user| async move { user.insert(&state.db).await.inspect_err(|e| debug!("Failed to insert user: {}", e)).context("Failed to insert user") }).await; - match user_result { - Ok(user) => HttpResponse::Ok().json(json!({ "id": user.id, "username": user.username })), + let user_service = UserService::new(&state.db); + match user_service.create_user(user.into_inner()).await { + Ok(user) => HttpResponse::Ok().json(user), Err(e) => { tracing::error!("Failed to create user: {}", e); HttpResponse::InternalServerError().json(json!({ "error": e.to_string() })) } } +} + +#[get("/user/{username}")] +#[instrument(level = "info")] +pub async fn get_user( + state: web::Data, + username: web::Path, +) -> HttpResponse { + let user_service = UserService::new(&state.db); + match user_service.find_by_username(&username).await { + Ok(Some(user)) => HttpResponse::Ok().json(user), + Ok(None) => HttpResponse::NotFound().json(json!({ "error": "User not found" })), + Err(e) => { + tracing::error!("Failed to get user: {}", e); + HttpResponse::InternalServerError().json(json!({ "error": e.to_string() })) + } + } } \ No newline at end of file diff --git a/nhmesh-mqtt-auth/api/tests/api/mqtt.rs b/nhmesh-mqtt-auth/api/tests/api/mqtt.rs index c89bcdd..45bc50c 100644 --- a/nhmesh-mqtt-auth/api/tests/api/mqtt.rs +++ b/nhmesh-mqtt-auth/api/tests/api/mqtt.rs @@ -1,4 +1,5 @@ use crate::util::spawn_app; +use crate::user::create_user; use reqwest::StatusCode; use serde_json::json; @@ -6,12 +7,15 @@ use serde_json::json; async fn test_mqtt_auth() { let app_url = spawn_app().await; let client = reqwest::Client::new(); + let username = "nhmesh"; + let password = "hunter2"; + create_user(&app_url, &client, username, password, true).await.unwrap(); let response = client .post(format!("{}/mqtt/auth", app_url)) .json(&json!({ "clientid": "test", - "username": "test", - "password": "test", + "username": username, + "password": password, "ipaddr": "127.0.0.1" })) .send() @@ -20,3 +24,27 @@ async fn test_mqtt_auth() { assert_eq!(response.status(), StatusCode::OK); assert_eq!(response.text().await.unwrap(), "allow"); } + + +#[tokio::test] +async fn test_mqtt_auth_invalid_password() { + let app_url = spawn_app().await; + let client = reqwest::Client::new(); + let username = "nhmesh"; + let password = "hunter2"; + let invalid_password = "hunter3"; + create_user(&app_url, &client, username, password, true).await.unwrap(); + let response = client + .post(format!("{}/mqtt/auth", app_url)) + .json(&json!({ + "clientid": "test", + "username": username, + "password": invalid_password, + "ipaddr": "127.0.0.1" + })) + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::OK); + assert_eq!(response.text().await.unwrap(), "deny"); +} \ No newline at end of file diff --git a/nhmesh-mqtt-auth/api/tests/api/user.rs b/nhmesh-mqtt-auth/api/tests/api/user.rs index 2128f46..3f386ea 100644 --- a/nhmesh-mqtt-auth/api/tests/api/user.rs +++ b/nhmesh-mqtt-auth/api/tests/api/user.rs @@ -2,21 +2,47 @@ use crate::util::spawn_app; use reqwest::StatusCode; use serde_json::json; -#[tokio::test] -async fn test_create_user() { - let app_url = spawn_app().await; - let client = reqwest::Client::new(); - let response = client +pub async fn create_user(app_url: &str, client: &reqwest::Client, username: &str, password: &str, is_superuser: bool) -> Result { + client .post(format!("{}/user/create", app_url)) .json(&json!({ - "username": "nhmesh", - "password": "hunter2", - "is_superuser": true + "username": username, + "password": password, + "is_superuser": is_superuser })) .send() .await - .unwrap(); +} + +pub async fn get_user(app_url: &str, client: &reqwest::Client, username: &str) -> Result { + client + .get(format!("{}/user/{}", app_url, username)) + .send() + .await +} + +#[tokio::test] +async fn test_create_user() { + let app_url = spawn_app().await; + let client = reqwest::Client::new(); + let response = create_user(&app_url, &client, "nhmesh", "hunter2", true).await.unwrap(); assert_eq!(response.status(), StatusCode::OK); let body: serde_json::Value = response.json().await.unwrap(); assert_eq!(body["username"], "nhmesh"); +} + +#[tokio::test] +async fn test_get_user() { + let app_url = spawn_app().await; + let user = "nhmesh"; + let client = reqwest::Client::new(); + let create_response = create_user(&app_url, &client, user, "hunter2", true).await.unwrap(); + let create_body: serde_json::Value = create_response.json().await.unwrap(); + let user_id = create_body["id"].as_str().unwrap(); + let response = get_user(&app_url, &client, user).await.unwrap(); + assert_eq!(response.status(), StatusCode::OK); + let body: serde_json::Value = response.json().await.unwrap(); + assert_eq!(body["username"], user); + assert_eq!(body["is_superuser"], true); + assert_eq!(body["id"], user_id); } \ No newline at end of file From 13c19578b1ac036d0127a496e6b24ccfec41cb88 Mon Sep 17 00:00:00 2001 From: Doni Crosby Date: Tue, 6 May 2025 11:29:49 -0400 Subject: [PATCH 6/7] feat: rmqtt integration test complete --- nhmesh-mqtt-auth/Cargo.toml | 2 ++ nhmesh-mqtt-auth/config.yaml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/nhmesh-mqtt-auth/Cargo.toml b/nhmesh-mqtt-auth/Cargo.toml index cf906d5..d414883 100644 --- a/nhmesh-mqtt-auth/Cargo.toml +++ b/nhmesh-mqtt-auth/Cargo.toml @@ -1,2 +1,4 @@ [workspace] members = ["api", "entity", "migration"] +resolver = "3" +default-members = ["api"] diff --git a/nhmesh-mqtt-auth/config.yaml b/nhmesh-mqtt-auth/config.yaml index 6fc32d3..a585f9f 100644 --- a/nhmesh-mqtt-auth/config.yaml +++ b/nhmesh-mqtt-auth/config.yaml @@ -1,7 +1,7 @@ --- app: - host: 127.0.0.1 + host: 0.0.0.0 port: 8000 database: - url: "sqlite://auth.db?mode=rwc" + url: "sqlite://auth-db.sqlite?mode=rwc" From 4aa9582f246685c4784f1060ee284a8567601365 Mon Sep 17 00:00:00 2001 From: Doni Crosby Date: Tue, 6 May 2025 11:44:31 -0400 Subject: [PATCH 7/7] ci: add docker build --- .dockerignore | 2 ++ docker/docker-compose.yml | 7 +++++++ docker/nhmesh-auth/Dockerfile | 21 +++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 .dockerignore create mode 100644 docker/nhmesh-auth/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..588248d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +nhmesh-mqtt-auth/target +nhmesh-mqtt-auth/auth-db.sqlite \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 3d49dc7..ed6176d 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -55,6 +55,13 @@ services: - mqttdata:/var/log/rmqtt - ./rmqtt/rmqtt/rmqtt-plugins:/app/rmqtt/rmqtt-plugins:ro - ./rmqtt/rmqtt/rmqtt.toml:/app/rmqtt/rmqtt.toml:ro + + auth: + build: + context: .. + dockerfile: docker/nhmesh-auth/Dockerfile + ports: + - "8000:8000" volumes: esdata: diff --git a/docker/nhmesh-auth/Dockerfile b/docker/nhmesh-auth/Dockerfile new file mode 100644 index 0000000..8e31d07 --- /dev/null +++ b/docker/nhmesh-auth/Dockerfile @@ -0,0 +1,21 @@ +FROM rust AS builder + +COPY ./nhmesh-mqtt-auth ./nhmesh-mqtt-auth + +WORKDIR /nhmesh-mqtt-auth + +RUN cargo build --release + +FROM debian:trixie-slim + +RUN mkdir -p /app/bin +WORKDIR /app + +RUN apt-get update && apt-get install -y ca-certificates + +COPY --from=builder /nhmesh-mqtt-auth/target/release/nhmesh-mqtt-auth /app/bin/nhmesh-mqtt-auth +COPY --from=builder /nhmesh-mqtt-auth/config.yaml /app/config.yaml + +EXPOSE 8000 + +CMD ["/app/bin/nhmesh-mqtt-auth"] \ No newline at end of file