Skip to content

Fix construction of final GSSAPI authentication message #2647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions kafka/sasl/gssapi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import absolute_import

import struct

# needed for SASL_GSSAPI authentication:
try:
import gssapi
Expand Down Expand Up @@ -68,8 +70,8 @@ def receive(self, auth_bytes):
client_flags = self.SASL_QOP_AUTH
server_flags = msg[0]
message_parts = [
bytes(client_flags & server_flags),
msg[:1],
struct.Struct('>b').pack(client_flags & server_flags),
msg[1:],
self.auth_id.encode('utf-8'),
]
# add authorization identity to the response, and GSS-wrap
Expand Down
2 changes: 1 addition & 1 deletion test/sasl/test_gssapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def mocked_message_wrapper(msg, *args):
while not gssapi.is_done():
send_token = gssapi.auth_bytes()
receive_token = send_token # not realistic, but enough for testing
if send_token == b'\x00cbar@foo': # final wrapped message
if send_token == b'\x01ompletebar@foo': # final wrapped message
receive_token = b'' # final message gets an empty response
gssapi.receive(receive_token)
if client_ctx.step.call_count == 3:
Expand Down
Loading