Skip to content

Commit d30d320

Browse files
committed
set is_authenticated on final receive; is_done on final send
1 parent e0104cb commit d30d320

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
@@ -40,8 +40,8 @@ def __init__(self, **config):
4040
self._next_token = self._client_ctx.step(None)
4141

4242
def auth_bytes(self):
43-
if self._is_done:
44-
self._is_authenticated = True
43+
if self._is_authenticated:
44+
self._is_done = True
4545
return self._next_token or b''
4646

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

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

0 commit comments

Comments
 (0)