Skip to main content

simplepam

An interface to the Pluggable Authentication Modules (PAM) library on linux, written in pure python (using ctypes)

Overview

This module provides an authenticate function that allows the caller to authenticate a given username / password against the PAM system on Linux.

Usage

Run python3 setup.py install as root to install the module, then import the authenticate function, and use it as follows:

from simplepam import authenticate
authenticate(username, password, service)

The full function signature is as follows:

authenticate(username, password, service='login', encoding='utf-8',
             resetcred=True)

The service argument specifies the PAM service to authenticate against. Defaults to login.

username, password and service can be given as strings or bytes. If they are strings, they will be encoded using the encoding given by the encoding parameter, or, if omitted, as UTF-8.

The function returns True if the authentication succeeds and returns False if authentication fails (or if PAM returns an error (FIXME)).

Python versions

This module works with both Python 2 and Python 3.

License

The original python-pam module was written by Chris AtLee, see the original copyright notice:

Copyright (C) 2007-2009 Chris AtLee <chris@atlee.ca>.
Licensed under the MIT license.

Modifications 2013-2014 by Leon Weber leon@leonweber.de:

  • Ported to Python3

  • Add call to pam_end()

  • Use ctypes.byref() instead of ctypes.pointer() to pass arguments by reference

  • Properly handle encoding of password, username and service (Patch by Sebastian Riese)

  • Add call to pam_reset() (Patch by Lertsenem)

  • Re-add Python2 support (Patch by Victor Stinner of eNovance)

This module is licensed under the MIT license.

Metadata

Release files for simplepam 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simplepam 0.1.5
File Size Uploaded
simplepam-0.1.5.tar.gz 2.4 kB Details

Release files / simplepam-0.1.5.tar.gz

Download URL simplepam-0.1.5.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9b4dd50da41a04dd6afff932b8b7e33c015af05beb3b3e5bcd323b64c2390a5f
BLAKE2b-256 checksum
How to use checksums
f5866e4446ea0b6a244a27d4cb806936bc00d349183669754287746ccf3a6c75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.5 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page