passlib.exc - exceptions and warnings raised by Passlib

This module contains all the custom exceptions & warnings that may be raised by Passlib.

Exceptions

exception passlib.exc.MissingBackendError

Error raised if multi-backend handler has no available backends; or if specifically requested backend is not available.

MissingBackendError derives from RuntimeError, since it usually indicates lack of an external library or OS feature. This is primarily raised by handlers which depend on external libraries (which is currently just bcrypt).

exception passlib.exc.PasswordSizeError

Error raised if a password exceeds the maximum size allowed by Passlib (4096 characters).

Many password hash algorithms take proportionately larger amounts of time and/or memory depending on the size of the password provided. This could present a potential denial of service (DOS) situation if a maliciously large password is provided to an application. Because of this, Passlib enforces a maximum size limit, but one which should be much larger than any legitimate password. PasswordSizeError derives from ValueError.

Note

Applications wishing to use a different limit should set the PASSLIB_MAX_PASSWORD_SIZE environmental variable before Passlib is loaded. The value can be any large positive integer.

New in version 1.6.

exception passlib.exc.PasslibSecurityError

Error raised if critical security issue is detected (e.g. an attempt is made to use a vulnerable version of a bcrypt backend).

New in version 1.6.3.

Warnings

exception passlib.exc.PasslibWarning

base class for Passlib’s user warnings, derives from the builtin UserWarning.

New in version 1.6.

Minor Warnings

exception passlib.exc.PasslibConfigWarning

Warning issued when non-fatal issue is found related to the configuration of a CryptContext instance.

This occurs primarily in one of two cases:

  • The CryptContext contains rounds limits which exceed the hard limits imposed by the underlying algorithm.
  • An explicit rounds value was provided which exceeds the limits imposed by the CryptContext.

In both of these cases, the code will perform correctly & securely; but the warning is issued as a sign the configuration may need updating.

New in version 1.6.

exception passlib.exc.PasslibHashWarning

Warning issued when non-fatal issue is found with parameters or hash string passed to a passlib hash class.

This occurs primarily in one of two cases:

  • A rounds value or other setting was explicitly provided which exceeded the handler’s limits (and has been clamped by the relaxed flag).
  • A malformed hash string was encountered which (while parsable) should be re-encoded.

New in version 1.6.

Critical Warnings

exception passlib.exc.PasslibRuntimeWarning

Warning issued when something unexpected happens during runtime.

The fact that it’s a warning instead of an error means Passlib was able to correct for the issue, but that it’s anomalous enough that the developers would love to hear under what conditions it occurred.

New in version 1.6.

exception passlib.exc.PasslibSecurityWarning

Special warning issued when Passlib encounters something that might affect security.

New in version 1.6.