Skip to content

Commit

Permalink
Merge pull request #311 from SpiderOak/BAC-3951-check-lengths
Browse files Browse the repository at this point in the history
Expected bcrypt hash
  • Loading branch information
bdzim authored Sep 10, 2018
2 parents 7aabef5 + aaa47d5 commit 8710c6a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions django/apps/openmanage/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
CHALLENGE_EXPIRATION_TIME = 60
KEYLEN = nacl.secret.SecretBox.KEY_SIZE
ITERATIONS = 100 # from py-bcrypt readme, maybe need to tweak this
BCRYPT_HASH_LENGTH = 60


def setup_logging():
handler = logging.StreamHandler()
Expand Down Expand Up @@ -253,10 +255,8 @@ def password(request):
except KeyError:
log.error("Got bad request. Missing arguments.")
return HttpResponse()
if len(new_password) < minimum_password_length:
message = 'Password too short. It should be at least {} characters long'.format(
minimum_password_length
)
if len(new_password) != BCRYPT_HASH_LENGTH:
message = 'Expected bcrypt hash'
log.warning(message)
return HttpResponseBadRequest(
content=message,
Expand Down

0 comments on commit 8710c6a

Please sign in to comment.