0
0
Kafkadevops~20 mins

SASL authentication in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SASL Authentication Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
SASL PLAIN Authentication Configuration Output
What will be the output of the following Kafka client configuration snippet when connecting with SASL PLAIN?
Kafka
props = {
  'security.protocol': 'SASL_PLAINTEXT',
  'sasl.mechanism': 'PLAIN',
  'sasl.jaas.config': 'org.apache.kafka.common.security.plain.PlainLoginModule required username="user1" password="pass1";'
}
print(props['security.protocol'], props['sasl.mechanism'])
APLAINTEXT SASL_PLAIN
BSASL_PLAINTEXT PLAIN
CSASL_SSL PLAIN
DSSL SASL_PLAINTEXT
Attempts:
2 left
💡 Hint
Check the values assigned to 'security.protocol' and 'sasl.mechanism' keys.
Predict Output
intermediate
2:00remaining
SASL SCRAM Authentication Error Message
What error message will be raised if the Kafka client tries to connect using SASL SCRAM with an incorrect password?
Kafka
try:
  # Simulated connection attempt
  raise Exception('SASL authentication failed: Invalid credentials')
except Exception as e:
  print(e)
ANo such mechanism supported
BConnection timeout error
CSASL authentication failed: Invalid credentials
DSSL handshake failed
Attempts:
2 left
💡 Hint
Focus on the exception message raised during authentication failure.
🔧 Debug
advanced
2:00remaining
Identify the SASL Authentication Bug
Given the following Kafka client configuration, which option correctly identifies the bug causing SASL authentication to fail?
Kafka
props = {
  'security.protocol': 'SASL_SSL',
  'sasl.mechanism': 'PLAIN',
  'sasl.jaas.config': 'org.apache.kafka.common.security.plain.PlainLoginModule required username="admin" password="admin123"'
}
# Connection fails with authentication error
AMissing semicolon at the end of 'sasl.jaas.config' string
BIncorrect 'security.protocol' value; should be 'PLAINTEXT'
CWrong SASL mechanism; should be 'SCRAM-SHA-256'
DUsername and password must be integers
Attempts:
2 left
💡 Hint
Check the syntax of the JAAS config string carefully.
📝 Syntax
advanced
2:00remaining
SASL JAAS Configuration Syntax Error
Which option contains a syntax error in the SASL JAAS configuration string?
Aorg.apache.kafka.common.security.plain.PlainLoginModule required username=user password=pass;
Borg.apache.kafka.common.security.plain.PlainLoginModule required username='user' password='pass';
Corg.apache.kafka.common.security.plain.PlainLoginModule required username="user" password="pass";
Dorg.apache.kafka.common.security.plain.PlainLoginModule required username="user" password="pass"
Attempts:
2 left
💡 Hint
Look at how username and password values are quoted.
🚀 Application
expert
2:00remaining
Determine the Number of SASL Mechanisms Supported
Given a Kafka broker configured with SASL mechanisms: PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, and GSSAPI, how many SASL mechanisms can a client choose from to authenticate?
A2
B3
C5
D4
Attempts:
2 left
💡 Hint
Count all listed mechanisms available for SASL authentication.