Skip to content

Commit d98ee2d

Browse files
committed
set is_authenticated on final receive; is_done on final send
1 parent 86c9080 commit d98ee2d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

kafka/sasl/gssapi.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def __init__(self, **config):
3939
self._next_token = self._client_ctx.step(None)
4040

4141
def auth_bytes(self):
42-
if self._is_done:
43-
self._is_authenticated = True
42+
if self._is_authenticated:
43+
self._is_done = True
4444
return self._next_token or b''
4545

4646
def receive(self, auth_bytes):
@@ -70,10 +70,12 @@ def receive(self, auth_bytes):
7070
# add authorization identity to the response, and GSS-wrap
7171
self._next_token = self._client_ctx.wrap(b''.join(message_parts), False).message
7272
# GSSAPI Auth does not have a final broker->client message
73-
# so mark is_done after the final token is generated
73+
# so we need to be able to identify when the final token is generated
74+
# here we set _is_authenticated after receiving the final response,
75+
# but wait until the final send (auth_bytes() call) to set _is_done.
7476
# in practice we'll still receive a response when using SaslAuthenticate
7577
# but not when using the prior unframed approach.
76-
self._is_done = True
78+
self._is_authenticated = True
7779

7880
def is_done(self):
7981
return self._is_done

0 commit comments

Comments
 (0)