Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions lib/auth/auth_with_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -4410,6 +4410,11 @@ func (a *ServerWithRoles) UpsertTrustedCluster(ctx context.Context, tc types.Tru
}

func (a *ServerWithRoles) ValidateTrustedCluster(ctx context.Context, validateRequest *ValidateTrustedClusterRequest) (*ValidateTrustedClusterResponse, error) {
// Don't allow leaf clusters if running in Cloud.
if modules.GetModules().Features().Cloud {
return nil, trace.NotImplemented("cloud clusters do not support trusted cluster resources")
}

// the token provides it's own authorization and authentication
return a.authServer.validateTrustedCluster(ctx, validateRequest)
}
Expand Down
17 changes: 17 additions & 0 deletions lib/auth/trustedcluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

"github.com/google/go-cmp/cmp"
"github.com/gravitational/trace"
"github.com/stretchr/testify/require"

"github.com/gravitational/teleport"
Expand All @@ -30,6 +31,7 @@ import (
"github.com/gravitational/teleport/lib/auth/keystore"
authority "github.com/gravitational/teleport/lib/auth/testauthority"
"github.com/gravitational/teleport/lib/backend/memory"
"github.com/gravitational/teleport/lib/modules"
"github.com/gravitational/teleport/lib/services"
"github.com/gravitational/teleport/lib/services/suite"
)
Expand Down Expand Up @@ -391,6 +393,21 @@ func TestValidateTrustedCluster(t *testing.T) {
[]types.CertAuthType{resp.CAs[0].GetType(), resp.CAs[1].GetType(), resp.CAs[2].GetType()},
)
})

t.Run("trusted clusters prevented on cloud", func(t *testing.T) {
modules.SetTestModules(t, &modules.TestModules{
TestFeatures: modules.Features{Cloud: true},
})

req := &ValidateTrustedClusterRequest{
Token: "invalidtoken",
CAs: []types.CertAuthority{},
}

server := ServerWithRoles{authServer: a}
_, err := server.ValidateTrustedCluster(ctx, req)
require.True(t, trace.IsNotImplemented(err), "ValidateTrustedCluster returned an unexpected error, got = %v (%T), want trace.NotImplementedError", err, err)
})
}

func newTestAuthServer(ctx context.Context, t *testing.T, name ...string) *Server {
Expand Down