Registry / auth-security / pure-sasl

pure-sasl

JSON →
library0.6.2pypypi✓ verified 27d ago

`pure-sasl` is a pure Python client-side implementation of the Simple Authentication and Security Layer (SASL) protocol. It enables Python applications to authenticate securely against servers using various SASL mechanisms like PLAIN, SCRAM-SHA-1, SCRAM-SHA-256, and GSSAPI (with an optional dependency). The current version is 0.6.2, and it maintains a moderate release cadence, with the latest update in March 2024.

pip install pure-sasl
INSTALL
IMPORT
SIG · PURE-SASL
P
pure-sasl
auth-securitypythonv0.6.2
Install
2.4s avg
Import
20ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.020s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.020s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SASLClient
from puresasl.client import SASLClient
from pure_sasl.client import SASLClient

This example demonstrates how to initialize a `SASLClient` for the PLAIN mechanism and process an initial (potentially empty) server challenge. For multi-step mechanisms like SCRAM, you would repeat the `client.process()` call for subsequent server challenges and client responses until `client.complete` is true.

import os from pure_sasl.client import SASLClient # Retrieve credentials from environment variables or provide defaults # In a real application, these would come from configuration or user input. username = os.environ.get("SASL_USERNAME", "myuser") password = os.environ.get("SASL_PASSWORD", "mypassword") # 1. Initialize the SASL client with the desired mechanism and credentials. # Common mechanisms: 'PLAIN', 'SCRAM-SHA-1', 'SCRAM-SHA-256'. try: client = SASLClient( mechanism='PLAIN', username=username, password=password ) print(f"SASLClient initialized for PLAIN mechanism with user: {username}") # 2. Process the initial challenge from the server. # For PLAIN, the initial challenge is typically an empty bytes string. # In a real network exchange, this comes from the server. server_challenge_1 = b'' client_response_1 = client.process(server_challenge_1) print(f"Client response to initial challenge: {client_response_1!r}") # 3. If authentication requires more steps (e.g., SCRAM), # the server would send another challenge, which you'd pass to .process() again. # For PLAIN, the process is often complete after the first response. if client.complete: print("SASL PLAIN authentication sequence complete.") else: print("Authentication not yet complete. Awaiting further server challenges.") except Exception as e: print(f"Error during SASL client operation: {e}")
Debug
Known issues
gotchaPure-SASL is a client-side library. It provides client implementations for various SASL mechanisms but does not offer server-side SASL functionality. Users needing server-side SASL should look for alternative libraries.
fix
Understand the library's scope and choose appropriate tools for server-side SASL needs.
affects: All versions
gotchaThe GSSAPI (Kerberos) SASL mechanism requires the separate `gssapi` Python library to be installed (e.g., `pip install gssapi`). `pure-sasl` itself does not bundle GSSAPI support and will raise an error if GSSAPI is used without the dependency.
fix
Install `gssapi` explicitly if you intend to use the GSSAPI mechanism.
affects: All versions
gotchaWhile `pure-sasl` handles the internal logic of SASL mechanisms, correct usage requires a clear understanding of the SASL challenge-response protocol. Developers must manage the network communication (sending client responses, receiving server challenges) correctly.
fix
Familiarize yourself with the SASL protocol flow for your chosen mechanism to correctly integrate the library with your network communication layer.
affects: All versions
Upgrade
Version history
0.6.2latest on PyPI · released Oct 14, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
47 hits · last 30 days
node
42
OpenAI (training)
1
Resources
pure-sasl — pip install pure-sasl · libregistry