diff options
| author | Eli Collins <elic@assurancetechnologies.com> | 2016-07-12 14:27:07 -0400 |
|---|---|---|
| committer | Eli Collins <elic@assurancetechnologies.com> | 2016-07-12 14:27:07 -0400 |
| commit | 36e14926d6b102e8d905fb031bbb214600c1fef3 (patch) | |
| tree | 36a3766f528b627139fb347b0fc9b202dd3bad21 /docs/lib | |
| parent | 5722f82fa8e28a7a3e164db880fb23181321af94 (diff) | |
| download | passlib-36e14926d6b102e8d905fb031bbb214600c1fef3.tar.gz | |
passlib.totp: large refactoring of API, added support for migration application secrets
This reworks a large portion of the totp module's API, to make it fit better
with the needs of the applications it's been integrated into so far.
* Key encryption encapsulated in new OTPContext() class,
which not only handles encryption of keys, but supports
multiple application secrets, allowing migration to new secrets
(whether periodic, or after a breach).
This makes workflow of OTP object serialization *much* simpler.
* encryption format changed to use a simple dict, which gets embedded
into overall json data; eliminates need for custom binary format.
* BaseOTP.generate_next() has been renamed to .advance(),
to make it distinct from .generate(), and give better hinting
that it modifies the internal state
BaseOTP.verify_next() has been renamed to .consume() for similar reasons.
* All .verify() and .verify_next() methods have been modified
so they throw an InvalidTokenError if the token doesn't match,
instead of returning False.
This reduces the boilerplate needed to implement them,
as code already had to catch ValueErrors for malformed tokens & reused tokens.
- the HotpMatch / TotpMatch objects were adjusted to account
for fact that they're only used when token matches successfully.
* better exception hierarchy: added base TokenError,
as well as subclasses for specific cases (MalformedTokenError,
InvalidTokenError, UsedTokenError).
* renamed BaseOTP.dirty -> BaseOTP.changed
* BaseOTP now detects if encryption is old, and flags that re-encryption
+ re-serialization is needed.
* .from_string() / .to_string() renamed to .from_json() / .to_json()
to disambiguate with .from_uri() / .to_uri(), which also returns a string.
Diffstat (limited to 'docs/lib')
| -rw-r--r-- | docs/lib/passlib.totp.rst | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/docs/lib/passlib.totp.rst b/docs/lib/passlib.totp.rst index 2b4aae8..e535a39 100644 --- a/docs/lib/passlib.totp.rst +++ b/docs/lib/passlib.totp.rst @@ -29,6 +29,12 @@ API Reference ============= +OTPContext +---------- +.. autoclass:: OTPContext + +.. autofunction:: generate_secret + Common Interface ---------------- .. autoclass:: BaseOTP() |
