@@ -22,12 +22,19 @@ class SaslMechanismGSSAPI(SaslMechanism):
22
22
23
23
def __init__ (self , ** config ):
24
24
assert gssapi is not None , 'GSSAPI lib not available'
25
- assert config ['sasl_kerberos_service_name' ] is not None , 'sasl_kerberos_service_name required for GSSAPI sasl'
25
+ if 'sasl_kerberos_name' not in config and 'sasl_kerberos_service_name' not in config :
26
+ raise ValueError ('sasl_kerberos_service_name or sasl_kerberos_name required for GSSAPI sasl configuration' )
26
27
self ._is_done = False
27
28
self ._is_authenticated = False
28
- self .kerberos_damin_name = config ['sasl_kerberos_domain_name' ] or config ['host' ]
29
- self .auth_id = config ['sasl_kerberos_service_name' ] + '@' + kerberos_damin_name
30
- self .gssapi_name = gssapi .Name (auth_id , name_type = gssapi .NameType .hostbased_service ).canonicalize (gssapi .MechType .kerberos )
29
+ if config .get ('sasl_kerberos_name' , None ) is not None :
30
+ self .auth_id = str (config ['sasl_kerberos_name' ])
31
+ else :
32
+ kerberos_domain_name = config .get ('sasl_kerberos_domain_name' , '' ) or config .get ('host' , '' )
33
+ self .auth_id = config ['sasl_kerberos_service_name' ] + '@' + kerberos_domain_name
34
+ if isinstance (config .get ('sasl_kerberos_name' , None ), gssapi .Name ):
35
+ self .gssapi_name = config ['sasl_kerberos_name' ]
36
+ else :
37
+ self .gssapi_name = gssapi .Name (self .auth_id , name_type = gssapi .NameType .hostbased_service ).canonicalize (gssapi .MechType .kerberos )
31
38
self ._client_ctx = gssapi .SecurityContext (name = self .gssapi_name , usage = 'initiate' )
32
39
self ._next_token = self ._client_ctx .step (None )
33
40
@@ -54,7 +61,7 @@ def receive(self, auth_bytes):
54
61
raise ValueError ("Unexpected receive auth_bytes after sasl/gssapi completion" )
55
62
else :
56
63
# unwraps message containing supported protection levels and msg size
57
- msg = client_ctx . unwrap (received_token ).message
64
+ msg = self . _client_ctx . unwrap (auth_bytes ).message
58
65
# Kafka currently doesn't support integrity or confidentiality security layers, so we
59
66
# simply set QoP to 'auth' only (first octet). We reuse the max message size proposed
60
67
# by the server
0 commit comments