Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SASL Authentication #105

Closed
nadeevkm opened this issue Nov 27, 2018 · 19 comments
Closed

SASL Authentication #105

nadeevkm opened this issue Nov 27, 2018 · 19 comments

Comments

@nadeevkm
Copy link

nadeevkm commented Nov 27, 2018

Greeting! Is it possible to use kafka-webview with a cluster with a SASL authenticaton? In simple console consumer I can do this by just passing jaas conf(with login/password) file as JVM argument like

export KAFKA_OPTS="-Djava.security.auth.login.config=/home/nkm/Apps/kafka_2.11-2.0.0/config/jaas_client.conf"

and consumer.property file with lines

security.protocol=SASL_PLAINTEXT
sasl.mechanism=PLAIN

as cmd arguments, like..

bin/kafka-console-consumer.sh --bootstrap-server localhost:9029092 --topic test_topic --from-beginning --consumer.config config/consumer.properties

@Crim
Copy link
Collaborator

Crim commented Dec 2, 2018

Do you know of a good online resource/tutorial for setting up SASL authentication on brokers? If I can configure it locally I can likely work out how to include it in the app.

@thammuio
Copy link

thammuio commented Dec 6, 2018

@Crim - I can help with this. What distro of Kafka you need? (Apache/Horotonworks/Cloudera/Confluent)...

This is a good doc which covers all vendor distros... Probably you need to setup a KDC, if you don't have one already.

@Crim
Copy link
Collaborator

Crim commented Dec 6, 2018

just standard Apache's Kafka, or whatever is easiest to get up and going really.

Thanks!

@nadeevkm
Copy link
Author

nadeevkm commented Dec 7, 2018

Glad to hear, it would be great!

As far as SASL is concerned - it's quite a simple thing when you get it, so I can describe it here.

To setup SASL authentification in a kafka cluster you shoul fulfill several steps:

  1. Add relevant properties in properies files
  2. Make jaas-file with authentication information
  3. Pass JVM a special environment parametr
  4. Run zookeeper/kafka/producers/consumers explicitly passing modifyed config files

Now in details:

  1. Zookeper

add this at config/zookeeper.properies

authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
requireClientAuthScheme=sasl
jaasLoginRenew=3600000

make jaas file, for example config/jaas_zookeeper.conf with lines

Server {
   org.apache.zookeeper.server.auth.DigestLoginModule required
   username="admin"
   password="admin-secret"
   user_zooclient="client-secret";
};

pass JVM a special param, in linux you can do it this way:

export SERVER_JVMFLAGS="-Djava.security.auth.login.config=/home/nkm/apps/kafka_2.11-2.0.0/config/jaas_zookeeper.conf"

and run zookeeper

bin/zookeeper-server-start.sh config/zookeeper.properties
  1. Kafka broker

modify or add this properies at config/server.properies

advertised.host.name=localhost
advertised.listeners=SASL_PLAINTEXT://localhost:9092

allow.everyone.if.no.acl.found=true
authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer

listeners=SASL_PLAINTEXT://localhost:9092
sasl.enabled.mechanisms=PLAIN
sasl.mechanism.inter.broker.protocol=PLAIN
security.inter.broker.protocol=SASL_PLAINTEXT
super.users=User:admin

make jaas file, for example config/jaas_kafka_server.conf with lines

KafkaServer {
   org.apache.kafka.common.security.plain.PlainLoginModule required
   username="admin"
   password="admin-secret"
   user_admin="admin-secret"
   user_kafkaclient="client-secret";
};

Client {
       org.apache.zookeeper.server.auth.DigestLoginModule required
       username="zooclient"
       password="client-secret";
};

pass JVM a special param, in linux you can do it this way:

export KAFKA_OPTS="-Djava.security.auth.login.config=/home/nkm/apps/kafka_2.11-2.0.0/config/jaas_kafka_server.conf"

and run kafka broker

bin/kafka-server-start.sh config/server.properties
  1. Kafka producer/consumer

make config/client.properties and add this

security.protocol=SASL_PLAINTEXT
sasl.mechanism=PLAIN

make jaas file, for example config/jaas_kafka_client.conf with lines

KafkaClient {
  org.apache.kafka.common.security.plain.PlainLoginModule required
  username="kafkaclient"
  password="client-secret";
};

pass JVM a special param, in linux you can do it this way:

export KAFKA_OPTS="-Djava.security.auth.login.config=/home/nkm/apps/kafka_2.11-2.0.0/config/jaas_kafka_client.conf"

