Skip to content

feat(auth): SSPI/NTLM Windows authentication on Unix via sspi-rs - #17

Merged
MattJackson merged 1 commit into
devfrom
feat/sspi-ntlm-linux
Aug 29, 2026
Merged

feat(auth): SSPI/NTLM Windows authentication on Unix via sspi-rs#17
MattJackson merged 1 commit into
devfrom
feat/sspi-ntlm-linux

Conversation

@MattJackson

@MattJackson MattJackson commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Summary

Integrates the intent of upstream PR #408 onto the current dev branch: SSPI/NTLM Windows authentication on Unix (Linux/macOS) without Kerberos, via the pure-Rust sspi crate. This lets Unix clients use AuthMethod::Windows / IntegratedSecurity=SSPI with an explicit username/password, closing the gap that previously required a full GSSAPI/Kerberos setup (#407, #276, #97).

Changes

  • New optional feature sspi-rs (sspi-rs = ["sspi"]) with sspi = { version = "0.18", optional = true } under the cfg(unix) target; added to the all feature so it is covered by clippy --features=all and docs.rs.
  • AuthMethod: WindowsAuth, the Windows variant and the windows() constructor are now available on all(unix, feature = "sspi-rs") in addition to the existing Windows winauth path.
  • Connection::login: implements the two-leg NTLM negotiate/authenticate exchange for the Unix sspi-rs path, reusing the existing SSPI token flushing and integrated_security login plumbing (spn, TokenSspi, flush_sspi).
  • Connection-string parsing: IntegratedSecurity=SSPI (or a truthy value) now selects NTLM when a username/password is present, and falls back to Kerberos (Integrated) only when integrated-auth-gssapi is enabled and no credentials are given. The gssapi arm is disabled only when sspi-rs is active on Unix, avoiding overlapping match arms.
  • Errors: adds Error::SspiRs and From<sspi::Error>.
  • Reconciled with the existing zeroized SQL-auth handling, Windows winauth, and Unix integrated-auth-gssapi paths — no duplication or downgrades.

Verification

  • cargo build (default) — ok
  • cargo build --features sspi-rs — ok
  • cargo clippy --features=all -- -D warnings — clean
  • cargo test --lib — 235 pass; added a unit test for the IntegratedSecurity=SSPI + credentials -> NTLM connection-string path
  • cargo fmt --check — clean
  • isolated integrated-auth-gssapi-only and sspi-rs-only builds — ok

Draft: the actual NTLM handshake against a server can only be validated against a live SQL Server instance accepting Windows/NTLM authentication, which is not available in CI here.

Add an optional `sspi-rs` feature that enables `AuthMethod::Windows`
(and `AuthMethod::windows()`) on Unix platforms, implementing the NTLM
handshake with the pure-Rust `sspi` crate. This provides Windows-style
authentication without requiring a Kerberos/GSSAPI setup, closing the
gap for Linux and macOS clients (#407, #276, #97).

- Add `sspi` (unix target) dependency and `sspi-rs` feature; include it
  in the `all` feature set.
- Gate `WindowsAuth`, the `AuthMethod::Windows` variant and the
  `windows()` constructor on `all(unix, feature = "sspi-rs")` in addition
  to the existing Windows `winauth` path.
- Implement the two-leg NTLM negotiate/authenticate exchange in
  `Connection::login` for the Unix `sspi-rs` path, reusing the existing
  SSPI token flushing and `integrated_security` login plumbing.
- Extend the connection-string parser so `IntegratedSecurity=SSPI`
  selects NTLM when a username/password is supplied and falls back to
  Kerberos (`Integrated`) only when `integrated-auth-gssapi` is enabled
  and no credentials are given.
- Add an `Error::SspiRs` variant and `From<sspi::Error>` conversion.

The existing Windows `winauth` and Unix `integrated-auth-gssapi` paths
are left intact; the gssapi connection-string arm is only disabled when
`sspi-rs` is active on Unix to avoid overlapping match arms.
@MattJackson
MattJackson merged commit 68b4219 into dev Aug 29, 2026
@MattJackson
MattJackson deleted the feat/sspi-ntlm-linux branch August 29, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant