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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.020s · 19.2MB
glibcpy 3.10–3.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}")
Upgrade
Version history
0.6.2latest on PyPI · released Oct 14, 2019
Audit
Dependencies
No dependency data recorded yet.