A Python library for enforcing password policies and compliance
Project description
Password Policy Compliance Library
A Python library that helps enforce password policies, ensuring password compliance with best practices and industry standards.
Features
- Password validation against customizable security policies
- Pre-defined policies based on industry standards (NIST, PCI DSS, HIPAA, SOX, GDPR)
- Custom policy creation
- Password expiration management
- Compliance reporting and auditing
- Password strength assessment using zxcvbn
- Crack time estimation
- Blacklist checking (local and HaveIBeenPwned integration)
- Password generation
Installation
To install the Password Policy Compliance Library, run:
pip install password-policy-compliance
Quick Start
Here's a quick example of how to use the library with a predefined policy:
from password_policy_compliance import password_validator, policy_compliance, password_strength
# Get a predefined policy
nist_policy = policy_compliance.get_policy("NIST")
# Validate a password
password = "MyStr0ngP@ssw0rd"
result = password_validator.validate_password(password, nist_policy)
if result["valid"]:
print(f"Password '{password}' is valid according to NIST policy!")
strength_result = password_strength.calculate_password_strength(password)
print(f"Password strength score: {strength_result['score']}/100")
print("Estimated crack times:")
for scenario, time in strength_result["crack_times_display"].items():
print(f" {scenario}: {time}")
else:
print(f"Password '{password}' is invalid. Errors:")
for error in result["errors"]:
print(f"- {error}")
# Create a custom policy
custom_policy = policy_compliance.create_policy(
name="Custom",
min_length=12,
require_uppercase=True,
require_lowercase=True,
require_digits=True,
require_special=True,
expiration_days=90,
warning_days=14
)
# Validate against custom policy
result = password_validator.validate_password(password, custom_policy)
print(f"Password valid for custom policy: {result['valid']}")
Documentation
For detailed information on how to use all features of the Password Policy Compliance Library, please refer to our User Guide.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Author
Bassem Abidi (abidi.bassem@me.com)
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file password_policy_compliance-0.2.0.tar.gz
.
File metadata
- Download URL: password_policy_compliance-0.2.0.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f305a3b140ecfacbd3767c5f48a3ccd7a0f3b0d1113866354fa010964220948 |
|
MD5 | 972fa4b560887bb856fa07bb42a56748 |
|
BLAKE2b-256 | 36d402f8ba119892e6a697f41044c6d498500a17eef53aed4357f70b9a269795 |
File details
Details for the file password_policy_compliance-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: password_policy_compliance-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfb38619ce1672c3cbc5260490e5f83f61fd60f35d22779686e6cb493ac36006 |
|
MD5 | baaa6a69cb0d9f97b26bfee58159a95b |
|
BLAKE2b-256 | e1ebfc0e78c471c944e23c9da9a84061b3a72d85ded81fc6f0bcd4a16a461f2a |