forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Kerberos-aware Elasticsearch and integration test to ES output (e…
…lastic#18127) This PR adds an integration test to the Elasticsearch output to check Kerberos authentication. Furthermore, it adds a new element to our testing environment, a Kerberos-aware Elasticsearch instance named `elasticsearch_kerberos.elastic`.
- Loading branch information
Showing
17 changed files
with
528 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Licensed to Elasticsearch under one or more contributor | ||
# license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright | ||
# ownership. Elasticsearch licenses this file to you 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. | ||
|
||
[libdefaults] | ||
default_realm = ELASTIC | ||
dns_canonicalize_hostname = false | ||
dns_lookup_kdc = false | ||
dns_lookup_realm = false | ||
dns_uri_lookup = false | ||
forwardable = true | ||
ignore_acceptor_hostname = true | ||
rdns = false | ||
default_tgs_enctypes = aes128-cts-hmac-sha1-96 | ||
default_tkt_enctypes = aes128-cts-hmac-sha1-96 | ||
permitted_enctypes = aes128-cts-hmac-sha1-96 | ||
udp_preference_limit = 1 | ||
kdc_timeout = 3000 | ||
|
||
[realms] | ||
ELASTIC = { | ||
kdc = elasticsearch_kerberos.elastic:1088 | ||
admin_server = elasticsearch_kerberos.elastic:1749 | ||
default_domain = elastic | ||
} | ||
|
||
[domain_realm] | ||
.elastic = ELASTIC | ||
elastic = ELASTIC | ||
|
10 changes: 10 additions & 0 deletions
10
testing/environments/docker/elasticsearch/kerberos/init.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
# setup Keberos | ||
echo elasticsearch_kerberos.elastic > /etc/hostname && echo "127.0.0.1 elasticsearch_kerberos.elastic" >> /etc/hosts | ||
|
||
/scripts/installkdc.sh | ||
/scripts/addprincs.sh | ||
|
||
# add test user | ||
bin/elasticsearch-users useradd beats -r superuser -p testing | /usr/local/bin/docker-entrypoint.sh eswrapper |
73 changes: 73 additions & 0 deletions
73
testing/environments/docker/elasticsearch/kerberos/installkdc.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/bin/bash | ||
|
||
# Licensed to Elasticsearch under one or more contributor | ||
# license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright | ||
# ownership. Elasticsearch licenses this file to you 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. | ||
|
||
set -e | ||
|
||
# KDC installation steps and considerations based on https://web.mit.edu/kerberos/krb5-latest/doc/admin/install_kdc.html | ||
# and helpful input from https://help.ubuntu.com/community/Kerberos | ||
|
||
LOCALSTATEDIR=/etc | ||
LOGDIR=/var/log/krb5 | ||
|
||
#MARKER_FILE=/etc/marker | ||
|
||
# Transfer and interpolate krb5.conf | ||
cp /config/krb5.conf.template $LOCALSTATEDIR/krb5.conf | ||
sed -i 's/${REALM_NAME}/'$REALM_NAME'/g' $LOCALSTATEDIR/krb5.conf | ||
sed -i 's/${KDC_NAME}/'$KDC_NAME'/g' $LOCALSTATEDIR/krb5.conf | ||
sed -i 's/${BUILD_ZONE}/'$BUILD_ZONE'/g' $LOCALSTATEDIR/krb5.conf | ||
sed -i 's/${ELASTIC_ZONE}/'$ELASTIC_ZONE'/g' $LOCALSTATEDIR/krb5.conf | ||
|
||
|
||
# Transfer and interpolate the kdc.conf | ||
mkdir -p $LOCALSTATEDIR/krb5kdc | ||
cp /config/kdc.conf.template $LOCALSTATEDIR/krb5kdc/kdc.conf | ||
sed -i 's/${REALM_NAME}/'$REALM_NAME'/g' $LOCALSTATEDIR/krb5kdc/kdc.conf | ||
sed -i 's/${KDC_NAME}/'$KDC_NAME'/g' $LOCALSTATEDIR/krb5kdc/kdc.conf | ||
sed -i 's/${BUILD_ZONE}/'$BUILD_ZONE'/g' $LOCALSTATEDIR/krb5kdc/kdc.conf | ||
sed -i 's/${ELASTIC_ZONE}/'$ELASTIC_ZONE'/g' $LOCALSTATEDIR/krb5.conf | ||
|
||
# Touch logging locations | ||
mkdir -p $LOGDIR | ||
touch $LOGDIR/kadmin.log | ||
touch $LOGDIR/krb5kdc.log | ||
touch $LOGDIR/krb5lib.log | ||
|
||
# Update package manager | ||
yum update -qqy | ||
|
||
# Install krb5 packages | ||
yum install -qqy krb5-{server,libs,workstation} | ||
|
||
# Create kerberos database with stash file and garbage password | ||
kdb5_util create -s -r $REALM_NAME -P zyxwvutsrpqonmlk9876 | ||
|
||
# Set up admin acls | ||
cat << EOF > /etc/krb5kdc/kadm5.acl | ||
*/admin@$REALM_NAME * | ||
*@$REALM_NAME * | ||
*/*@$REALM_NAME i | ||
EOF | ||
|
||
# Create admin principal | ||
kadmin.local -q "addprinc -pw elastic admin/admin@$REALM_NAME" | ||
kadmin.local -q "ktadd -k /etc/admin.keytab admin/admin@$REALM_NAME" | ||
|
||
# Create a link so addprinc.sh is on path | ||
ln -s /scripts/addprinc.sh /usr/bin/ |
15 changes: 15 additions & 0 deletions
15
testing/environments/docker/elasticsearch_kerberos/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM docker.elastic.co/elasticsearch/elasticsearch:8.0.0-SNAPSHOT | ||
|
||
ADD scripts /scripts | ||
ADD config /config | ||
ADD healthcheck.sh /healthcheck.sh | ||
ADD start.sh /start.sh | ||
|
||
ENV REALM_NAME ELASTIC | ||
ENV KDC_NAME elasticsearch_kerberos.elastic | ||
ENV BUILD_ZONE elastic | ||
ENV ELASTIC_ZONE $BUILD_ZONE | ||
|
||
USER root | ||
RUN /scripts/installkdc.sh && /scripts/addprincs.sh | ||
USER elasticsearch |
34 changes: 34 additions & 0 deletions
34
testing/environments/docker/elasticsearch_kerberos/config/kdc.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Licensed to Elasticsearch under one or more contributor | ||
# license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright | ||
# ownership. Elasticsearch licenses this file to you 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. | ||
|
||
[kdcdefaults] | ||
kdc_listen = 1088 | ||
kdc_tcp_listen = 1088 | ||
|
||
[realms] | ||
${REALM_NAME} = { | ||
kadmind_port = 1749 | ||
max_life = 12h 0m 0s | ||
max_renewable_life = 7d 0h 0m 0s | ||
master_key_type = aes256-cts | ||
supported_enctypes = aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal | ||
} | ||
|
||
[logging] | ||
kdc = FILE:/var/log/krb5/krb5kdc.log | ||
admin_server = FILE:/var/log/krb5/kadmin.log | ||
default = FILE:/var/log/krb5/krb5lib.log |
25 changes: 25 additions & 0 deletions
25
testing/environments/docker/elasticsearch_kerberos/config/krb5.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[libdefaults] | ||
default_realm = ELASTIC | ||
dns_canonicalize_hostname = false | ||
dns_lookup_kdc = false | ||
dns_lookup_realm = false | ||
dns_uri_lookup = false | ||
forwardable = true | ||
ignore_acceptor_hostname = true | ||
rdns = false | ||
default_tgs_enctypes = aes128-cts-hmac-sha1-96 | ||
default_tkt_enctypes = aes128-cts-hmac-sha1-96 | ||
permitted_enctypes = aes128-cts-hmac-sha1-96 | ||
kdc_timeout = 3000 | ||
|
||
[realms] | ||
ELASTIC = { | ||
kdc = elasticsearch_kerberos.elastic:88 | ||
admin_server = elasticsearch_kerberos.elastic:749 | ||
default_domain = elastic | ||
} | ||
|
||
[domain_realm] | ||
.elastic = ELASTIC | ||
elastic = ELASTIC | ||
|
Oops, something went wrong.