Skip to content

Commit

Permalink
Add env var to disable Role Visualizer (#51880)
Browse files Browse the repository at this point in the history
This is a temporary escape hatch to disable the role diff visualizer.
  • Loading branch information
avatus authored Feb 7, 2025
1 parent 99377ac commit 801bd8f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions api/client/webclient/webconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ type WebConfig struct {
// IsPolicyEnabled is true if [Features.Policy] = true
// Deprecated, use entitlements
IsPolicyEnabled bool `json:"isPolicyEnabled"`
// TODO (avatus) delete in v18
// IsPolicyRoleVisualizerEnabled is the graph visualizer for diffs made
// when editing roles in the Web UI. This defaults to true, but has an environment
// variable to turn off if needed TELEPORT_UNSTABLE_DISABLE_ROLE_VISUALIZER=true
IsPolicyRoleVisualizerEnabled bool `json:"isPolicyRoleVisualizerEnabled"`
// featureLimits define limits for features.
// Typically used with feature teasers if feature is not enabled for the
// product type eg: Team product contains teasers to upgrade to Enterprise.
Expand Down
4 changes: 4 additions & 0 deletions lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"net"
"net/http"
"net/url"
"os"
"slices"
"strconv"
"strings"
Expand Down Expand Up @@ -1854,6 +1855,8 @@ func (h *Handler) getWebConfig(w http.ResponseWriter, r *http.Request, p httprou
}
}

disableRoleVisualizer, _ := strconv.ParseBool(os.Getenv("TELEPORT_UNSTABLE_DISABLE_ROLE_VISUALIZER"))

webCfg := webclient.WebConfig{
Edition: modules.GetModules().BuildType(),
Auth: authSettings,
Expand All @@ -1862,6 +1865,7 @@ func (h *Handler) getWebConfig(w http.ResponseWriter, r *http.Request, p httprou
TunnelPublicAddress: tunnelPublicAddr,
RecoveryCodesEnabled: clusterFeatures.GetRecoveryCodes(),
UI: h.getUIConfig(r.Context()),
IsPolicyRoleVisualizerEnabled: !disableRoleVisualizer,
IsDashboard: services.IsDashboard(clusterFeatures),
IsTeam: false,
IsUsageBasedBilling: clusterFeatures.GetIsUsageBased(),
Expand Down
4 changes: 3 additions & 1 deletion lib/web/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4801,6 +4801,7 @@ func TestGetWebConfig_WithEntitlements(t *testing.T) {
TunnelPublicAddress: "",
RecoveryCodesEnabled: false,
UI: webclient.UIConfig{},
IsPolicyRoleVisualizerEnabled: true,
IsDashboard: false,
IsUsageBasedBilling: false,
AutomaticUpgradesTargetVersion: "",
Expand Down Expand Up @@ -4982,7 +4983,8 @@ func TestGetWebConfig_LegacyFeatureLimits(t *testing.T) {
string(entitlements.UsageReporting): {Enabled: false},
string(entitlements.LicenseAutoUpdate): {Enabled: false},
},
PlayableDatabaseProtocols: player.SupportedDatabaseProtocols,
PlayableDatabaseProtocols: player.SupportedDatabaseProtocols,
IsPolicyRoleVisualizerEnabled: true,
}

clt := env.proxies[0].newClient(t)
Expand Down
4 changes: 4 additions & 0 deletions web/packages/teleport/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const cfg = {
edition: 'oss',
isCloud: false,
automaticUpgrades: false,
// TODO (avatus) this is a temporary escape hatch. Delete in v18
// The role diff visualizer can be disabled by setting TELEPORT_UNSTABLE_DISABLE_ROLE_VISUALIZER=true
// in the proxy service
isPolicyRoleVisualizerEnabled: true,
automaticUpgradesTargetVersion: '',
// isDashboard is used generally when we want to hide features that can't be hidden by RBAC in
// the case of a self-hosted license tenant dashboard.
Expand Down

0 comments on commit 801bd8f

Please sign in to comment.