From 5b651efae1f7279f578dfd663567a62ba165e814 Mon Sep 17 00:00:00 2001 From: Andrew Dias Date: Wed, 14 Aug 2024 17:34:18 -0400 Subject: [PATCH 1/7] feat: enable integrated-auth-gssapi tiberius feature This should extend support for MSSQL integrated authentication to *nix systems. Prisma currently only supports this feature on Windows. --- Cargo.lock | 46 ++++++++++++++++++++++++++++++++++++++++++++++ quaint/Cargo.toml | 3 ++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 626842538144..c286112dfeba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -292,14 +292,18 @@ dependencies = [ "bitflags 1.3.2", "cexpr", "clang-sys", + "clap 2.34.0", + "env_logger", "lazy_static", "lazycell", + "log", "peeking_take_while", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", + "which", ] [[package]] @@ -1339,6 +1343,19 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "env_logger" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -1931,6 +1948,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "0.14.27" @@ -2292,6 +2315,28 @@ version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +[[package]] +name = "libgssapi" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "724dbcd1f871da9c67983537a47ac510c278656f6392418ad67c7a52720e54b2" +dependencies = [ + "bitflags 1.3.2", + "bytes", + "lazy_static", + "libgssapi-sys", + "parking_lot 0.11.2", +] + +[[package]] +name = "libgssapi-sys" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd7d65e409c889f6c9d81ff079371d0d8fd88d7dca702ff187ef96fb0450fb7" +dependencies = [ + "bindgen", +] + [[package]] name = "libloading" version = "0.7.4" @@ -5684,6 +5729,7 @@ dependencies = [ "futures", "futures-sink", "futures-util", + "libgssapi", "num-traits", "once_cell", "opentls", diff --git a/quaint/Cargo.toml b/quaint/Cargo.toml index 89507de20635..27185292c9f7 100644 --- a/quaint/Cargo.toml +++ b/quaint/Cargo.toml @@ -128,7 +128,7 @@ optional = true [target.'cfg(not(any(target_os = "macos", target_os = "ios")))'.dependencies.tiberius] version = "0.11.8" optional = true -features = ["sql-browser-tokio", "chrono", "bigdecimal"] +features = ["sql-browser-tokio", "chrono", "bigdecimal", "integrated-auth-gssapi"] [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.tiberius] version = "0.11.8" @@ -141,6 +141,7 @@ features = [ "bigdecimal", "tds73", "winauth", + "integrated-auth-gssapi" ] [dependencies.bigdecimal] From 1e2e66b4ef74ba8046864d2fa66fb6f50ca74391 Mon Sep 17 00:00:00 2001 From: Andrew Dias Date: Tue, 27 Aug 2024 00:09:41 -0400 Subject: [PATCH 2/7] Install libkrb5 on ubuntu in tests --- .github/workflows/test-compilation.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test-compilation.yml b/.github/workflows/test-compilation.yml index 3db71c67b5e7..1e9435717342 100644 --- a/.github/workflows/test-compilation.yml +++ b/.github/workflows/test-compilation.yml @@ -41,6 +41,10 @@ jobs: target key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: install kerberos dependencies on Ubuntu + if: matrix.os == 'ubuntu-latest' + run: sudo apt-get update && sudo apt-get install -y libkrb5-dev + - name: compile ${{ matrix.crate }} shell: bash env: From dea9f04a8643fd3d1424ffa15252ab3a5341717b Mon Sep 17 00:00:00 2001 From: Andrew Dias Date: Tue, 27 Aug 2024 23:47:51 -0400 Subject: [PATCH 3/7] Attempt to fix tests by installing kerberos dependencies in ubuntu images --- .github/workflows/codspeed.yml | 1 + .github/workflows/formatting.yml | 1 + .github/workflows/include/kerberos-setup/action.yml | 12 ++++++++++++ .github/workflows/publish-query-engine-wasm.yml | 2 ++ .github/workflows/test-compilation.yml | 5 +---- .github/workflows/test-quaint.yml | 2 ++ .github/workflows/test-query-engine-black-box.yml | 2 ++ .github/workflows/test-query-engine-template.yml | 1 + .github/workflows/test-schema-engine.yml | 2 ++ .github/workflows/test-unit-tests.yml | 1 + .github/workflows/wasm-benchmarks.yml | 2 ++ 11 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/include/kerberos-setup/action.yml diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index f5958960cd62..add93d3b3c53 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -23,6 +23,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: ./.github/workflows/include/kerberos-setup - name: Install cargo-codspeed run: cargo install --locked cargo-codspeed diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index c766cd27ea21..7ea651ae4160 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -29,6 +29,7 @@ jobs: with: components: clippy targets: wasm32-unknown-unknown + - uses: ./.github/workflows/include/kerberos-setup # Check the whole workspace with clippy for the native compilation # target, and query-engine-wasm and dependencies for wasm32-unknown-unknown. # Note that `--all-targets` is unrelated to `--target` as in target platform, diff --git a/.github/workflows/include/kerberos-setup/action.yml b/.github/workflows/include/kerberos-setup/action.yml new file mode 100644 index 000000000000..28b2ea4d211c --- /dev/null +++ b/.github/workflows/include/kerberos-setup/action.yml @@ -0,0 +1,12 @@ +name: Kerberos deps +description: Install the libkrb5-dev package on Ubuntu. This is required by tiberius when integrated-auth-gssapi is enabled. + +runs: + using: "composite" + steps: + - name: Install libkrb5-dev + if: runner.os == 'Linux' + shell: bash + run: | + apt update + apt install -y libkrb5-dev diff --git a/.github/workflows/publish-query-engine-wasm.yml b/.github/workflows/publish-query-engine-wasm.yml index bba9dc1eb658..c9308c2d5d9b 100644 --- a/.github/workflows/publish-query-engine-wasm.yml +++ b/.github/workflows/publish-query-engine-wasm.yml @@ -32,6 +32,8 @@ jobs: - uses: ./.github/workflows/include/rust-wasm-setup + - uses: ./.github/workflows/include/kerberos-setup + - name: Build @prisma/query-engine-wasm run: make build-qe-wasm env: diff --git a/.github/workflows/test-compilation.yml b/.github/workflows/test-compilation.yml index 1e9435717342..63de2c160370 100644 --- a/.github/workflows/test-compilation.yml +++ b/.github/workflows/test-compilation.yml @@ -40,10 +40,7 @@ jobs: ~/.cargo/git target key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - name: install kerberos dependencies on Ubuntu - if: matrix.os == 'ubuntu-latest' - run: sudo apt-get update && sudo apt-get install -y libkrb5-dev + - uses: ./.github/workflows/include/kerberos-setup - name: compile ${{ matrix.crate }} shell: bash diff --git a/.github/workflows/test-quaint.yml b/.github/workflows/test-quaint.yml index 62aa722e3955..2d4146acc1a8 100644 --- a/.github/workflows/test-quaint.yml +++ b/.github/workflows/test-quaint.yml @@ -37,6 +37,8 @@ jobs: target key: ${{ runner.os }}-cargo-${{ matrix.features }} + - uses: ./.github/workflows/include/kerberos-setup + - name: Start Databases run: docker compose -f docker-compose.yml up -d working-directory: ./quaint diff --git a/.github/workflows/test-query-engine-black-box.yml b/.github/workflows/test-query-engine-black-box.yml index fa332d44799a..7bedebecd75c 100644 --- a/.github/workflows/test-query-engine-black-box.yml +++ b/.github/workflows/test-query-engine-black-box.yml @@ -47,6 +47,8 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: ./.github/workflows/include/kerberos-setup + - name: Login to Docker Hub uses: docker/login-action@v3 continue-on-error: true diff --git a/.github/workflows/test-query-engine-template.yml b/.github/workflows/test-query-engine-template.yml index 5a9c3d692d7c..765bb5564635 100644 --- a/.github/workflows/test-query-engine-template.yml +++ b/.github/workflows/test-query-engine-template.yml @@ -51,6 +51,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: taiki-e/install-action@nextest + - uses: ./.github/workflows/include/kerberos-setup - name: Login to Docker Hub uses: docker/login-action@v3 diff --git a/.github/workflows/test-schema-engine.yml b/.github/workflows/test-schema-engine.yml index a661fd0554c8..cfedae48a75f 100644 --- a/.github/workflows/test-schema-engine.yml +++ b/.github/workflows/test-schema-engine.yml @@ -37,6 +37,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: taiki-e/install-action@nextest + - uses: ./.github/workflows/include/kerberos-setup - name: Login to Docker Hub uses: docker/login-action@v3 @@ -109,6 +110,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: taiki-e/install-action@nextest + - uses: ./.github/workflows/include/kerberos-setup - name: Login to Docker Hub uses: docker/login-action@v3 diff --git a/.github/workflows/test-unit-tests.yml b/.github/workflows/test-unit-tests.yml index ba9ea0f69b40..8cb2a3744807 100644 --- a/.github/workflows/test-unit-tests.yml +++ b/.github/workflows/test-unit-tests.yml @@ -26,6 +26,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: ./.github/workflows/include/kerberos-setup - run: | cargo test --workspace --all-features \ diff --git a/.github/workflows/wasm-benchmarks.yml b/.github/workflows/wasm-benchmarks.yml index cfbe4ca7b531..e5507eccff27 100644 --- a/.github/workflows/wasm-benchmarks.yml +++ b/.github/workflows/wasm-benchmarks.yml @@ -28,6 +28,8 @@ jobs: - uses: ./.github/workflows/include/rust-wasm-setup + - uses: ./.github/workflows/include/kerberos-setup + - name: "Setup Node.js" uses: actions/setup-node@v4 From 32580862d5f406874407ac4861c81baa48d962c8 Mon Sep 17 00:00:00 2001 From: Andrew Dias Date: Tue, 27 Aug 2024 23:52:39 -0400 Subject: [PATCH 4/7] Fix kerberos install script --- .github/workflows/include/kerberos-setup/action.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/include/kerberos-setup/action.yml b/.github/workflows/include/kerberos-setup/action.yml index 28b2ea4d211c..2bf834a78e14 100644 --- a/.github/workflows/include/kerberos-setup/action.yml +++ b/.github/workflows/include/kerberos-setup/action.yml @@ -7,6 +7,4 @@ runs: - name: Install libkrb5-dev if: runner.os == 'Linux' shell: bash - run: | - apt update - apt install -y libkrb5-dev + run: sudo apt update && sudo apt install -y libkrb5-dev From 204162d8f57f0ccebfe7c60c7b1e1a393ef534e3 Mon Sep 17 00:00:00 2001 From: Andrew Dias Date: Wed, 28 Aug 2024 09:49:34 -0400 Subject: [PATCH 5/7] Add kerberos install step to driver adapter tests --- .github/workflows/include/kerberos-setup/action.yml | 2 +- .github/workflows/test-driver-adapters-template.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/include/kerberos-setup/action.yml b/.github/workflows/include/kerberos-setup/action.yml index 2bf834a78e14..c71ef2213927 100644 --- a/.github/workflows/include/kerberos-setup/action.yml +++ b/.github/workflows/include/kerberos-setup/action.yml @@ -7,4 +7,4 @@ runs: - name: Install libkrb5-dev if: runner.os == 'Linux' shell: bash - run: sudo apt update && sudo apt install -y libkrb5-dev + run: sudo apt-get update && sudo apt-get install -y libkrb5-dev diff --git a/.github/workflows/test-driver-adapters-template.yml b/.github/workflows/test-driver-adapters-template.yml index eb45af278bc4..c263bc160f0c 100644 --- a/.github/workflows/test-driver-adapters-template.yml +++ b/.github/workflows/test-driver-adapters-template.yml @@ -67,6 +67,7 @@ jobs: fi - uses: ./.github/workflows/include/rust-wasm-setup + - uses: ./.github/workflows/include/kerberos-setup - uses: taiki-e/install-action@nextest - name: Setup From 8f85bed0288cf5273a54e7fa3930623520887cb9 Mon Sep 17 00:00:00 2001 From: Andrew Dias Date: Wed, 28 Aug 2024 11:26:21 -0400 Subject: [PATCH 6/7] Enable integrated-auth-gssapi feature for all unix family OSs --- quaint/Cargo.toml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/quaint/Cargo.toml b/quaint/Cargo.toml index 27185292c9f7..bb0a03c4f7ab 100644 --- a/quaint/Cargo.toml +++ b/quaint/Cargo.toml @@ -125,10 +125,15 @@ version = "0.31" features = ["chrono", "column_decltype"] optional = true +[target.'cfg(target_family = "unix")'.dependencies.tiberius] +version = "0.11.8" +optional = true +features = ["integrated-auth-gssapi"] + [target.'cfg(not(any(target_os = "macos", target_os = "ios")))'.dependencies.tiberius] version = "0.11.8" optional = true -features = ["sql-browser-tokio", "chrono", "bigdecimal", "integrated-auth-gssapi"] +features = ["sql-browser-tokio", "chrono", "bigdecimal"] [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.tiberius] version = "0.11.8" @@ -141,7 +146,6 @@ features = [ "bigdecimal", "tds73", "winauth", - "integrated-auth-gssapi" ] [dependencies.bigdecimal] From d6b0a74fc92eba9c77ec0b0b34a40bd5186d9610 Mon Sep 17 00:00:00 2001 From: Andrew Dias Date: Wed, 28 Aug 2024 13:36:50 -0400 Subject: [PATCH 7/7] Adjust tiberius config for linux os --- quaint/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaint/Cargo.toml b/quaint/Cargo.toml index bb0a03c4f7ab..ec34727abfa5 100644 --- a/quaint/Cargo.toml +++ b/quaint/Cargo.toml @@ -125,7 +125,7 @@ version = "0.31" features = ["chrono", "column_decltype"] optional = true -[target.'cfg(target_family = "unix")'.dependencies.tiberius] +[target.'cfg(target_os = "linux")'.dependencies.tiberius] version = "0.11.8" optional = true features = ["integrated-auth-gssapi"]