From f9e4502c96ac0a5b92cddf774b98e0c8b63488fa Mon Sep 17 00:00:00 2001 From: Anon Ray Date: Wed, 7 Aug 2024 11:53:12 +0530 Subject: [PATCH] add AuthConfig v2 example (#937) ### What - Added `AuthConfig` v2 config example in `static/auth/auth_config_v2.json` - Moved exisiting `auth_config.json` to `static/auth/` - Removed unused `pre_plugins.json` If one wants to start the engine with a v2 of AuthConfig, `static/auth/auth_config_v2.json` can be used. V3_GIT_ORIGIN_REV_ID: 471f8ae43ab02c2182457804a24b8445bb41f06c --- v3/README.md | 6 +++--- v3/crates/engine/src/authentication.rs | 2 +- v3/docker-compose.yaml | 2 +- v3/justfile | 6 +++--- v3/pre_plugins.json | 17 ----------------- v3/{ => static/auth}/auth_config.json | 0 v3/static/auth/auth_config_v2.json | 11 +++++++++++ 7 files changed, 19 insertions(+), 25 deletions(-) delete mode 100644 v3/pre_plugins.json rename v3/{ => static/auth}/auth_config.json (100%) create mode 100644 v3/static/auth/auth_config_v2.json diff --git a/v3/README.md b/v3/README.md index ce77d1c5fea..e6a8c62e89a 100644 --- a/v3/README.md +++ b/v3/README.md @@ -46,7 +46,7 @@ and the new V3 concepts. ```sh RUST_LOG=DEBUG cargo run --release --bin engine -- \ --metadata-path crates/open-dds/examples/reference.json \ - --authn-config-path auth_config.json + --authn-config-path static/auth/auth_config.json ``` A dev webhook implementation is provided in `crates/auth/dev-auth-webhook`, that @@ -81,7 +81,7 @@ You can also start v3-engine, along with a Postgres data connector and Jaeger for tracing using Docker: ```sh -METADATA_PATH=crates/engine/tests/schema.json AUTHN_CONFIG_PATH=auth_config.json docker compose up +METADATA_PATH=crates/engine/tests/schema.json AUTHN_CONFIG_PATH=static/auth/auth_config.json docker compose up ``` Open for GraphiQL, or to view @@ -220,7 +220,7 @@ v3-engine run with the chinook database as a data connector. To get this running, you can run the following command: ```bash -METADATA_PATH=crates/engine/tests/schema.json AUTHN_CONFIG_PATH=auth_config.json docker compose up postgres_connector engine +METADATA_PATH=crates/engine/tests/schema.json AUTHN_CONFIG_PATH=static/auth/auth_config.json docker compose up postgres_connector engine ``` ### Running tests with a single command diff --git a/v3/crates/engine/src/authentication.rs b/v3/crates/engine/src/authentication.rs index 35c5b782add..f9f11d0aa5e 100644 --- a/v3/crates/engine/src/authentication.rs +++ b/v3/crates/engine/src/authentication.rs @@ -148,7 +148,7 @@ mod tests { let mut path_buf = PathBuf::from(env!("CARGO_MANIFEST_DIR")); path_buf.pop(); path_buf.pop(); - path_buf.join("auth_config.json") + path_buf.join("static/auth/auth_config.json") }; let auth_config_from_json = ::deserialize( serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap(), diff --git a/v3/docker-compose.yaml b/v3/docker-compose.yaml index 484dda81a29..4e30d8852d8 100644 --- a/v3/docker-compose.yaml +++ b/v3/docker-compose.yaml @@ -21,7 +21,7 @@ services: auth_hook: condition: service_started volumes: - - ./auth_config.json:/app/auth_config.json + - ./static/auth/auth_config.json:/app/auth_config.json - ./crates/engine/tests/schema.json:/app/crates/engine/tests/schema.json - ./crates/open-dds/examples/reference.json:/app/crates/open-dds/examples/reference.json diff --git a/v3/justfile b/v3/justfile index d8eb31f664b..c14a479e7a8 100644 --- a/v3/justfile +++ b/v3/justfile @@ -33,7 +33,7 @@ run-local-with-shell: cargo run --bin dev-auth-webhook | ts "dev-auth-webhook:" & RUST_LOG=DEBUG cargo run --bin engine -- \ --otlp-endpoint http://localhost:4317 \ - --authn-config-path auth_config.json \ + --authn-config-path static/auth/auth_config.json \ --metadata-path crates/engine/tests/schema.json \ --expose-internal-errors | ts "engine: " & wait @@ -78,7 +78,7 @@ watch: start-docker-test-deps start-docker-run-deps -x 'clippy --no-deps' \ -x 'run --bin engine -- \ --otlp-endpoint http://localhost:4317 \ - --authn-config-path auth_config.json \ + --authn-config-path static/auth/auth_config.json \ --metadata-path crates/engine/tests/schema.json \ --expose-internal-errors' @@ -134,7 +134,7 @@ update-custom-connector-schema-in-test-metadata: && fix-format run: start-docker-test-deps start-docker-run-deps RUST_LOG=DEBUG cargo run --bin engine -- \ --otlp-endpoint http://localhost:4317 \ - --authn-config-path auth_config.json \ + --authn-config-path static/auth/auth_config.json \ --metadata-path crates/engine/tests/schema.json \ --expose-internal-errors diff --git a/v3/pre_plugins.json b/v3/pre_plugins.json deleted file mode 100644 index a41b56fc78f..00000000000 --- a/v3/pre_plugins.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "version": "v1", - "definition": { - "name": "example", - "url": "http://localhost:5000/allow_list", - "request": { - "headers": false, - "session": true, - "rawRequest": { - "query": true, - "variables": true - } - } - } - } -] diff --git a/v3/auth_config.json b/v3/static/auth/auth_config.json similarity index 100% rename from v3/auth_config.json rename to v3/static/auth/auth_config.json diff --git a/v3/static/auth/auth_config_v2.json b/v3/static/auth/auth_config_v2.json new file mode 100644 index 00000000000..432cc4f9b4c --- /dev/null +++ b/v3/static/auth/auth_config_v2.json @@ -0,0 +1,11 @@ +{ + "version": "v2", + "definition": { + "mode": { + "webhook": { + "url": "http://auth_hook:3050/validate-request", + "method": "Post" + } + } + } +}