diff options
Diffstat (limited to 'distixapi/authn.py')
-rw-r--r-- | distixapi/authn.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/distixapi/authn.py b/distixapi/authn.py index 9875929..8b7d00a 100644 --- a/distixapi/authn.py +++ b/distixapi/authn.py @@ -35,8 +35,17 @@ class AuthenticationError(Exception): def encrypt_password(salt, password): - return scrypt.hash(password, salt) + return scrypt.hash(password, salt).encode('hex') def get_scopes(users, request): - raise AuthenticationError('foo') + username, password = get_credentials(request) + if username not in users['users']: + raise AuthenticationError('Error authenticating') + user = users['users'][username] + + encrypted = encrypt_password(user['salt'], password) + if encrypted != user['password']: + raise AuthenticationError('Error authenticating') + + return user['scopes'] |