Skip to content

Commit ef4e070

Browse files
committed
lowercase all hashes
1 parent 634a868 commit ef4e070

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def wrapper(self, *args, **kwargs):
5959
if not user:
6060
raise BBJUserError("User %s is not registered" % username)
6161

62-
elif auth != user["auth_hash"]:
62+
elif auth.lower() != user["auth_hash"].lower():
6363
raise BBJException(5, "Invalid authorization key for user.")
6464

6565
# api_methods may choose to bind a usermap into the thread_data
@@ -233,7 +233,7 @@ def check_auth(self, args, database, user, **kwargs):
233233
"""
234234
validate(args, ["target_user", "target_hash"])
235235
user = db.user_resolve(database, args["target_user"], return_false=False)
236-
return args["target_hash"] == user["auth_hash"]
236+
return args["target_hash"].lower() == user["auth_hash"].lower()
237237

238238

239239
@api_method

src/db.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def user_register(connection, user_name, auth_hash):
338338
raise BBJUserError("Username already registered")
339339

340340
scheme = schema.user_internal(
341-
uuid1().hex, user_name, auth_hash,
341+
uuid1().hex, user_name, auth_hash.lower(),
342342
"", "", 0, False, time())
343343

344344
connection.execute("""
@@ -391,6 +391,8 @@ def user_update(connection, user_object, parameters):
391391
# bool(0) == False hur hur hurrrrrr ::drools::
392392
if value == 0 or value:
393393
validate([(key, value)])
394+
if key == "auth_hash":
395+
value = value.lower()
394396
user_object[key] = value
395397

396398
values = ordered_keys(user_object,

src/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def user_internal(
8383
return {
8484
"user_id": user_id,
8585
"user_name": user_name,
86-
"auth_hash": auth_hash,
86+
"auth_hash": auth_hash.lower(),
8787
"quip": quip,
8888
"bio": bio,
8989
"color": color,

0 commit comments

Comments
 (0)