feat(drivers): Windows integrated (Kerberos) auth for SQL Server (#1961) - #1962
feat(drivers): Windows integrated (Kerberos) auth for SQL Server (#1961)#1962Seha16 wants to merge 4 commits into
Conversation
|
Testing evidence on Arch Linux Kernel 7.1.5 with krb5 (Kerberos) with default_realm patched to the needed one: kerberos-testing.mp4 |
|
Pushed Kerberos through an SSH tunnel was asking for the wrong SPN
The socket and the service name are now separate: Kerberos was writing a password into the keyring
Auth mode no longer lives in widget visibility
That also fixes two things the visibility coupling had introduced:
Kerberos is a cargo feature now
Debug builds no longer abort[profile.dev.package.libgssapi]
debug-assertions = falseThe UB precondition check is emitted per crate, so turning it off for that one package makes Also
Two things I did not doThe flatpak manifest is unverified.
Cargo.lock is unchanged: |
fefd543 to
c055475
Compare
|
Testing evidence on Arch Linux Kernel 7.1.4 after rebasing onto the screenrecording-2026-07-27_14-51-18.mp4 |
…bort debug builds tiberius 0.12.3 (its latest release) pins libgssapi ^0.4.5. On a successful GSSAPI handshake the KDC returns an empty final token (value=NULL, length=0), and libgssapi 0.4.6's `Buf::deref` calls `slice::from_raw_parts(NULL, 0)` -- undefined behavior that trips the standard library's precondition check and aborts (SIGABRT) at util.rs:237. Every Kerberos login therefore crashes under a debug build (`cargo run`); the previously committed per-package `debug-assertions = false` override did not reliably suppress it and left the UB in place regardless. tiberius already fixed this on `main` (merged PR prisma/tiberius#372: bump libgssapi 0.4.5 -> 0.8.x, whose deref guards the null/empty case), but has not cut a release; the bug is tracked open as prisma/tiberius#343. Pin the fixed commit (a6b4fcdae0de5702427290b89f8d05bc51f3bcfa) via [patch.crates-io] so libgssapi resolves to the guarded 0.8.3. Drop this patch and bump the `tiberius` version once a release ships. No TablePro code changes -- the mssql driver builds unchanged.
edcbf97 to
8fcca0c
Compare
Kerberos login is unchanged for users: the connect dialog still offers Method -> Password / Windows (Kerberos), and AuthMode::Kerberos still maps to tiberius AuthMethod::Integrated. What goes away is the opt-out around it. The mssql `kerberos` cargo feature existed so a packager without MIT Kerberos could drop it, but ADR 0001 statically links every driver into one binary, so there is no unit to swap and no packager to serve. The tiberius `integrated-auth-gssapi` feature moves to the workspace dep and the opt-out's whole tail goes with the feature: DriverError::Unsupported and its UI string, the authentication_for indirection, the extra CI job, and the build-without-Kerberos README block. Alongside it, the rest of the branch's over-engineering: - ServiceEndpoint (one construction site) becomes Option<(String, u16)>, service_address() a single map_or. - collect_options() derives blanked credentials from shows_credentials() instead of re-deriving the mode per field, so the two cannot drift. - selected_auth_mode() dropped; callers use form.mode(). - Eight assertion-per-test cases collapse into one table test each for AuthFormState and service_address; the tests asserting #[derive(Default)] and re-testing serde round-trip are gone, the legacy-file default (real data-loss risk) stays. - Comments that restated the line under them, or duplicated another file's comment, removed. Verified: cargo fmt --check, clippy -D warnings, 279 unit tests, full workspace link (gssapi_krb5 now links unconditionally), app launches. A scratch test confirmed AuthMode::Kerberos reaches the socket and fails with ConnectionRefused rather than being compiled out.
|
Testing evidence after refactoring of Kerberos/Windows Auth screenrecording-2026-07-28_12-25-32.mp4 |
Summary
Adds Windows integrated authentication (Kerberos / GSSAPI) to the Linux SQL Server driver — connect with your
kinitticket instead of a SQL login. Fixes #1961.core:AuthMode { Password, Kerberos }+ConnectOptions.auth_mode;DatabaseDriver::supports_integrated_auth()(defaultfalse).drivers/mssql: tiberiusintegrated-auth-gssapifeature;connect()usesAuthMethod::Integratedfor Kerberos (ambient credential cache, SPNMSSQLSvc/<host>:<port>).storage:SavedConnection.auth_modepersisted (legacy files default toPassword).app: connect-dialog "Method" selector, shown only for integrated-capable drivers; Kerberos hides username/password; validity / label / dedup updated.libkrb5-devandclang(libgssapi-sys linksgssapi_krb5and runs bindgen).Depends on #1958
This branch is stacked on the SQL Server driver PR (#1958). Until that merges, this PR's diff also contains #1958's commit (
feat(drivers): add SQL Server driver via tiberius). Please review/merge after #1958 — the diff then reduces to the single Kerberos commit.Test plan
cargo build --workspace;cargo test --workspace --lib(core + storageauth_moderound-trip/legacy default; mssqlsupports_integrated_auth)cargo fmt --all -- --check;cargo clippy --all-targets -- -D warningsKnown upstream-crate limitations (with workarounds)
default_realm(+[capaths]/[domain_realm]) soMSSQLSvc/<host>:<port>maps to the service realm. Proper fix: host-based SPN (GSS_C_NT_HOSTBASED_SERVICE) upstream in tiberius.slice::from_raw_parts(null, 0), tripping Rust's UB precondition check (debug only). Run a release build (debug-assertions off) for Kerberos. Proper fix: null-guard upstream in libgssapi (0.4.6 is the latest^0.4.5).Neither limitation affects CI (build + unit tests; no live handshake) or the SQL-login path.