Skip to content

Commit 9c61499

Browse files
committed
Update comments
1 parent 9395a78 commit 9c61499

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

kafka/sasl/gssapi.py

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

4141
def auth_bytes(self):
42+
# GSSAPI Auth does not have a final broker->client message
43+
# so mark is_done after the final auth_bytes are provided
44+
# in practice we'll still receive a response when using SaslAuthenticate
45+
# but not when using the prior unframed approach.
4246
if self._is_authenticated:
4347
self._is_done = True
4448
return self._next_token or b''
@@ -69,12 +73,12 @@ def receive(self, auth_bytes):
6973
]
7074
# add authorization identity to the response, and GSS-wrap
7175
self._next_token = self._client_ctx.wrap(b''.join(message_parts), False).message
72-
# GSSAPI Auth does not have a final broker->client message
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.
76-
# in practice we'll still receive a response when using SaslAuthenticate
77-
# but not when using the prior unframed approach.
76+
# We need to identify the last token in auth_bytes();
77+
# we can't rely on client_ctx.complete because it becomes True after generating
78+
# the second-to-last token (after calling .step(auth_bytes) for the final time)
79+
# We could introduce an additional state variable (i.e., self._final_token),
80+
# but instead we just set _is_authenticated. Since the plugin interface does
81+
# not read is_authenticated() until after is_done() is True, this should be fine.
7882
self._is_authenticated = True
7983

8084
def is_done(self):

0 commit comments

Comments
 (0)