Skip to content

Commit 9bee9fc

Browse files
authored
fix scram username character escape (#196)
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.
1 parent 31a6b92 commit 9bee9fc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kafka/scram.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self, user, password, mechanism):
3030
self.server_signature = None
3131

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

0 commit comments

Comments
 (0)