Skip to content

Commit 079bc5c

Browse files
committed
Merge remote-tracking branch 'origin/master' into timothyb89/bound-keypair-audit-events
2 parents 8731de0 + e71690a commit 079bc5c

File tree

848 files changed

+13086
-3973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

848 files changed

+13086
-3973
lines changed

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ linters:
113113
deny:
114114
- pkg: github.com/gravitational/teleport/integration
115115
desc: integration test should not be imported outside of intergation tests
116+
- pkg: github.com/gravitational/teleport/lib/srv/db/cassandra/testing
117+
desc: testing packages should not be imported outside of _test.go files
116118
logging:
117119
deny:
118120
- pkg: github.com/sirupsen/logrus
@@ -185,6 +187,10 @@ linters:
185187
desc: testing packages should not be imported outside of _test.go files
186188
- pkg: github.com/gravitational/teleport/tool/teleport/testenv
187189
desc: testing packages should not be imported outside of _test.go files
190+
- pkg: github.com/gravitational/teleport/lib/srv/db/redis/testing
191+
desc: testing packages should not be imported outside of _test.go files
192+
- pkg: github.com/gravitational/teleport/lib/srv/db/spanner/testing
193+
desc: testing packages should not be imported outside of _test.go files
188194
testify:
189195
files:
190196
- '!$test'

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,10 +917,11 @@ test-go-prepare: ensure-webassets bpf-bytecode $(TEST_LOG_DIR) ensure-gotestsum
917917

918918
# Runs base unit tests
919919
.PHONY: test-go-unit
920+
test-go-unit: rdpclient
920921
test-go-unit: FLAGS ?= -race -shuffle on
921922
test-go-unit: SUBJECT ?= $(shell go list ./... | grep -vE 'teleport/(e2e|integration|tool/tsh|integrations/operator|integrations/access|integrations/lib)')
922923
test-go-unit:
923-
$(CGOFLAG) GOEXPERIMENT=synctest go test -cover -json -tags "enablesynctest $(PAM_TAG) $(FIPS_TAG) $(BPF_TAG) $(LIBFIDO2_TEST_TAG) $(TOUCHID_TAG) $(PIV_TEST_TAG) $(VNETDAEMON_TAG)" $(PACKAGES) $(SUBJECT) $(FLAGS) $(ADDFLAGS) \
924+
$(CGOFLAG) GOEXPERIMENT=synctest go test -cover -json -tags "enablesynctest $(PAM_TAG) $(RDPCLIENT_TAG) $(FIPS_TAG) $$(BPF_TAG) $(LIBFIDO2_TEST_TAG) $(TOUCHID_TAG) $(PIV_TEST_TAG) $(VNETDAEMON_TAG)" $(PACKAGES) $(SUBJECT) $(FLAGS) $(ADDFLAGS) \
924925
| tee $(TEST_LOG_DIR)/unit.json \
925926
| gotestsum --raw-command -- cat
926927

@@ -1080,9 +1081,10 @@ FLAKY_RUNS ?= 3
10801081
FLAKY_TIMEOUT ?= 1h
10811082
FLAKY_TOP_N ?= 20
10821083
FLAKY_SUMMARY_FILE ?= /tmp/flaky-report.txt
1084+
test-go-flaky: rdpclient
10831085
test-go-flaky: FLAGS ?= -race -shuffle on
10841086
test-go-flaky: SUBJECT ?= $(shell go list ./... | grep -v -e e2e -e integration -e tool/tsh -e integrations/operator -e integrations/access -e integrations/lib )
1085-
test-go-flaky: GO_BUILD_TAGS ?= $(PAM_TAG) $(FIPS_TAG) $(BPF_TAG) $(TOUCHID_TAG) $(PIV_TEST_TAG) $(LIBFIDO2_TEST_TAG) $(VNETDAEMON_TAG)
1087+
test-go-flaky: GO_BUILD_TAGS ?= $(PAM_TAG) $(FIPS_TAG) $(RDPCLIENT_TAG) $(BPF_TAG) $(TOUCHID_TAG) $(PIV_TEST_TAG) $(LIBFIDO2_TEST_TAG) $(VNETDAEMON_TAG)
10861088
test-go-flaky: RENDER_FLAGS ?= -report-by flakiness -summary-file $(FLAKY_SUMMARY_FILE) -top $(FLAKY_TOP_N)
10871089
test-go-flaky: test-go-prepare $(RENDER_TESTS) $(RERUN)
10881090
$(CGOFLAG) $(RERUN) -n $(FLAKY_RUNS) -t $(FLAKY_TIMEOUT) \

api/client/proto/inventory.pb.go

