Skip to content

Commit

Permalink
Quote username in SCRAM auth
Browse files Browse the repository at this point in the history
  • Loading branch information
ods committed Aug 15, 2024
1 parent e2afc03 commit 9812e86
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion aiokafka/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,13 @@ def __init__(
self._authenticator = self.authenticator_scram()

def first_message(self):
client_first_bare = f"n={self._sasl_plain_username},r={self._nonce}"
# The characters ',' or '=' in usernames are sent as '=2C' and
# '=3D' respectively.
# https://datatracker.ietf.org/doc/html/rfc5802#section-5.1
quoted_username = (
self._sasl_plain_username.replace("=", "=3D").replace( ",", "=2C")
) # fmt: skip
client_first_bare = f"n={quoted_username},r={self._nonce}"
self._auth_message += client_first_bare
return "n,," + client_first_bare

Expand Down

0 comments on commit 9812e86

Please sign in to comment.