diff options
author | Eli Collins <elic@assurancetechnologies.com> | 2016-02-08 17:09:31 -0500 |
---|---|---|
committer | Eli Collins <elic@assurancetechnologies.com> | 2016-02-08 17:09:31 -0500 |
commit | 790a90b9c06716cc8e154e5fd691a1d6e0d3d6fe (patch) | |
tree | 1153565b10b44ba9595851065b678114c1d9610d /passlib/context.py | |
parent | 1b9a56c1a36c8c2a4b134d64546117d8851b2935 (diff) | |
download | passlib-790a90b9c06716cc8e154e5fd691a1d6e0d3d6fe.tar.gz |
PasswordHash ifc: added temporarily helper .parse_rounds(),
which abstracts out job of parsing rounds value from hash.
Diffstat (limited to 'passlib/context.py')
-rw-r--r-- | passlib/context.py | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/passlib/context.py b/passlib/context.py index 016ab40..c3de494 100644 --- a/passlib/context.py +++ b/passlib/context.py @@ -923,7 +923,7 @@ class _CryptRecord(object): # set flag if we can extract rounds from hash, allowing # needs_update() to check for rounds that are outside of # the configured range. - if self._has_rounds_bounds and hasattr(handler, "from_string"): + if self._has_rounds_bounds and hasattr(handler, "parse_rounds"): self._has_rounds_introspection = True def needs_update(self, hash, secret): @@ -945,15 +945,7 @@ class _CryptRecord(object): # if we can parse rounds parameter, check if it's w/in bounds. if self._has_rounds_introspection: - # XXX: this might be a good place to use parsehash() - hash_obj = self.handler.from_string(hash) - try: - rounds = hash_obj.rounds - except AttributeError: # pragma: no cover -- sanity check - # XXX: all builtin hashes should have rounds attr, - # so should a warning be issues here? - pass - else: + rounds = self.handler.parse_rounds(hash) mn = self._min_rounds if mn is not None and rounds < mn: return True |