Lines changed: 42 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23.10
55
require (
66
github.com/charlievieth/strcase v0.0.5
77
github.com/coreos/go-semver v0.3.1
8-
github.com/go-piv/piv-go v1.11.0
8+
github.com/go-piv/piv-go/v2 v2.3.0
99
github.com/gobwas/ws v1.4.0
1010
github.com/gogo/protobuf v1.3.2
1111
github.com/google/go-cmp v0.7.0

api/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
1616
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
1717
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
1818
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
19-
github.com/go-piv/piv-go v1.11.0 h1:5vAaCdRTFSIW4PeqMbnsDlUZ7odMYWnHBDGdmtU/Zhg=
20-
github.com/go-piv/piv-go v1.11.0/go.mod h1:NZ2zmjVkfFaL/CF8cVQ/pXdXtuj110zEKGdJM6fJZZM=
19+
github.com/go-piv/piv-go/v2 v2.3.0 h1:kKkrYlgLQTMPA6BiSL25A7/x4CEh2YCG7rtb/aTkx+g=
20+
github.com/go-piv/piv-go/v2 v2.3.0/go.mod h1:ShZi74nnrWNQEdWzRUd/3cSig3uNOcEZp+EWl0oewnI=
2121
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
2222
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
2323
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=

api/profile/profile.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,19 +317,26 @@ func FullProfilePath(dir string) string {
317317

318318
// defaultProfilePath retrieves the default path of the TSH profile.
319319
func defaultProfilePath() string {
320-
// start with UserHomeDir, which is the fastest option as it
321-
// relies only on environment variables and does not perform
322-
// a user lookup (which can be very slow on large AD environments)
323-
home, err := os.UserHomeDir()
324-
if err == nil && home != "" {
325-
return filepath.Join(home, profileDir)
320+
home, ok := UserHomeDir()
321+
if !ok {
322+
home = os.TempDir()
326323
}
324+
return filepath.Join(home, profileDir)
325+
}
327326

328-
home = os.TempDir()
327+
// UserHomeDir returns the current user's home directory if it can be found.
328+
func UserHomeDir() (string, bool) {
329+
// Start with os.UserHomeDir, which is the fastest option as it relies only
330+
// on environment variables and does not perform a user lookup (which can be
331+
// very slow on large AD environments).
332+
if home, err := os.UserHomeDir(); err == nil && home != "" {
333+
return home, true
334+
}
335+
// Fall back to the user lookup.
329336
if u, err := user.Current(); err == nil && u.HomeDir != "" {
330-
home = u.HomeDir
337+
return u.HomeDir, true
331338
}
332-
return filepath.Join(home, profileDir)
339+
return "", false
333340
}
334341

335342
// FromDir reads the user profile from a given directory. If dir is empty,

api/proto/teleport/legacy/client/proto/inventory.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package proto;
2020

2121
import "google/protobuf/timestamp.proto";
2222
import "teleport/legacy/types/types.proto";
23+
import "teleport/presence/v1/relay_server.proto";
2324

2425
option go_package = "github.com/gravitational/teleport/api/client/proto";
2526

@@ -166,6 +167,8 @@ message DownstreamInventoryHello {
166167
bool KubernetesHeartbeats = 17;
167168
// KubernetesCleanup indicates the ICS supports deleting kubernetes clusters when UpstreamInventoryGoodbye.DeleteResources is set.
168169
bool KubernetesCleanup = 18;
170+
// Indicates that the ICS supports heartbeating relay_server entries as well as deleting them on disconnect if UpstreamInventoryGoodbye.DeleteResources is set.
171+
bool relay_server_heartbeats_cleanup = 19;
169172
}
170173

171174
// SupportedCapabilities advertises the supported features of the auth server.
@@ -217,6 +220,8 @@ message InventoryHeartbeat {
217220
types.DatabaseServerV3 DatabaseServer = 3;
218221
// KubeServer is a complete kube server spec to be heartbeated.
219222
types.KubernetesServerV3 KubernetesServer = 4;
223+
// A relay_server to be heartbeated.
224+
teleport.presence.v1.RelayServer relay_server = 5;
220225
}
221226

222227
// UpstreamInventoryGoodbye informs the upstream service that instance

api/types/constants.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,15 @@ var KubernetesResourcesKinds = []string{
14401440
KindKubeIngress,
14411441
}
14421442

1443+
// KubernetesResourceSelfSubjectAccessReview is a Kubernetes resource that
1444+
// represents a self-subject access review. This gets injected in the allow section in the roles.
1445+
var KubernetesResourceSelfSubjectAccessReview = KubernetesResource{
1446+
Kind: "selfsubjectaccessreviews",
1447+
Name: Wildcard,
1448+
Verbs: []string{"create"},
1449+
APIGroup: "authorization.k8s.io",
1450+
}
1451+
14431452
// KubernetesResourcesV7KindGroups maps the legacy Teleport kube kinds
14441453
// to their kubernetes group.
14451454
// Used for validation in role >=v8 to check whether an older value has

api/types/role.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,12 @@ func (r *RoleV6) SetKubeGroups(rct RoleConditionType, groups []string) {
470470
// access to.
471471
func (r *RoleV6) GetKubeResources(rct RoleConditionType) []KubernetesResource {
472472
if rct == Allow {
473-
return r.convertAllowKubernetesResourcesBetweenRoleVersions(r.Spec.Allow.KubernetesResources)
473+
out := r.convertAllowKubernetesResourcesBetweenRoleVersions(r.Spec.Allow.KubernetesResources)
474+
// We need to support `kubectl auth can-i` as we prompt the user to use this when they get an access denied error.
475+
// Inject a selfsubjectaccessreviews resource to allow for it. It can still be explicitly denied by the role if
476+
// set in the `deny` section.
477+
out = append(out, KubernetesResourceSelfSubjectAccessReview)
478+
return out
474479
}
475480
return r.convertKubernetesResourcesBetweenRoleVersions(r.Spec.Deny.KubernetesResources)
476481
}

api/types/role_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ func TestRole_GetKubeResources(t *testing.T) {
661661
}
662662
if tt.wantDeny == nil {
663663
got := r.GetKubeResources(Allow)
664+
tt.wantAllow = append(tt.wantAllow, KubernetesResourceSelfSubjectAccessReview)
664665
require.Equal(t, tt.wantAllow, got)
665666
}
666667
got := r.GetKubeResources(Deny)

api/types/system_role.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ const (
3939
RoleProxy SystemRole = "Proxy"
4040
// RoleAdmin is admin role
4141
RoleAdmin SystemRole = "Admin"
42+
// RoleRelay is the system role for a relay in the cluster.
43+
RoleRelay SystemRole = "Relay"
4244
// RoleProvisionToken is a role for nodes authenticated using provisioning tokens
4345
RoleProvisionToken SystemRole = "ProvisionToken"
4446
// RoleTrustedCluster is a role needed for tokens used to add trusted clusters.
@@ -90,6 +92,7 @@ var roleMappings = map[string]SystemRole{
9092
"node": RoleNode,
9193
"proxy": RoleProxy,
9294
"admin": RoleAdmin,
95+
"relay": RoleRelay,
9396
"provisiontoken": RoleProvisionToken,
9497
"trusted_cluster": RoleTrustedCluster,
9598
"trustedcluster": RoleTrustedCluster,
@@ -132,6 +135,7 @@ var localServiceMappings = map[SystemRole]struct{}{
132135
RoleAuth: {},
133136
RoleNode: {},
134137
RoleProxy: {},
138+
RoleRelay: {},
135139
RoleKube: {},
136140
RoleApp: {},
137141
RoleDatabase: {},

api/types/trust.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ func (c CertAuthType) NewlyAdded() bool {
9595
return c.addedInMajorVer() >= api.VersionMajor
9696
}
9797

98-
// addedInVer return the major version in which given CA was added.
98+
// addedInMajorVer returns the major version in which given CA was added.
99+
// The returned version must be the X.0.0 release in which the CA first
100+
// existed.
99101
func (c CertAuthType) addedInMajorVer() int64 {
100102
switch c {
101103
case DatabaseCA:
@@ -107,7 +109,7 @@ func (c CertAuthType) addedInMajorVer() int64 {
107109
case SPIFFECA:
108110
return 15
109111
case OktaCA:
110-
return 16
112+
return 17
111113
case AWSRACA, BoundKeypairCA:
112114
return 18
113115
default:

api/utils/keypaths/keypaths.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ const (
8282
// vnetKnownHosts is the file name of the known_hosts file trusted by
8383
// third-party SSH clients connecting to VNet SSH.
8484
vnetKnownHosts = "vnet_known_hosts"
85-
// vnetSSHConfig is the file name of the generated OpenSSH-compatible config
85+
// VNetSSHConfig is the file name of the generated OpenSSH-compatible config
8686
// file to be used by third-party SSH clients connecting to VNet SSH.
87-
vnetSSHConfig = "vnet_ssh_config"
87+
VNetSSHConfig = "vnet_ssh_config"
8888
)
8989

9090
// Here's the file layout of all these keypaths.
@@ -463,7 +463,7 @@ func VNetKnownHostsPath(baseDir string) string {
463463
// VNetSSHConfigPath returns the path to VNet's generated OpenSSH-compatible
464464
// config file.
465465
func VNetSSHConfigPath(baseDir string) string {
466-
return filepath.Join(baseDir, vnetSSHConfig)
466+
return filepath.Join(baseDir, VNetSSHConfig)
467467
}
468468

469469
// TrimKeyPathSuffix returns the given path with any key suffix/extension trimmed off.

api/utils/keys/piv/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"io"
2626
"sync"
2727

28-
"github.com/go-piv/piv-go/piv"
28+
"github.com/go-piv/piv-go/v2/piv"
2929
"github.com/gravitational/trace"
3030

3131
"github.com/gravitational/teleport/api/utils/keys/hardwarekey"

0 commit comments

Comments
 (0)