and run producer

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test_topic --producer.config config/client.properties

run consumer

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test_topic --from-beginning --consumer.config config/client.properties 

So after all kafka broker connects to Zookeper using Client data in jaas file (it must correspond to zookeeper Server jaas data) and consumers and producers connect to broker using KafkaClient jaas data (it must correspond to KafkaServer authentication data)

And don't forget to replace "/home/nkm/apps/kafka_2.11-2.0.0" with your own kafka directory)

@Crim
Copy link
Collaborator

Crim commented Dec 7, 2018

That worked a treat @nadeevkm Thanks a ton! I'll poke around this weekend and get this working in the webapp.

@Crim
Copy link
Collaborator

Crim commented Dec 9, 2018

How does this UI look for setting up a cluster using SASL? Any suggestions or improvements?

Plain SASL authentication

image

GSSAPI / Custom Mechanism

Selecting GSSAPI or a Custom mechanism would basically just prompt you to enter your own JAAS configuration manually.
image

@thammuio
Copy link

thammuio commented Dec 9, 2018

Looks Great. We Use GSSAPI(Kerberos) with SSL as SASL_SSL. So It should also take path to trust store and its password in SSL Settings(when no ssl auth). Also, it should ask for Kafka security protocol options as - PLAINTEXT/SASL_PLAINTEXT/SASL_SSL/SSL.

@thammuio
Copy link

thammuio commented Dec 9, 2018

SASL JAAS Config (only applies to SASL based security) - used for yahoo kafka manager

com.sun.security.auth.module.Krb5LoginModule required doNotPrompt=true useTicketCache=false principal="user@HADOOP.COM" useKeyTab=true serviceName="kafka" keyTab="/home/user/user.keytab" client=true;

here is the jaas.conf file that clients uses

KafkaClient {
com.sun.security.auth.module.Krb5LoginModule required
doNotPrompt=true
useTicketCache=false
principal="user@HADOOP.COM"
useKeyTab=true
serviceName="kafka"
keyTab="/home/user/user.keytab"
client=true;
};

Client {
com.sun.security.auth.module.Krb5LoginModule required
doNotPrompt=true
useTicketCache=false
principal="user@HADOOP.COM"
useKeyTab=true
serviceName="kafka"
keyTab="/home/user/user.keytab"
client=true;
};

@Crim
Copy link
Collaborator

Crim commented Dec 10, 2018

Just to make sure I'm understanding correctly....since the app already supports PLAINTEXT and SSL, when I add SASL support,

  • PLAIN when you don't have SSL or SASL options enabled
  • SSL when you have just the currently supported SSL options enabled.
  • SASL_PLAIN when you do NOT have the currently supported SSL settings enabled, and have the new SASL settings enabled.
  • SASL_SSL a combination of the existing SSL settings enabled, as well as the new SASL settings

This sounds correct?

@thammuio
Copy link

@Crim yes you are right.

One thing to point out is when we have SASL_SSL; we just use truststore(no ssl Auth - so keystore is not needed).

@Crim
Copy link
Collaborator

Crim commented Dec 10, 2018

Good to know!

@Crim
Copy link
Collaborator

Crim commented Dec 20, 2018

I've published a new release that should support this. Thanks!

@Crim Crim closed this as completed Dec 20, 2018
@nadeevkm
Copy link
Author

Thank you very much for your work! I'll check It in a few days!

@thammuio
Copy link

Thanks @Crim. when we have SASL auth, we dont need SSL auth; can you check on this; for SASL_SSL we just need SASL conf and SSL truststore.

image

@thammuio
Copy link

I am able to setup with SASL. I can use it. But, i am getting below error in Cluster Broker View:

Error: org.apache.kafka.common.errors.UnsupportedVersionException: The broker does not support DESCRIBE_CONFIGS

@Crim
Copy link
Collaborator

Crim commented Dec 21, 2018

@thammuio I've created issue #115 for your error.

@Crim Crim reopened this Dec 21, 2018
@Crim
Copy link
Collaborator

Crim commented Dec 21, 2018

Sounds like when SASL is enabled, there's no need for the keystore and associated password?

@thammuio
Copy link

Thanks @Crim . Yes, when SASL is enabled no need of keystore details.

@Crim
Copy link
Collaborator

Crim commented Dec 25, 2018

created issue #116 to deal with no longer requiring a KEYSTORE in this scenario and closing out this ticket.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants