Skip to content
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

Server auto discover: allow fips package #46918

Merged
merged 1 commit into from
Oct 10, 2024
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
4 changes: 3 additions & 1 deletion api/types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const (
PackageNameOSS = "teleport"
// PackageNameEnt is the teleport package name for the Enterprise version.
PackageNameEnt = "teleport-ent"
// PackageNameEntFIPS is the teleport package name for the Enterprise with FIPS enabled version.
PackageNameEntFIPS = "teleport-ent-fips"

// ActionRead grants read access (get, list)
ActionRead = "read"
Expand Down Expand Up @@ -583,7 +585,7 @@ const (
)

// PackageNameKinds is the list of valid teleport package names.
var PackageNameKinds = []string{PackageNameOSS, PackageNameEnt}
var PackageNameKinds = []string{PackageNameOSS, PackageNameEnt, PackageNameEntFIPS}

// WebSessionSubKinds lists subkinds of web session resources
var WebSessionSubKinds = []string{KindAppSession, KindWebSession, KindSnowflakeSession, KindSAMLIdPSession}
Expand Down
8 changes: 6 additions & 2 deletions lib/srv/server/installer/autodiscover.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type AutoDiscoverNodeInstallerConfig struct {
ProxyPublicAddr string

// TeleportPackage contains the teleport package name.
// Allowed values: teleport, teleport-ent
// Allowed values: teleport, teleport-ent, teleport-ent-fips
TeleportPackage string

// RepositoryChannel is the repository channel to use.
Expand Down Expand Up @@ -129,10 +129,14 @@ func (c *AutoDiscoverNodeInstallerConfig) checkAndSetDefaults() error {
return trace.BadParameter("teleport-package must be one of %+v", types.PackageNameKinds)
}

if c.AutoUpgrades && c.TeleportPackage != types.PackageNameEnt {
if c.AutoUpgrades && c.TeleportPackage == types.PackageNameOSS {
return trace.BadParameter("only enterprise package supports auto upgrades")
}

if c.AutoUpgrades && c.TeleportPackage == types.PackageNameEntFIPS {
return trace.BadParameter("auto upgrades are not supported in FIPS environments")
}

if c.autoUpgradesChannelURL == "" {
c.autoUpgradesChannelURL = "https://" + c.ProxyPublicAddr + "/v1/webapi/automaticupgrades/channel/default"
}
Expand Down
42 changes: 42 additions & 0 deletions lib/srv/server/installer/autodiscover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,48 @@ func TestAutoDiscoverNode(t *testing.T) {
},
}

t.Run("check and set defaults", func(t *testing.T) {
t.Run("oss package is not allowed with auto upgrades", func(t *testing.T) {
installerConfig := &AutoDiscoverNodeInstallerConfig{
RepositoryChannel: "stable/rolling",
AutoUpgrades: true,
ProxyPublicAddr: "proxy.example.com",
TeleportPackage: "teleport",
TokenName: "my-token",
AzureClientID: "azure-client-id",
}

_, err := NewAutoDiscoverNodeInstaller(installerConfig)
require.Error(t, err)
})
t.Run("fips package is allowed", func(t *testing.T) {
installerConfig := &AutoDiscoverNodeInstallerConfig{
RepositoryChannel: "stable/rolling",
AutoUpgrades: false,
ProxyPublicAddr: "proxy.example.com",
TeleportPackage: "teleport-ent-fips",
TokenName: "my-token",
AzureClientID: "azure-client-id",
}

_, err := NewAutoDiscoverNodeInstaller(installerConfig)
require.NoError(t, err)
})
t.Run("fips is not allowed with auto upgrades", func(t *testing.T) {
installerConfig := &AutoDiscoverNodeInstallerConfig{
RepositoryChannel: "stable/rolling",
AutoUpgrades: true,
ProxyPublicAddr: "proxy.example.com",
TeleportPackage: "teleport-ent-fips",
TokenName: "my-token",
AzureClientID: "azure-client-id",
}

_, err := NewAutoDiscoverNodeInstaller(installerConfig)
require.Error(t, err)
})
})

t.Run("well known distros", func(t *testing.T) {
for distroName, distroVersions := range wellKnownOS {
for distroVersion, distroConfig := range distroVersions {
Expand Down
7 changes: 5 additions & 2 deletions lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2109,9 +2109,12 @@ func (h *Handler) installer(w http.ResponseWriter, r *http.Request, p httprouter
}

feats := modules.GetModules().Features()
teleportPackage := teleport.ComponentTeleport
teleportPackage := types.PackageNameOSS
if modules.GetModules().BuildType() == modules.BuildEnterprise || feats.Cloud {
teleportPackage = fmt.Sprintf("%s-%s", teleport.ComponentTeleport, modules.BuildEnterprise)
teleportPackage = types.PackageNameEnt
if h.cfg.FIPS {
teleportPackage = types.PackageNameEntFIPS
}
}

// By default, it uses the stable/v<majorVersion> channel.
Expand Down
Loading