Skip to content

Commit 0245352

Browse files
authored
Fix construction of final GSSAPI authentication message (#2647)
1 parent 5d83941 commit 0245352

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

kafka/sasl/gssapi.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import absolute_import
22

3+
import struct
4+
35
# needed for SASL_GSSAPI authentication:
46
try:
57
import gssapi
@@ -68,8 +70,8 @@ def receive(self, auth_bytes):
6870
client_flags = self.SASL_QOP_AUTH
6971
server_flags = msg[0]
7072
message_parts = [
71-
bytes(client_flags & server_flags),
72-
msg[:1],
73+
struct.Struct('>b').pack(client_flags & server_flags),
74+
msg[1:],
7375
self.auth_id.encode('utf-8'),
7476
]
7577
# add authorization identity to the response, and GSS-wrap

test/sasl/test_gssapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def mocked_message_wrapper(msg, *args):
3232
while not gssapi.is_done():
3333
send_token = gssapi.auth_bytes()
3434
receive_token = send_token # not realistic, but enough for testing
35-
if send_token == b'\x00cbar@foo': # final wrapped message
35+
if send_token == b'\x01ompletebar@foo': # final wrapped message
3636
receive_token = b'' # final message gets an empty response
3737
gssapi.receive(receive_token)
3838
if client_ctx.step.call_count == 3:

0 commit comments

Comments
 (0)