Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
00a2969
Introduce config v3, add auth_server and proxy_address
ryanclark Sep 22, 2022
78d7af2
Rename `join_method` to `method`
ryanclark Sep 22, 2022
98b729a
Remove random file
ryanclark Sep 22, 2022
73c19a1
Add `AuthToken` back for config v1 & v2, error if used in v3
ryanclark Sep 22, 2022
e371fd5
Only validate that auth_server isn't set when the auth service isn't …
ryanclark Sep 22, 2022
265a92c
Improve the error message for using auth_token with config v3
ryanclark Sep 22, 2022
ebc226c
Fix tests
ryanclark Sep 22, 2022
53e267b
Set default config version for tctl commands
ryanclark Sep 22, 2022
a7f21a7
Fix tests, set default config version to v1
ryanclark Sep 22, 2022
b3d5491
Remove ProxyServer test
ryanclark Sep 22, 2022
2485cdd
Change all nodes created during proxy testing to use config v3 & `Pro…
ryanclark Sep 22, 2022
b1a63a8
Allow proxy address to be given when registering a node
ryanclark Sep 22, 2022
c0910e0
Improve port checking warnings
ryanclark Sep 22, 2022
b0eb57d
Detect if a proxy address is an auth server during registration
ryanclark Sep 22, 2022
6ce02d9
Only set the auth server address if a proxy address isn't given
ryanclark Sep 22, 2022
7689635
Correctly set the CA path when `data_dir` is specified in the config
ryanclark Sep 22, 2022
40c37fd
Improve the bad parameter error when using auth_servers with v3
ryanclark Sep 22, 2022
3e36b08
Change `newClient` to use different connection strategies based on th…
ryanclark Sep 22, 2022
1272025
Wording changes for consistency
ryanclark Sep 22, 2022
10691d8
Add a changelog for the config versions
ryanclark Sep 22, 2022
39b6f12
Fix typo, wrap error
ryanclark Sep 22, 2022
66ea782
Remove duplicate error reporting
ryanclark Sep 22, 2022
7d36d63
Change `switch` version checks to `if` statements
ryanclark Sep 22, 2022
391bcf8
Use `TeleportConfigVersions` instead of `TeleportVersions`
ryanclark Sep 22, 2022
cbda2b7
Remove version check when retrieving the value of auth server addresses
ryanclark Sep 22, 2022
ae5d5ea
Simplify variable names now they're now scoped
ryanclark Sep 22, 2022
e62327e
Improve the API for getting & setting auth server addresses
ryanclark Sep 22, 2022
92a8dc2
Fix comment spacing
ryanclark Sep 22, 2022
fcd8550
Add method for validating join methods
ryanclark Sep 22, 2022
17f137e
Improve the token application logic
ryanclark Sep 22, 2022
34797fa
Add the auth listen address to the auth servers list only when empty
ryanclark Sep 22, 2022
1bc1f2d
Add discover_service to the expected error message
ryanclark Sep 22, 2022
7e71303
Fix the logic for setting join params
ryanclark Sep 22, 2022
989e429
Append to auth servers when starting a node during tests with config …
ryanclark Sep 22, 2022
7339dbe
Apply suggestions from code review
ryanclark Sep 22, 2022
adb3e8b
Only attempt to registry through the proxy when given a proxy address
ryanclark Sep 26, 2022
faf76b1
Merge config checking and default setting into one method
ryanclark Sep 26, 2022
213293c
Check if both proxy_server and auth_server are set when applying the …
ryanclark Sep 26, 2022
949948f
Remove unneeded switch statement
ryanclark Sep 26, 2022
be9a4b3
Fix punctuation
ryanclark Sep 26, 2022
bdcff43
Improve the go doc for `JoinStrings`
ryanclark Sep 26, 2022
216d971
Reword the messaging to convey a connection is actually going to the …
ryanclark Sep 26, 2022
f7ce5b4
Change the fake tokens to obvious fake ones
ryanclark Sep 26, 2022
0977d5b
Undo whitespace changes
ryanclark Sep 26, 2022
464832a
Apply suggestions from code review
ryanclark Sep 26, 2022
c3acd9d
Change the configure AD script to output a v3 config
ryanclark Sep 26, 2022
9b4d0d3
Add `auth_token` back in
ryanclark Sep 27, 2022
4c3f4b1
Remove notice from the top of the config page
ryanclark Sep 27, 2022
b956340
Update e ref
ryanclark Sep 27, 2022
e437493
Update helm snaphot
ryanclark Sep 27, 2022
a23a192
Change the configure AD script to use `auth_token`
ryanclark Sep 27, 2022
83b4b11
Improve the error message for validating the join method
ryanclark Sep 27, 2022
25dfbea
Fix correct assertion
ryanclark Sep 28, 2022
be6c859
Do not enable the kube service if the config version is empty
ryanclark Sep 28, 2022
a2f4ce5
Update bats tests
ryanclark Sep 28, 2022
10225fb
Also check if the config version is empty
ryanclark Sep 28, 2022
dff9cfd
Update e ref
ryanclark Sep 28, 2022
294edde
Update e ref
ryanclark Sep 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/types/installers/installer.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# token is read as a parameter from the AWS ssm script run and
# passed as the first argument to the script
sudo /usr/local/bin/teleport node configure \
--auth-server="{{ .PublicProxyAddr }}" \
--proxy="{{ .PublicProxyAddr }}" \
--join-method=iam \
--token="$1" \
--output=file \
Expand Down
16 changes: 16 additions & 0 deletions api/types/provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"time"

"github.com/gravitational/teleport/api/defaults"
apiutils "github.com/gravitational/teleport/api/utils"

"github.com/gravitational/trace"
)
Expand All @@ -39,6 +40,21 @@ const (
JoinMethodIAM JoinMethod = "iam"
)

var JoinMethods = []JoinMethod{
JoinMethodToken,
JoinMethodEC2,
JoinMethodIAM,
}

func ValidateJoinMethod(method JoinMethod) error {
hasJoinMethod := apiutils.SliceContainsStr(JoinMethods, method)
if !hasJoinMethod {
return trace.BadParameter("join method must be one of %s", apiutils.JoinStrings(JoinMethods, ", "))
}

return nil
}

// ProvisionToken is a provisioning token
type ProvisionToken interface {
Resource
Expand Down
31 changes: 30 additions & 1 deletion api/utils/slices.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ limitations under the License.

package utils

import (
"strings"
)

// CopyByteSlice returns a copy of the byte slice.
func CopyByteSlice(in []byte) []byte {
if in == nil {
Expand Down Expand Up @@ -52,7 +56,7 @@ func StringSlicesEqual(a, b []string) bool {
}

// SliceContainsStr returns 'true' if the slice contains the given value
func SliceContainsStr(slice []string, value string) bool {
func SliceContainsStr[T ~string](slice []T, value T) bool {
for i := range slice {
if slice[i] == value {
return true
Expand All @@ -61,6 +65,31 @@ func SliceContainsStr(slice []string, value string) bool {
return false
}

// JoinStrings returns a string that is all the elements in the slice `T[]` joined by `sep`
// This being generic allows for the usage of custom string times, without having to convert
// the elements to a string to be passed into `strings.Join`.
func JoinStrings[T ~string](elems []T, sep string) T {
switch len(elems) {
case 0:
return ""
case 1:
return elems[0]
}
n := len(sep) * (len(elems) - 1)
for i := 0; i < len(elems); i++ {
n += len(elems[i])
}

var b strings.Builder
b.Grow(n)
b.WriteString(string(elems[0]))
for _, s := range elems[1:] {
b.WriteString(sep)
b.WriteString(string(s))
}
return T(b.String())
Comment thread
ryanclark marked this conversation as resolved.
}

// Deduplicate deduplicates list of strings
func Deduplicate(in []string) []string {
if len(in) == 0 {
Expand Down
19 changes: 10 additions & 9 deletions assets/aws/files/bin/teleport-generate-config
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ elif [[ "${TELEPORT_ROLE}" == "proxy" ]]; then
# Teleport proxy proxies and optionally records
# SSH sessions
cat >${USE_CONFIG_PATH} <<EOF
version: v3
teleport:
auth_token: /var/lib/teleport/token
ca_pin: CA_PIN_HASH_PLACEHOLDER
Expand All @@ -324,8 +325,7 @@ teleport:
storage:
type: dir
path: /var/lib/teleport/backend
auth_servers:
- ${TELEPORT_AUTH_SERVER_LB}:3025
auth_server: ${TELEPORT_AUTH_SERVER_LB}:3025

auth_service:
enabled: no
Expand All @@ -348,7 +348,7 @@ EOF
if [[ "${USE_ACM}" != "true" ]]; then
write_https_keypairs_section
fi

# set up the database listeners
write_database_section TELEPORT_DOMAIN_NAME

Expand All @@ -374,6 +374,7 @@ elif [[ "${TELEPORT_ROLE}" == "node" ]]; then
echo "node" > ${USE_CONFD_DIR}/role.node
# Teleport node handles incoming connections
cat >${USE_CONFIG_PATH} <<EOF
version: v3
teleport:
auth_token: /var/lib/teleport/token
ca_pin: CA_PIN_HASH_PLACEHOLDER
Expand All @@ -386,8 +387,7 @@ teleport:
storage:
type: dir
path: /var/lib/teleport/backend
auth_servers:
- ${TELEPORT_AUTH_SERVER_LB}:3025
auth_server: ${TELEPORT_AUTH_SERVER_LB}:443

auth_service:
enabled: no
Expand Down Expand Up @@ -506,7 +506,7 @@ EOF

# set up the database listeners
write_database_section TELEPORT_EXTERNAL_HOSTNAME

# set up the kubernetes listener
write_kubernetes_section TELEPORT_EXTERNAL_HOSTNAME

Expand All @@ -527,7 +527,7 @@ EOF

# set up the database listeners
write_database_section TELEPORT_EXTERNAL_HOSTNAME

# set up the kubernetes listener
write_kubernetes_section TELEPORT_EXTERNAL_HOSTNAME

Expand Down Expand Up @@ -588,7 +588,7 @@ EOF

# write ssh/tunnel config
write_ssh_and_tunnel_section 3080

# set up the database listeners
write_database_section TELEPORT_EXTERNAL_HOSTNAME

Expand Down Expand Up @@ -767,13 +767,14 @@ EOF
elif [[ "${TELEPORT_ROLE}" == "agent" ]]; then
echo "agent" > ${USE_CONFD_DIR}/role.agent
cat >${USE_CONFIG_PATH} <<EOF
version: v3
teleport:
log:
output: stderr
severity: INFO
data_dir: /var/lib/teleport
auth_token: ${TELEPORT_JOIN_TOKEN}
auth_servers: ['${TELEPORT_PROXY_SERVER_LB}']
proxy_server: ${TELEPORT_PROXY_SERVER_LB}

auth_service:
enabled: no
Expand Down
4 changes: 2 additions & 2 deletions assets/aws/files/tests/agent-app.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ load fixtures/common
[ ${GENERATE_EXIT_CODE?} -eq 0 ]
}

@test "[${TEST_SUITE?}] teleport.auth_servers is set correctly" {
@test "[${TEST_SUITE?}] teleport.proxy_server is set correctly" {
load ${TELEPORT_CONFD_DIR?}/conf
cat "${TELEPORT_CONFIG_PATH?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_servers:" -A1 | grep -q "${TELEPORT_PROXY_SERVER_LB?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ proxy_server:" -A1 | grep -q "${TELEPORT_PROXY_SERVER_LB?}"
}

@test "[${TEST_SUITE?}] teleport.auth_token is set correctly" {
Expand Down
4 changes: 2 additions & 2 deletions assets/aws/files/tests/agent-db.bats
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ load fixtures/common
[ ${GENERATE_EXIT_CODE?} -eq 0 ]
}

@test "[${TEST_SUITE?}] teleport.auth_servers is set correctly" {
@test "[${TEST_SUITE?}] teleport.proxy_server is set correctly" {
load ${TELEPORT_CONFD_DIR?}/conf
cat "${TELEPORT_CONFIG_PATH?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_servers:" -A1 | grep -q "${TELEPORT_PROXY_SERVER_LB?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ proxy_server:" -A1 | grep -q "${TELEPORT_PROXY_SERVER_LB?}"
}

@test "[${TEST_SUITE?}] teleport.auth_token is set correctly" {
Expand Down
4 changes: 2 additions & 2 deletions assets/aws/files/tests/agent-ssh.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ load fixtures/common
[ ${GENERATE_EXIT_CODE?} -eq 0 ]
}

@test "[${TEST_SUITE?}] teleport.auth_servers is set correctly" {
@test "[${TEST_SUITE?}] teleport.proxy_server is set correctly" {
load ${TELEPORT_CONFD_DIR?}/conf
cat "${TELEPORT_CONFIG_PATH?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_servers:" -A1 | grep -q "${TELEPORT_PROXY_SERVER_LB?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ proxy_server:" -A1 | grep -q "${TELEPORT_PROXY_SERVER_LB?}"
}

@test "[${TEST_SUITE?}] teleport.auth_token is set correctly" {
Expand Down
4 changes: 2 additions & 2 deletions assets/aws/files/tests/ha-node.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ load fixtures/common
[ ${GENERATE_EXIT_CODE?} -eq 0 ]
}

@test "[${TEST_SUITE?}] teleport.auth_servers is set correctly" {
@test "[${TEST_SUITE?}] teleport.auth_server is set correctly" {
load ${TELEPORT_CONFD_DIR?}/conf
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_servers:" -A1 | grep -q "${TELEPORT_AUTH_SERVER_LB?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_server:" -A1 | grep -q "${TELEPORT_AUTH_SERVER_LB?}"
}

# in each test, we echo the block so that if the test fails, the block is outputted
Expand Down
4 changes: 2 additions & 2 deletions assets/aws/files/tests/ha-proxy-acm-alias.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ load fixtures/common
[ ${GENERATE_EXIT_CODE?} -eq 0 ]
}

@test "[${TEST_SUITE?}] teleport.auth_servers is set correctly" {
@test "[${TEST_SUITE?}] teleport.auth_server is set correctly" {
load ${TELEPORT_CONFD_DIR?}/conf
cat "${TELEPORT_CONFIG_PATH?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_servers:" -A1 | grep -q "${TELEPORT_AUTH_SERVER_LB?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_server:" -A1 | grep -q "${TELEPORT_AUTH_SERVER_LB?}"
}

# in each test, we echo the block so that if the test fails, the block is outputted
Expand Down
4 changes: 2 additions & 2 deletions assets/aws/files/tests/ha-proxy-acm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ load fixtures/common
[ ${GENERATE_EXIT_CODE?} -eq 0 ]
}

@test "[${TEST_SUITE?}] teleport.auth_servers is set correctly" {
@test "[${TEST_SUITE?}] teleport.auth_server is set correctly" {
load ${TELEPORT_CONFD_DIR?}/conf
cat "${TELEPORT_CONFIG_PATH?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_servers:" -A1 | grep -q "${TELEPORT_AUTH_SERVER_LB?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_server:" -A1 | grep -q "${TELEPORT_AUTH_SERVER_LB?}"
}

# in each test, we echo the block so that if the test fails, the block is outputted
Expand Down
4 changes: 2 additions & 2 deletions assets/aws/files/tests/ha-proxy-mysql.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ load fixtures/common
[ ${GENERATE_EXIT_CODE?} -eq 0 ]
}

@test "[${TEST_SUITE?}] teleport.auth_servers is set correctly" {
@test "[${TEST_SUITE?}] teleport.auth_server is set correctly" {
load ${TELEPORT_CONFD_DIR?}/conf
cat "${TELEPORT_CONFIG_PATH?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_servers:" -A1 | grep -q "${TELEPORT_AUTH_SERVER_LB?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_server:" -A1 | grep -q "${TELEPORT_AUTH_SERVER_LB?}"
}

# in each test, we echo the block so that if the test fails, the block is outputted
Expand Down
4 changes: 2 additions & 2 deletions assets/aws/files/tests/ha-proxy-no-db.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ load fixtures/common
[ ${GENERATE_EXIT_CODE?} -eq 0 ]
}

@test "[${TEST_SUITE?}] teleport.auth_servers is set correctly" {
@test "[${TEST_SUITE?}] teleport.auth_server is set correctly" {
load ${TELEPORT_CONFD_DIR?}/conf
cat "${TELEPORT_CONFIG_PATH?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_servers:" -A1 | grep -q "${TELEPORT_AUTH_SERVER_LB?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_server:" -A1 | grep -q "${TELEPORT_AUTH_SERVER_LB?}"
}

# in each test, we echo the block so that if the test fails, the block is outputted
Expand Down
4 changes: 2 additions & 2 deletions assets/aws/files/tests/ha-proxy.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ load fixtures/common
[ ${GENERATE_EXIT_CODE?} -eq 0 ]
}

@test "[${TEST_SUITE?}] teleport.auth_servers is set correctly" {
@test "[${TEST_SUITE?}] teleport.auth_server is set correctly" {
load ${TELEPORT_CONFD_DIR?}/conf
cat "${TELEPORT_CONFIG_PATH?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_servers:" -A1 | grep -q "${TELEPORT_AUTH_SERVER_LB?}"
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_server:" -A1 | grep -q "${TELEPORT_AUTH_SERVER_LB?}"
}

# in each test, we echo the block so that if the test fails, the block is outputted
Expand Down
5 changes: 3 additions & 2 deletions assets/loadtest/teleport/teleport-iot-node.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: v3
teleport:
data_dir: /var/lib/teleport
log:
Expand All @@ -6,11 +7,11 @@ teleport:
output: json
storage:
type: dir
auth_servers: ["${PROXY_HOST}:3080"]
auth_token: "node-${NODE_TOKEN}"
proxy_server: ${PROXY_HOST}:3080
auth_service:
enabled: false
proxy_service:
enabled: false
ssh_service:
enabled: true
enabled: true
5 changes: 3 additions & 2 deletions assets/loadtest/teleport/teleport-node.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: v3
teleport:
data_dir: /var/lib/teleport
log:
Expand All @@ -6,11 +7,11 @@ teleport:
output: json
storage:
type: dir
auth_servers: ["auth:3025"]
auth_token: "node-${NODE_TOKEN}"
auth_server: auth:3025
auth_service:
enabled: false
proxy_service:
enabled: false
ssh_service:
enabled: true
enabled: true
5 changes: 3 additions & 2 deletions assets/loadtest/teleport/teleport-proxy.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
version: v3
teleport:
log:
severity: DEBUG
format:
output: json

data_dir: /var/lib/teleport
auth_servers: ["auth:3025"]
auth_server: auth:3025
auth_token: "proxy-${PROXY_TOKEN}"
cache:
type: in-memory
Expand All @@ -24,4 +25,4 @@ proxy_service:
https_cert_file: /etc/teleport-tls/tls.crt
https_key_file: /etc/teleport-tls/tls.key
public_addr: "${PROXY_HOST}:3080"
tunnel_public_addr: "${PROXY_HOST}:3024"
tunnel_public_addr: "${PROXY_HOST}:3024"
15 changes: 8 additions & 7 deletions docker/one-node.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
version: v3
teleport:
auth_servers: ["one"]
auth_server: one
auth_token: foo
log:
output: /var/lib/teleport/teleport.log
severity: INFO

data_dir: /var/lib/teleport
storage:
path: /var/lib/teleport/backend
type: dir
path: /var/lib/teleport/backend
type: dir

auth_service:
enabled: no

ssh_service:
enabled: yes
labels:
cluster: one
cluster: one
commands:
- name: kernel
command: [/bin/uname, -r]
period: 5m
- name: kernel
command: [ /bin/uname, -r ]
period: 5m

proxy_service:
enabled: no
Expand Down
Loading