Skip to content

Commit

Permalink
Server auto discover: allow fips package
Browse files Browse the repository at this point in the history
This PR changes auto discovery to use the fips package when using
fips-environments.

AFAIK, we dont support auto upgrade for fips environments.
  • Loading branch information
marcoandredinis authored and github-actions committed Oct 10, 2024
1 parent eeb5152 commit d72a764
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
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 @@ -2080,9 +2080,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

0 comments on commit d72a764

Please sign in to comment.