Skip to content

Commit

Permalink
fix wampcra auth with salt
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahad-10 committed Jan 14, 2025
1 parent f722a22 commit 41cfc24
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crossbar/router/auth/wampcra.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ def _compute_challenge(self, user):
}
challenge: str = json.dumps(challenge_obj, ensure_ascii=False)
secret = user['secret'].encode('utf8')
signature = auth.compute_wcs(secret, challenge.encode('utf8')).decode('ascii')

# extra data to send to client in CHALLENGE
extra = {'challenge': challenge}

# when using salted passwords, provide the client with
# the salt and then PBKDF2 parameters used
if 'salt' in user:
if 'salt' in user and 'iterations' in user and 'keylen' in user:
extra['salt'] = user['salt']
extra['iterations'] = user.get('iterations', 1000)
extra['keylen'] = user.get('keylen', 32)
extra['iterations'] = user['iterations']
extra['keylen'] = user['keylen']
secret = auth.derive_key(secret, extra['salt'], extra['iterations'], extra['keylen'])

signature = auth.compute_wcs(secret, challenge.encode('utf8')).decode('ascii')

return extra, signature

Expand Down

0 comments on commit 41cfc24

Please sign in to comment.