Skip to content

Commit 0fe2e3c

Browse files
committed
improve flags handling
1 parent a89f4a3 commit 0fe2e3c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

kafka/sasl/gssapi.py

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

3-
import struct
4-
53
# needed for SASL_GSSAPI authentication:
64
try:
75
import gssapi
@@ -67,8 +65,10 @@ def receive(self, auth_bytes):
6765
# Kafka currently doesn't support integrity or confidentiality security layers, so we
6866
# simply set QoP to 'auth' only (first octet). We reuse the max message size proposed
6967
# by the server
68+
client_flags = self.SASL_QOP_AUTH
69+
server_flags = msg[0]
7070
message_parts = [
71-
struct.pack('>b', self.SASL_QOP_AUTH & struct.unpack('>b', msg[0:1])),
71+
bytes(client_flags & server_flags),
7272
msg[:1],
7373
self.auth_id.encode('utf-8'),
7474
]

kafka/sasl/sspi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ def receive(self, auth_bytes):
9191
# Kafka currently doesn't support integrity or confidentiality security layers, so we
9292
# simply set QoP to 'auth' only (first octet). We reuse the max message size proposed
9393
# by the server
94+
client_flags = self.SASL_QOP_AUTH
95+
server_flags = msg[0]
9496
message_parts = [
95-
Int8.encode(self.SASL_QOP_AUTH & Int8.decode(io.BytesIO(msg[0:1]))),
97+
bytes(client_flags & server_flags),
9698
msg[:1],
9799
self.auth_id.encode('utf-8'),
98100
]

0 commit comments

Comments
 (0)