diff --git a/Cargo.lock b/Cargo.lock index cd413de..3b49e96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,7 +161,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", - "axum-core 0.3.4", + "axum-core", "bitflags 1.3.2", "bytes", "futures-util", @@ -177,34 +177,7 @@ dependencies = [ "rustversion", "serde", "sync_wrapper 0.1.2", - "tower 0.4.13", - "tower-layer", - "tower-service", -] - -[[package]] -name = "axum" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" -dependencies = [ - "async-trait", - "axum-core 0.4.5", - "bytes", - "futures-util", - "http 1.1.0", - "http-body 1.0.1", - "http-body-util", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "rustversion", - "serde", - "sync_wrapper 1.0.1", - "tower 0.5.1", + "tower", "tower-layer", "tower-service", ] @@ -226,26 +199,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "axum-core" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" -dependencies = [ - "async-trait", - "bytes", - "futures-util", - "http 1.1.0", - "http-body 1.0.1", - "http-body-util", - "mime", - "pin-project-lite", - "rustversion", - "sync_wrapper 1.0.1", - "tower-layer", - "tower-service", -] - [[package]] name = "backtrace" version = "0.3.74" @@ -761,6 +714,40 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "famedly-sync" +version = "0.5.0" +dependencies = [ + "anyhow", + "async-trait", + "base64 0.22.1", + "bincode", + "chrono", + "config", + "csv", + "http 1.1.0", + "indoc", + "itertools 0.13.0", + "ldap-poller", + "ldap3", + "reqwest 0.11.27", + "serde", + "serde_json", + "serde_yaml", + "tempfile", + "test-log", + "tokio", + "tokio-stream", + "tonic", + "tracing", + "tracing-subscriber", + "url", + "uuid", + "vergen", + "wiremock", + "zitadel-rust-client", +] + [[package]] name = "fastrand" version = "2.1.1" @@ -1245,7 +1232,6 @@ dependencies = [ "hyper 1.4.1", "hyper-util", "rustls 0.23.14", - "rustls-native-certs 0.8.0", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -1265,16 +1251,16 @@ dependencies = [ ] [[package]] -name = "hyper-timeout" -version = "0.5.1" +name = "hyper-tls" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "hyper 1.4.1", - "hyper-util", - "pin-project-lite", + "bytes", + "hyper 0.14.30", + "native-tls", "tokio", - "tower-service", + "tokio-native-tls", ] [[package]] @@ -1503,40 +1489,6 @@ dependencies = [ "url", ] -[[package]] -name = "ldap-sync" -version = "0.5.0" -dependencies = [ - "anyhow", - "async-trait", - "base64 0.22.1", - "bincode", - "chrono", - "config", - "csv", - "http 1.1.0", - "indoc", - "itertools 0.13.0", - "ldap-poller", - "ldap3", - "reqwest 0.12.8", - "serde", - "serde_json", - "serde_yaml", - "tempfile", - "test-log", - "tokio", - "tokio-stream", - "tonic 0.12.3", - "tracing", - "tracing-subscriber", - "url", - "uuid", - "vergen", - "wiremock", - "zitadel-rust-client", -] - [[package]] name = "ldap3" version = "0.11.5" @@ -1987,7 +1939,7 @@ checksum = "2580e33f2292d34be285c5bc3dba5259542b083cfad6037b6d70345f24dcb735" dependencies = [ "heck 0.4.1", "itertools 0.11.0", - "prost 0.12.6", + "prost", "prost-types", ] @@ -2001,7 +1953,7 @@ dependencies = [ "chrono", "pbjson", "pbjson-build", - "prost 0.12.6", + "prost", "prost-build", "serde", ] @@ -2198,15 +2150,6 @@ dependencies = [ "prost-derive", ] -[[package]] -name = "prost" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" -dependencies = [ - "bytes", -] - [[package]] name = "prost-build" version = "0.12.6" @@ -2221,7 +2164,7 @@ dependencies = [ "once_cell", "petgraph", "prettyplease", - "prost 0.12.6", + "prost", "prost-types", "regex", "syn", @@ -2247,7 +2190,7 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ - "prost 0.12.6", + "prost", ] [[package]] @@ -2260,54 +2203,6 @@ dependencies = [ "ipnet", ] -[[package]] -name = "quinn" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" -dependencies = [ - "bytes", - "pin-project-lite", - "quinn-proto", - "quinn-udp", - "rustc-hash", - "rustls 0.23.14", - "socket2", - "thiserror", - "tokio", - "tracing", -] - -[[package]] -name = "quinn-proto" -version = "0.11.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" -dependencies = [ - "bytes", - "rand", - "ring 0.17.8", - "rustc-hash", - "rustls 0.23.14", - "slab", - "thiserror", - "tinyvec", - "tracing", -] - -[[package]] -name = "quinn-udp" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" -dependencies = [ - "libc", - "once_cell", - "socket2", - "tracing", - "windows-sys 0.59.0", -] - [[package]] name = "quote" version = "1.0.37" @@ -2416,14 +2311,17 @@ dependencies = [ "http-body 0.4.6", "hyper 0.14.30", "hyper-rustls 0.24.2", + "hyper-tls 0.5.0", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", "rustls 0.21.12", + "rustls-native-certs 0.6.3", "rustls-pemfile 1.0.4", "serde", "serde_json", @@ -2431,6 +2329,7 @@ dependencies = [ "sync_wrapper 0.1.2", "system-configuration 0.5.1", "tokio", + "tokio-native-tls", "tokio-rustls 0.24.1", "tower-service", "url", @@ -2458,7 +2357,7 @@ dependencies = [ "http-body-util", "hyper 1.4.1", "hyper-rustls 0.27.3", - "hyper-tls", + "hyper-tls 0.6.0", "hyper-util", "ipnet", "js-sys", @@ -2468,11 +2367,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "quinn", - "rustls 0.23.14", - "rustls-native-certs 0.8.0", "rustls-pemfile 2.2.0", - "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", @@ -2480,7 +2375,6 @@ dependencies = [ "system-configuration 0.6.1", "tokio", "tokio-native-tls", - "tokio-rustls 0.26.0", "tower-service", "url", "wasm-bindgen", @@ -2577,12 +2471,6 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" -[[package]] -name = "rustc-hash" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" - [[package]] name = "rustc_version" version = "0.4.1" @@ -2650,9 +2538,7 @@ version = "0.23.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8" dependencies = [ - "log", "once_cell", - "ring 0.17.8", "rustls-pki-types", "rustls-webpki 0.102.8", "subtle", @@ -2673,22 +2559,21 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.3" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile 2.2.0", - "rustls-pki-types", + "rustls-pemfile 1.0.4", "schannel", "security-framework", ] [[package]] name = "rustls-native-certs" -version = "0.8.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" +checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" dependencies = [ "openssl-probe", "rustls-pemfile 2.2.0", @@ -3438,57 +3323,24 @@ checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" dependencies = [ "async-stream", "async-trait", - "axum 0.6.20", + "axum", "base64 0.21.7", "bytes", "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.30", - "hyper-timeout 0.4.1", + "hyper-timeout", "percent-encoding", "pin-project", - "prost 0.12.6", + "prost", "rustls-native-certs 0.7.3", "rustls-pemfile 2.2.0", "rustls-pki-types", "tokio", "tokio-rustls 0.25.0", "tokio-stream", - "tower 0.4.13", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tonic" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" -dependencies = [ - "async-stream", - "async-trait", - "axum 0.7.7", - "base64 0.22.1", - "bytes", - "h2 0.4.6", - "http 1.1.0", - "http-body 1.0.1", - "http-body-util", - "hyper 1.4.1", - "hyper-timeout 0.5.1", - "hyper-util", - "percent-encoding", - "pin-project", - "prost 0.13.3", - "rustls-native-certs 0.8.0", - "rustls-pemfile 2.2.0", - "socket2", - "tokio", - "tokio-rustls 0.26.0", - "tokio-stream", - "tower 0.4.13", + "tower", "tower-layer", "tower-service", "tracing", @@ -3500,9 +3352,9 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4aa089471d8d4c60ec3aef047739713a4695f0b309d4cea0073bc55201064f4" dependencies = [ - "prost 0.12.6", + "prost", "prost-types", - "tonic 0.11.0", + "tonic", ] [[package]] @@ -3525,20 +3377,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tower" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" -dependencies = [ - "futures-core", - "futures-util", - "pin-project-lite", - "sync_wrapper 0.1.2", - "tower-layer", - "tower-service", -] - [[package]] name = "tower-layer" version = "0.3.3" @@ -4138,7 +3976,7 @@ dependencies = [ "jsonwebtoken", "openidconnect", "pbjson-types", - "prost 0.12.6", + "prost", "prost-types", "reqwest 0.11.27", "serde", @@ -4146,7 +3984,7 @@ dependencies = [ "serde_urlencoded", "time", "tokio", - "tonic 0.11.0", + "tonic", "tonic-types", ] @@ -4170,7 +4008,7 @@ dependencies = [ "thiserror", "time", "tokio", - "tonic 0.11.0", + "tonic", "tracing", "url", "zitadel", diff --git a/Cargo.toml b/Cargo.toml index 3d2bf0a..77ce9f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ldap-sync" +name = "famedly-sync" version = "0.5.0" authors = [] edition = "2021" diff --git a/Dockerfile b/Dockerfile index 54c7672..d3bf6d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,8 +22,8 @@ RUN cargo auditable build --release FROM debian:bookworm-slim RUN apt update && apt install ca-certificates curl -y -RUN mkdir -p /opt/famedly-sync-agent -WORKDIR /opt/famedly-sync-agent -COPY --from=builder /app/target/release/ldap-sync /usr/local/bin/famedly-sync-agent -ENV FAMEDLY_LDAP_SYNC_CONFIG="/opt/famedly-sync-agent/config.yaml" -ENTRYPOINT ["/usr/local/bin/famedly-sync-agent"] +RUN mkdir -p /opt/famedly-sync +WORKDIR /opt/famedly-sync +COPY --from=builder /app/target/release/famedly-sync /usr/local/bin/famedly-sync +ENV FAMEDLY_SYNC_CONFIG="/opt/famedly-sync/config.yaml" +ENTRYPOINT ["/usr/local/bin/famedly-sync"] diff --git a/README.md b/README.md index bfda90c..6dc4e78 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Currently supported sources: The tool expects a configuration file located at `./config.yaml`. See example configuration at [config.sample.yaml](./config.sample.yaml). -The default path can be changed by setting the new path to the environment variable `FAMEDLY_LDAP_SYNC_CONFIG`. +The default path can be changed by setting the new path to the environment variable `FAMEDLY_SYNC_CONFIG`. Also, individual configuration items and the whole configuration can be set using environment variables. For example, the following YAML configuration: @@ -24,10 +24,10 @@ sources: Could be set using the following environment variable: ```bash -FAMEDLY_LDAP_SYNC__SOURCES__LDAP__URL="ldap://localhost:1389" +FAMEDLY_SYNC__SOURCES__LDAP__URL="ldap://localhost:1389" ``` -Note that the environment variable name always starts with the prefix `FAMEDLY_LDAP_SYNC` followed by keys separated by double underscores (`__`). +Note that the environment variable name always starts with the prefix `FAMEDLY_SYNC` followed by keys separated by double underscores (`__`). Some configuration items take a list of values. In this cases the values should be separated by space. **If an empty list is desired the variable shouldn't be created.** diff --git a/src/config.rs b/src/config.rs index 8d90cfa..6b31566 100644 --- a/src/config.rs +++ b/src/config.rs @@ -20,7 +20,7 @@ use crate::{ }; /// App prefix for env var configuration -const ENV_VAR_CONFIG_PREFIX: &str = "FAMEDLY_LDAP_SYNC"; +const ENV_VAR_CONFIG_PREFIX: &str = "FAMEDLY_SYNC"; /// Separator for setting a list using env vars const ENV_VAR_LIST_SEP: &str = " "; diff --git a/src/main.rs b/src/main.rs index ad10e79..f748f10 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use std::{path::Path, process::ExitCode, str::FromStr}; use anyhow::{Context, Result}; -use ldap_sync::Config; +use famedly_sync::Config; use tracing::level_filters::LevelFilter; #[tokio::main] @@ -20,7 +20,7 @@ async fn main() -> ExitCode { #[allow(clippy::print_stderr)] async fn run_sync() -> Result<()> { let config = { - let config_path = std::env::var("FAMEDLY_LDAP_SYNC_CONFIG").unwrap_or("config.yaml".into()); + let config_path = std::env::var("FAMEDLY_SYNC_CONFIG").unwrap_or("config.yaml".into()); let config_path = Path::new(&config_path); match Config::new(config_path) { Ok(config) => config, diff --git a/src/sources/csv.rs b/src/sources/csv.rs index b3d063b..ae8a694 100644 --- a/src/sources/csv.rs +++ b/src/sources/csv.rs @@ -26,7 +26,7 @@ impl Source for CsvSource { let new_users = self.read_csv()?; // TODO: Implement changed and deleted users // Holding off on this until we get rid of the cache concept - // https://github.com/famedly/ldap-sync/issues/53 + // https://github.com/famedly/famedly-sync/issues/53 return Ok(SourceDiff { new_users, changed_users: vec![], deleted_user_ids: vec![] }); } } diff --git a/tests/e2e.rs b/tests/e2e.rs index 4ef34ec..c281b0b 100644 --- a/tests/e2e.rs +++ b/tests/e2e.rs @@ -3,14 +3,14 @@ use std::{collections::HashSet, path::Path, time::Duration}; use base64::prelude::{Engine, BASE64_STANDARD}; -use ldap3::{Ldap as LdapClient, LdapConnAsync, LdapConnSettings, Mod}; -use ldap_sync::{ +use famedly_sync::{ csv_test_helpers::temp_csv_file, ukt_test_helpers::{ get_mock_server_url, prepare_endpoint_mock, prepare_oauth2_mock, ENDPOINT_PATH, OAUTH2_PATH, }, AttributeMapping, Config, FeatureFlag, }; +use ldap3::{Ldap as LdapClient, LdapConnAsync, LdapConnSettings, Mod}; use tempfile::TempDir; use test_log::test; use tokio::sync::OnceCell; diff --git a/tests/environment/docker-compose.yaml b/tests/environment/docker-compose.yaml index 49e9002..e2f1dd5 100644 --- a/tests/environment/docker-compose.yaml +++ b/tests/environment/docker-compose.yaml @@ -17,7 +17,7 @@ services: read_only: true test-setup: - image: famedly/ldap-sync-testenv + image: famedly/famedly-sync-testenv build: context: ./test-setup entrypoint: /environment/test-setup.sh