-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Support Kerberos authentication between nodes #9683
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
Changes from all commits
0eb2282
4317f7c
286efd3
3b50e03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.facebook.presto.server; | ||
|
|
||
| import com.google.inject.Binder; | ||
| import com.google.inject.Module; | ||
| import io.airlift.configuration.AbstractConfigurationAwareModule; | ||
| import io.airlift.http.client.HttpClientConfig; | ||
| import io.airlift.http.client.spnego.KerberosConfig; | ||
|
|
||
| import java.io.UncheckedIOException; | ||
| import java.net.InetAddress; | ||
| import java.net.UnknownHostException; | ||
| import java.util.Locale; | ||
|
|
||
| import static com.facebook.presto.server.InternalCommunicationConfig.INTERNAL_COMMUNICATION_KERBEROS_ENABLED; | ||
| import static com.facebook.presto.server.security.KerberosConfig.HTTP_SERVER_AUTHENTICATION_KRB5_KEYTAB; | ||
| import static com.google.common.base.Verify.verify; | ||
| import static io.airlift.configuration.ConditionalModule.installModuleIf; | ||
| import static io.airlift.configuration.ConfigBinder.configBinder; | ||
|
|
||
| public class InternalCommunicationModule | ||
| extends AbstractConfigurationAwareModule | ||
| { | ||
| @Override | ||
| protected void setup(Binder binder) | ||
| { | ||
| InternalCommunicationConfig internalCommunicationConfig = buildConfigObject(InternalCommunicationConfig.class); | ||
| configBinder(binder).bindConfigGlobalDefaults(HttpClientConfig.class, config -> { | ||
| config.setKeyStorePath(internalCommunicationConfig.getKeyStorePath()); | ||
| config.setKeyStorePassword(internalCommunicationConfig.getKeyStorePassword()); | ||
| }); | ||
|
|
||
| install(installModuleIf(InternalCommunicationConfig.class, InternalCommunicationConfig::isKerberosEnabled, kerberosInternalCommunicationModule())); | ||
| } | ||
|
|
||
| private Module kerberosInternalCommunicationModule() | ||
| { | ||
| return binder -> { | ||
| InternalCommunicationConfig clientKerberosConfig = buildConfigObject(InternalCommunicationConfig.class); | ||
| com.facebook.presto.server.security.KerberosConfig serverKerberosConfig = buildConfigObject(com.facebook.presto.server.security.KerberosConfig.class); | ||
| verify(serverKerberosConfig.getKeytab() != null, "%s must be set when %s is true", HTTP_SERVER_AUTHENTICATION_KRB5_KEYTAB, INTERNAL_COMMUNICATION_KERBEROS_ENABLED); | ||
|
|
||
| configBinder(binder).bindConfigGlobalDefaults(KerberosConfig.class, kerberosConfig -> { | ||
| kerberosConfig.setConfig(serverKerberosConfig.getKerberosConfig()); | ||
| kerberosConfig.setKeytab(serverKerberosConfig.getKeytab()); | ||
| kerberosConfig.setUseCanonicalHostname(clientKerberosConfig.isKerberosUseCanonicalHostname()); | ||
| }); | ||
|
|
||
| String kerberosPrincipal = serverKerberosConfig.getServiceName() + "/" + getLocalCanonicalHostName(); | ||
| configBinder(binder).bindConfigGlobalDefaults(HttpClientConfig.class, httpClientConfig -> { | ||
| httpClientConfig.setAuthenticationEnabled(true); | ||
| httpClientConfig.setKerberosPrincipal(kerberosPrincipal); | ||
| httpClientConfig.setKerberosRemoteServiceName(serverKerberosConfig.getServiceName()); | ||
| }); | ||
| }; | ||
| } | ||
|
|
||
| private static String getLocalCanonicalHostName() | ||
| { | ||
| try { | ||
| return InetAddress.getLocalHost().getCanonicalHostName().toLowerCase(Locale.US); | ||
| } | ||
| catch (UnknownHostException e) { | ||
| throw new UncheckedIOException(e); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| SCRIPT_DIRECTORY=${BASH_SOURCE%/*} | ||
|
|
||
| source ${SCRIPT_DIRECTORY}/../common/compose-commons.sh | ||
|
|
||
| docker-compose \ | ||
| -f ${SCRIPT_DIRECTORY}/../common/standard.yml \ | ||
| -f ${SCRIPT_DIRECTORY}/../common/kerberos.yml \ | ||
| -f ${SCRIPT_DIRECTORY}/docker-compose.yml \ | ||
| "$@" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| version: '2' | ||
| services: | ||
|
|
||
| presto-master: | ||
| domainname: docker.cluster | ||
| hostname: presto-master | ||
| image: '${HADOOP_BASE_IMAGE}-kerberized:${DOCKER_IMAGES_VERSION}' | ||
| command: /docker/volumes/conf/docker/files/presto-launcher-wrapper.sh multinode-tls-kerberos-master run | ||
| ports: | ||
| - '7778:7778' | ||
| networks: | ||
| default: | ||
| aliases: | ||
| - presto-master.docker.cluster | ||
| volumes: | ||
| - ../../../conf/presto/etc/environment-specific-catalogs/singlenode-kerberos-hdfs-no-impersonation/hive.properties:/docker/volumes/conf/presto/etc/catalog/hive.properties | ||
|
||
|
|
||
| presto-worker-1: | ||
| domainname: docker.cluster | ||
| hostname: presto-worker-1 | ||
| image: '${HADOOP_BASE_IMAGE}-kerberized:${DOCKER_IMAGES_VERSION}' | ||
| extends: | ||
| file: ../common/standard.yml | ||
| service: java-8-base | ||
| command: /docker/volumes/conf/docker/files/presto-launcher-wrapper.sh multinode-tls-kerberos-worker run | ||
| networks: | ||
| default: | ||
| aliases: | ||
| - presto-worker-1.docker.cluster | ||
| depends_on: | ||
| - presto-master | ||
| volumes_from: | ||
| - presto-master | ||
|
|
||
| presto-worker-2: | ||
| domainname: docker.cluster | ||
| hostname: presto-worker-2 | ||
| image: '${HADOOP_BASE_IMAGE}-kerberized:${DOCKER_IMAGES_VERSION}' | ||
| extends: | ||
| file: ../common/standard.yml | ||
| service: java-8-base | ||
| command: /docker/volumes/conf/docker/files/presto-launcher-wrapper.sh multinode-tls-kerberos-worker run | ||
| networks: | ||
| default: | ||
| aliases: | ||
| - presto-worker-2.docker.cluster | ||
| depends_on: | ||
| - presto-master | ||
| volumes_from: | ||
| - presto-master | ||
|
|
||
| application-runner: | ||
| environment: | ||
| - TEMPTO_PROFILE_CONFIG_FILE=/docker/volumes/conf/tempto/tempto-configuration-for-docker-kerberos.yaml | ||
| - CLI_ARGUMENTS=--server https://presto-master.docker.cluster:7778 --keystore-path /docker/volumes/conf/presto/etc/docker.cluster.jks --keystore-password 123456 --krb5-config-path /etc/krb5.conf --krb5-principal presto-client/presto-master.docker.cluster@LABS.TERADATA.COM --krb5-keytab-path /etc/presto/conf/presto-client.keytab --krb5-remote-service-name presto-server --krb5-disable-remote-service-hostname-canonicalization | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| # | ||
| # WARNING | ||
| # ^^^^^^^ | ||
| # This configuration file is for development only and should NOT be used be | ||
| # used in production. For example configuration, see the Presto documentation. | ||
| # | ||
|
|
||
| node.id=will-be-overwritten | ||
| node.environment=test | ||
| node.internal-address-source=FQDN | ||
|
|
||
| coordinator=true | ||
| node-scheduler.include-coordinator=true | ||
| discovery-server.enabled=true | ||
| discovery.uri=https://presto-master.docker.cluster:7778 | ||
|
|
||
| query.max-memory=1GB | ||
| query.max-memory-per-node=512MB | ||
|
|
||
| http-server.http.enabled=false | ||
| http-server.https.enabled=true | ||
| http-server.https.port=7778 | ||
| http-server.https.keystore.path=/docker/volumes/conf/presto/etc/docker.cluster.jks | ||
| http-server.https.keystore.key=123456 | ||
|
|
||
| http.authentication.krb5.config=/etc/krb5.conf | ||
| http-server.authentication.type=KERBEROS | ||
| http.server.authentication.krb5.service-name=presto-server | ||
| http.server.authentication.krb5.keytab=/etc/presto/conf/presto-server.keytab | ||
|
|
||
| internal-communication.https.required=true | ||
| internal-communication.https.keystore.path=/docker/volumes/conf/presto/etc/docker.cluster.jks | ||
| internal-communication.https.keystore.key=123456 | ||
|
|
||
| internal-communication.kerberos.enabled=true | ||
| internal-communication.kerberos.use-canonical-hostname=false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
||
| # | ||
|
|
||
| # | ||
| # WARNING | ||
| # ^^^^^^^ | ||
| # This configuration file is for development only and should NOT be used be | ||
| # used in production. For example configuration, see the Presto documentation. | ||
| # | ||
|
|
||
| node.id=will-be-overwritten | ||
| node.environment=test | ||
| node.internal-address-source=FQDN | ||
|
|
||
| coordinator=false | ||
| discovery-server.enabled=false | ||
| discovery.uri=https://presto-master.docker.cluster:7778 | ||
|
|
||
| query.max-memory=1GB | ||
| query.max-memory-per-node=512MB | ||
|
|
||
| http-server.http.enabled=false | ||
| http-server.https.enabled=true | ||
| http-server.https.port=7778 | ||
| http-server.https.keystore.path=/docker/volumes/conf/presto/etc/docker.cluster.jks | ||
| http-server.https.keystore.key=123456 | ||
|
|
||
| http.authentication.krb5.config=/etc/krb5.conf | ||
| http-server.authentication.type=KERBEROS | ||
| http.server.authentication.krb5.service-name=presto-server | ||
| http.server.authentication.krb5.keytab=/etc/presto/conf/presto-server.keytab | ||
|
|
||
| internal-communication.https.required=true | ||
| internal-communication.https.keystore.path=/docker/volumes/conf/presto/etc/docker.cluster.jks | ||
| internal-communication.https.keystore.key=123456 | ||
|
|
||
| internal-communication.kerberos.enabled=true | ||
| internal-communication.kerberos.use-canonical-hostname=false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,8 @@ databases: | |
| presto: | ||
| host: presto-master.docker.cluster | ||
| port: 7778 | ||
| http_port: 8080 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it needed? http is disabled
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ya. but we run TLS test group (TlsTests) now in this profile. This property is used there to test if http_port is not actually being used. |
||
| https_port: ${databases.presto.port} | ||
| server_address: https://${databases.presto.host}:${databases.presto.port} | ||
|
|
||
| # jdbc_user in here should satisfy two requirements in order to pass SQL standard access control checks in Presto: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this document
_HOST?