Skip to main content

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
  • Policy compliance checking
  • Compliance reporting and auditing

Installation

To install the Password Policy Compliance Library, run:

pip install password-policy-compliance

Usage

Here's a quick example of how to use the library:

from password_policy_compliance import password_validator, policy_compliance, compliance_reporter

# Create a policy
policy = policy_compliance.Policy(
    name="Custom Policy",
    min_length=8,
    require_uppercase=True,
    require_lowercase=True,
    require_digits=True,
    require_special=True
)

# Validate a password
password = "MyP@ssw0rd"
result = password_validator.validate_password(password, policy)

if result["valid"]:
    print(f"Password '{password}' is valid!")
else:
    print(f"Password '{password}' is invalid. Errors:")
    for error in result["errors"]:
        print(f"- {error}")

# Generate a compliance report
passwords = ["StrongP@ss1", "weakpass", "NoSpecial1", "sh0rt", "AllLowercase123!"]
report = compliance_reporter.generate_compliance_report(passwords, policy)
print(f"\nCompliance report:")
print(f"Total passwords: {report['total_passwords']}")
print(f"Compliant passwords: {report['compliant_passwords']}")
print(f"Non-compliant passwords: {report['non_compliant_passwords']}")
print(f"Compliance rate: {report['compliance_rate']}%")

# Audit password compliance
print("\nPassword audit:")
audit_results = compliance_reporter.audit_password_compliance(passwords, policy)
for result in audit_results:
    print(f"Password: {result['password']}, Compliant: {result['compliant']}")
    if not result['compliant']:
        print(f"Errors: {', '.join(result['errors'])}")

For more detailed examples, check the examples directory in the repository.

Documentation

For more detailed documentation, please refer to the docstrings in the source code. Full documentation will be available soon.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

password_policy_compliance-0.1.3.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file password_policy_compliance-0.1.3.tar.gz.

File metadata

File hashes

Hashes for password_policy_compliance-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7de7b107cb6bf4551db7d022cc0c7f7947a04b087a013ab69833b71b75aba215
MD5 8819738ef0eee55307153818e541368d
BLAKE2b-256 b48fef411f44f4419d1f223fb6549c1283d76e8a94950b8374bde6ac506d0a5c

See more details on using hashes here.

File details

Details for the file password_policy_compliance-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for password_policy_compliance-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c44af2b2c0a154cfdcce9baf858285dbbfc7a282cdc18fff177af66675b326f1
MD5 9c79aa7456adaa402e0576fd213c27c7
BLAKE2b-256 751775d530c3685806de4f2e70dac59b53e9625cc101e6927ef312bdd4ee8f31

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page