3 releases (breaking)

0.8.0 Nov 1, 2023
0.7.0 Feb 7, 2019
0.0.2 Mar 6, 2015
0.0.1 Mar 6, 2015

#68 in Authentication

Download history 156/week @ 2023-11-23 96/week @ 2023-11-30 120/week @ 2023-12-07 139/week @ 2023-12-14 170/week @ 2023-12-21 85/week @ 2023-12-28 126/week @ 2024-01-04 212/week @ 2024-01-11 142/week @ 2024-01-18 117/week @ 2024-01-25 140/week @ 2024-02-01 145/week @ 2024-02-08 226/week @ 2024-02-15 270/week @ 2024-02-22 432/week @ 2024-02-29 145/week @ 2024-03-07

1,099 downloads per month
Used in 7 crates (6 directly)

MIT/Apache

46KB
773 lines

pam - Safe Rust API to the Linux Pluggable Authentication Modules (PAM)

Crates.io Documentation Build Status License

Note: Currently only supports basic username/password authentication out-of-the-box.

Warning

Environment support through the env module is probably broken and should not be used in the current state!

Usage

  1. Add pam to your Cargo.toml:
[dependencies]
pam = "0.7.0"
  1. Use the Authenticator struct to authenticate and open a session
extern crate pam;
pub fn main() {
        let service = "<yourapp>";
        let user = "<user>";
        let password = "<pass>";

        let mut auth = pam::Authenticator::with_password(service).unwrap();
        auth.handler_mut().set_credentials(user, password);
        if auth.authenticate().is_ok() && auth.open_session().is_ok() {
            println!("Successfully opened a session!");
        }
        else {
            println!("Authentication failed =/");
        }
}

TODO:

  • Implement basic user/password authentication
  • Add Authenticator struct
  • Add (more) documentation
  • Verify current conv does not leak memory
  • Allow custom conv functions to be passed
  • Code cleanup

Supported Rust versions

The library is only continuously built against Rust stable, beta and nightly but as it does not use a lot of new language features it should probably compile on older versions as well. If you encounter problems building on older versions and a small fix can be applied to make the build succeed, consider opening a pull request.

Note about stability

This crate follows semantic versioning. As such all versions below 1.0.0 should be considered development versions. This means the API could change any time.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1.2–3.5MB
~72K SLoC