Skip to content

Commit

Permalink
fix scram username character escape
Browse files Browse the repository at this point in the history
According to [rfc5802](https://datatracker.ietf.org/doc/html/rfc5802), username should escape special characters before sending to the server.
> The characters ',' or '=' in usernames are sent as '=2C' and
         '=3D' respectively.  If the server receives a username that
         contains '=' not followed by either '2C' or '3D', then the
         server MUST fail the authentication.
  • Loading branch information
debuggings committed Aug 14, 2024
1 parent 31a6b92 commit b532eb3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kafka/scram.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, user, password, mechanism):
self.server_signature = None

def first_message(self):
client_first_bare = f'n={self.user},r={self.nonce}'
client_first_bare = f'n={self.user.replace("=","=3D").replace(",","=2C")},r={self.nonce}'
self.auth_message += client_first_bare
return 'n,,' + client_first_bare

Expand Down

0 comments on commit b532eb3

Please sign in to comment.