#ntlm #auth #sspi #windows #kerberos

sspi

A Rust implementation of the Security Support Provider Interface (SSPI) API

10 unstable releases (4 breaking)

Uses new Rust 2021

0.5.2 Nov 17, 2022
0.4.0 Aug 11, 2022
0.3.6 Jun 17, 2022
0.3.2 Aug 26, 2021
0.2.0 Jul 18, 2019

#78 in Authentication

Download history 139/week @ 2022-08-04 163/week @ 2022-08-11 159/week @ 2022-08-18 109/week @ 2022-08-25 184/week @ 2022-09-01 164/week @ 2022-09-08 191/week @ 2022-09-15 150/week @ 2022-09-22 162/week @ 2022-09-29 132/week @ 2022-10-06 97/week @ 2022-10-13 150/week @ 2022-10-20 129/week @ 2022-10-27 138/week @ 2022-11-03 153/week @ 2022-11-10 158/week @ 2022-11-17

607 downloads per month

MIT/Apache

610KB
12K SLoC

sspi-rs

Build Status

sspi-rs is a Rust implementation of Security Support Provider Interface (SSPI). It ships with platform-independent implementations of Security Support Providers (SSP), and is able to utilize native Microsoft libraries when ran under Windows.

The purpose of sspi-rs is to clean the original interface from cluttering and provide users with Rust-friendly SSPs for execution under *nix or any other platform that is able to compile Rust.

Overview

The sspi-rs works in accordance with the MSDN documentation. At the moment, NT LAN Manager (NTLM) is implemented and available for platform independent execution. It is also possible to create your own SSPs by implementing the SspiImpl trait. More on that in the Documentation.

WinAPI

You can switch between the sspi module to use the platform independent implementations of the SSPs, and the sspi::winapi module to use the native Windows libraries when running under Windows.

Ease of use

Some SSPI functions tend to be cumbersome, that's why sspi-rs allows to use SSPI in a convenient way by utilizing builders. Examples are available in the examples, example section, and Documentation.

Usage

sspi-rs is included in the Cargo.toml like this:

[dependencies]
sspi = "0.1.0"

After that you can use the types that you need.

Documentation

Documentation will give you a comprehensive overlook of the crate. For the example of a simple use case, visit the examples folder.

Example

The usage of the SSPs is as simple as creating an instance of the security provider and calling its functions.

It is easy to switch between Windows and our SSP implementations. Here is an example of acquiring a credentials handle and a timestamp of their vaidity. The source of Ntlm is selected automatically depending on the platform:

#[cfg(windows)]
use sspi::{winapi::Ntlm, Sspi, CredentialUse};
#[cfg(unix)]
use sspi::{Ntlm, Sspi, CredentialUse};

fn main() {
    let mut ntlm = Ntlm::new();
        
    let (cred_handle, timestamp) = ntlm
        .acquire_credentials_handle()
        .with_credential_use(CredentialUse::Inbound)
        .execute()
        .unwrap();
}

Example of acquiring an SSP provided by Windows:

let mut negotiate = SecurityPackage::from_package_type(
    SecurityPackageType::Other(String::from("Negotiate"))
);

Projects that use sspi-rs

License

sspi-rs is licensed under MIT license.

Dependencies

~9–64MB
~1M SLoC