Skip to content

Commit

Permalink
Chat auth hardening (#602)
Browse files Browse the repository at this point in the history
  • Loading branch information
duogenesis authored Jan 10, 2025
1 parent 83abdbb commit ee4c656
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions service/chat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ class IntroRateLimit(Enum):
1
FROM
duo_session
JOIN
person
ON
person.id = duo_session.person_id
WHERE
session_token_hash = %(session_token_hash)s
duo_session.session_token_hash = %(session_token_hash)s
AND
person.uuid = %(auth_username)s
"""

Q_SELECT_INTRO_HASH = """
Expand Down Expand Up @@ -321,7 +327,11 @@ async def process_auth(parsed_xml, username):

auth_token_hash = sha512(auth_token)

params = dict(session_token_hash=auth_token_hash)
params = dict(
auth_username=auth_username,
session_token_hash=auth_token_hash,
)

async with api_tx('read committed') as tx:
await tx.execute(Q_CHECK_AUTH, params)
assert await tx.fetchone()
Expand Down

0 comments on commit ee4c656

Please sign in to comment.