-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
34772: ccl/gssapiccl: add GSS authentication support on Linux r=mjibson a=mjibson GSS support uses the same logic from postgres. It works by calling a C method statically compiled into cockroach in a loop, passing back and forth various GSS tokens until a completed authentication is done. Enterprise license checks are done at the end of a GSS auth session. This allows administrators to test and verify their GSS setup before needing to buy an enterprise license. We directly include the krb5 library so we can statically compile an exact version into the binary. The builder image has been changed to add (well, keep) bison/yacc which is needed to build krb5. Testing is done by using a docker-compose file. It defines containers for the kdc, cockroach server, and psql binary. This has proven to be the easiest way to get a correct test written. We support (and require) the include_realm=0 option to be present, which strips the realm from the GSS username. This removes the immediate need to either add user identity mapping or for allowing additional characters in usernames. The krb_realm option is also supported, with the addition that it can be specified more than once to support multiple realms at once. Release note (enterprise change): Add a GSS auth method configurable by the server.host_based_authentication.configuration cluster setting. Co-authored-by: Matt Jibson <[email protected]>
- Loading branch information
Showing
28 changed files
with
3,584 additions
and
2,115 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 |
---|---|---|
|
@@ -260,7 +260,6 @@ RUN apt-get purge -y \ | |
apt-transport-https \ | ||
automake \ | ||
autopoint \ | ||
bison \ | ||
bzip2 \ | ||
file \ | ||
flex \ | ||
|
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,4 @@ | ||
Bump the version below when changing krb5 configure flags. Search for "BUILD | ||
ARTIFACT CACHING" in build/common.mk for rationale. | ||
|
||
1 |
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,34 @@ | ||
version: '3' | ||
services: | ||
kdc: | ||
build: ./kdc | ||
volumes: | ||
- ./kdc/start.sh:/start.sh | ||
- keytab:/keytab | ||
cockroach: | ||
image: ubuntu:xenial-20170214 | ||
depends_on: | ||
- kdc | ||
command: /cockroach/cockroach --certs-dir=/certs start --listen-addr cockroach | ||
environment: | ||
- KRB5_KTNAME=/keytab/crdb.keytab | ||
volumes: | ||
- ../../.localcluster.certs:/certs | ||
- keytab:/keytab | ||
- ../../../../cockroach-linux-2.6.32-gnu-amd64:/cockroach/cockroach | ||
psql: | ||
build: ./psql | ||
depends_on: | ||
- cockroach | ||
environment: | ||
- PGHOST=cockroach | ||
- PGPORT=26257 | ||
- PGSSLCERT=/certs/node.crt | ||
- PGSSLKEY=/certs/node.key | ||
volumes: | ||
- ./kdc/krb5.conf:/etc/krb5.conf | ||
- ./psql/gss_test.go:/test/gss_test.go | ||
- ./psql/start.sh:/start.sh | ||
- ../../.localcluster.certs:/certs | ||
volumes: | ||
keytab: |
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,13 @@ | ||
FROM alpine:3.9 | ||
|
||
RUN apk add --no-cache \ | ||
krb5-server \ | ||
&& rm -rf /var/cache/apk/* | ||
|
||
COPY krb5.conf /etc/krb5.conf | ||
|
||
RUN kdb5_util create -s -P kpass \ | ||
&& kadmin.local -q "addprinc -pw psql [email protected]" \ | ||
&& kadmin.local -q "addprinc -randkey postgres/[email protected]" | ||
|
||
CMD ["/start.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,32 @@ | ||
[logging] | ||
default = FILE:/var/log/krb5libs.log | ||
kdc = FILE:/var/log/krb5kdc.log | ||
admin_server = FILE:/var/log/kadmind.log | ||
|
||
[libdefaults] | ||
default_realm = MY.EX | ||
dns_lookup_realm = false | ||
dns_lookup_kdc = false | ||
ticket_lifetime = 24h | ||
renew_lifetime = 7d | ||
forwardable = yes | ||
|
||
[realms] | ||
MY.EX = { | ||
kdc = kdc:88 | ||
admin_server = kdc:74 | ||
default_domain = my.ex | ||
} | ||
|
||
[domain_realm] | ||
.my.ex = MY.EX | ||
my.ex = MY.EX | ||
|
||
[appdefaults] | ||
pam = { | ||
debug = false | ||
ticket_lifetime = 36000 | ||
renew_lifetime = 36000 | ||
forwardable = true | ||
krb4_convert = false | ||
} |
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 | ||
|
||
set -e | ||
|
||
# The /keytab directory is volume mounted on both kdc and cockroach. kdc | ||
# can create the keytab with kadmin.local here and it is then useable | ||
# by cockroach. | ||
kadmin.local -q "ktadd -k /keytab/crdb.keytab postgres/[email protected]" | ||
|
||
krb5kdc -n |
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,24 @@ | ||
FROM postgres:11 | ||
|
||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends \ | ||
build-essential \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
krb5-user | ||
|
||
RUN curl https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz | tar xz -C /usr/local | ||
|
||
ENV PATH="/usr/local/go/bin:${PATH}" | ||
|
||
COPY gss_test.go /test/ | ||
|
||
# Fetch the go packages we need but remove the script so it can be | ||
# volume mounted at run-time enabling it to be changed without rebuilding | ||
# the image. | ||
RUN cd /test \ | ||
&& go get -d -t -tags gss \ | ||
&& rm -rf /test | ||
|
||
ENTRYPOINT ["/start.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,11 @@ | ||
// Copyright 2019 The Cockroach Authors. | ||
// | ||
// Licensed as a CockroachDB Enterprise file under the Cockroach Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt | ||
|
||
package gss | ||
|
||
// This file is here so go test always finds at least one file. |
Oops, something went wrong.