-
Notifications
You must be signed in to change notification settings - Fork 1k
RANGER-5373: Docker setup updated to run KDC and create keytabs for service accounts #704
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
Open
mneethiraj
wants to merge
6
commits into
apache:master
Choose a base branch
from
mneethiraj:RANGER-5373
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ca941b6
RANGER-5373: Docker setup updated to run KDC and create keytabs for s…
mneethiraj 7eba338
RANGER-5373: addressed review comments; verified kerberos authenticat…
mneethiraj 4573f13
RANGER-5373: #3
mneethiraj 3a93709
RANGER-5373: update Hive container for Kerberos authentication #4
mneethiraj ae9f814
RANGER-5373: update HBase container for Kerberos authentication - #5
mneethiraj 1eaf645
RANGER-5373: update Kafka container for Kerberos authentication - #6
mneethiraj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,42 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF 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. | ||
|
|
||
| ARG RANGER_BASE_JAVA_VERSION=8 | ||
|
|
||
| FROM eclipse-temurin:${RANGER_BASE_JAVA_VERSION}-jdk-jammy | ||
|
|
||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| ENV REALM=EXAMPLE.COM | ||
| ENV KDC_HOST=kdc.example.com | ||
| ENV ADMIN_PRINCIPAL=admin/admin | ||
| ENV ADMIN_PASSWORD=rangerR0cks! | ||
| ENV MASTER_PASSWORD=rangerR0cks! | ||
|
|
||
| # Install Kerberos components | ||
| RUN apt-get update && \ | ||
| apt-get install -y krb5-kdc krb5-admin-server krb5-user && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Copy configuration files | ||
| COPY config/kdc/krb5.conf /etc/krb5.conf | ||
| COPY config/kdc/kdc.conf /etc/krb5kdc/kdc.conf | ||
| COPY config/kdc/kadm5.acl /etc/krb5kdc/kadm5.acl | ||
| COPY config/kdc/entrypoint.sh /entrypoint.sh | ||
| RUN chmod +x /entrypoint.sh | ||
|
|
||
| EXPOSE 88/tcp 88/udp 749/tcp | ||
|
|
||
| ENTRYPOINT ["/entrypoint.sh"] |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,41 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF 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. | ||
|
|
||
| ADMIN_PRINCIPAL=admin/admin | ||
| ADMIN_PASSWORD=rangerR0cks! | ||
|
|
||
| PRINCIPAL_NAME=$1 | ||
| KEYTAB_DIR=$2 | ||
| KEYTAB_OWNER=$3 | ||
|
|
||
| PRINCIPAL=${PRINCIPAL_NAME}/`hostname -f` | ||
| KEYTAB=${KEYTAB_DIR}/${PRINCIPAL_NAME}.keytab | ||
|
|
||
| echo "Creating Kerberos principal ${PRINCIPAL} .." | ||
| echo ${ADMIN_PASSWORD} | kadmin -p ${ADMIN_PRINCIPAL} -q "addprinc -randkey ${PRINCIPAL}" | ||
|
|
||
| mkdir -p ${KEYTAB_DIR} | ||
|
|
||
| echo "Creating keytab for principal ${PRINCIPAL} .." | ||
| echo ${ADMIN_PASSWORD} | kadmin -p ${ADMIN_PRINCIPAL} -q "ktadd -k ${KEYTAB} ${PRINCIPAL}" | ||
|
|
||
| if [ "${KEYTAB_OWNER}" != "" ] | ||
| then | ||
| chmod 440 ${KEYTAB} | ||
| chown ${KEYTAB_OWNER} ${KEYTAB} | ||
| fi | ||
This file contains hidden or 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,61 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF 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 | ||
|
|
||
| REALM="${REALM:-EXAMPLE.COM}" | ||
| KDC_HOST="${KDC_HOST:-ranger-kdc.rangernw}" | ||
| MASTER_PASSWORD="${MASTER_PASSWORD:-masterpassword}" | ||
| ADMIN_PRINC="${ADMIN_PRINCIPAL:-admin/admin}" | ||
| ADMIN_PASSWORD="${ADMIN_PASSWORD:-adminpassword}" | ||
|
|
||
| DB_DIR=/var/kerberos/krb5kdc | ||
|
|
||
| # ensure directories | ||
| mkdir -p $DB_DIR | ||
| chown -R root.root /etc/krb5kdc || true | ||
| chown -R root.root $DB_DIR || true | ||
|
|
||
| if [ ! -f $DB_DIR/principal ]; then | ||
| echo "=== Creating KDC database for realm $REALM ===" | ||
| # create DB noninteractive | ||
| echo "$MASTER_PASSWORD" | kdb5_util create -s -r $REALM -P "$MASTER_PASSWORD" | ||
| # create admin principal | ||
| kadmin.local -q "addprinc -pw $ADMIN_PASSWORD $ADMIN_PRINC@${REALM}" | ||
| # add kadmind keytab | ||
| kadmin.local -q "ktadd -k /etc/krb5kdc/kadm5.keytab kadmin/admin@$REALM" | ||
| echo "Database initialized" | ||
| else | ||
| echo "KDC DB already exists; skipping create" | ||
| fi | ||
|
|
||
| # Ensure ownership and perms | ||
| chown -R root:root /var/kerberos | ||
| chmod 700 /var/kerberos/krb5kdc | ||
|
|
||
| # start krb5kdc in foreground and then kadmind | ||
| echo "Starting krb5kdc..." | ||
| /usr/sbin/krb5kdc -n & | ||
| KDC_PID=$! | ||
|
|
||
| echo "Starting kadmind..." | ||
| /usr/sbin/kadmind -nofork | ||
| # if kadmind exits, bring down krb5kdc | ||
| kill $KDC_PID || true | ||
| wait $KDC_PID || true | ||
|
|
This file contains hidden or 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 @@ | ||
| */[email protected] * |
This file contains hidden or 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,16 @@ | ||
| [kdcdefaults] | ||
| kdc_ports = 88 | ||
| kdc_tcp_ports = 88 | ||
|
|
||
| [realms] | ||
| EXAMPLE.COM = { | ||
| # where the DB will be stored | ||
| database_name = /var/kerberos/krb5kdc/principal | ||
| admin_keytab = /etc/krb5kdc/kadm5.keytab | ||
| acl_file = /etc/krb5kdc/kadm5.acl | ||
| dict_file = /usr/share/dict/words | ||
| key_stash_file = /var/kerberos/krb5kdc/.k5.EXAMPLE.COM | ||
| max_life = 24h 0m 0s | ||
| max_renewable_life = 7d 0h 0m 0s | ||
| } | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hard-coded credentials in the script create a security vulnerability. These credentials should be passed as environment variables or parameters instead of being embedded in the script.