Skip to content

Commit be4ca92

Browse files
committed
adding access graph entitlement
1 parent bb981e0 commit be4ca92

File tree

5 files changed

+30
-23
lines changed

5 files changed

+30
-23
lines changed

entitlements/entitlements.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,20 @@ package entitlements
1818

1919
type EntitlementKind string
2020

21-
// The EntitlementKind list should be 1:1 with the Features & FeatureStrings in salescenter/product/product.go,
21+
// The EntitlementKind list should be 1:1 with the Features & FeatureStrings in cloud/cloud/product/product.go,
2222
// except CustomTheme which is dropped. CustomTheme entitlement only toggles the ability to "set" a theme;
2323
// the value of that theme, if set, is stored and accessed outside of entitlements.
2424
//
2525
// All EntitlementKinds added here should also be added to AllEntitlements below and defaultEntitlements in
2626
// web/packages/teleport/src/entitlement.ts.
2727
const (
28+
AccessGraph EntitlementKind = "AccessGraph"
29+
AccessGraphDemoMode EntitlementKind = "AccessGraphDemoMode"
2830
AccessLists EntitlementKind = "AccessLists"
2931
AccessMonitoring EntitlementKind = "AccessMonitoring"
3032
AccessRequests EntitlementKind = "AccessRequests"
3133
App EntitlementKind = "App"
34+
ClientIPRestrictions EntitlementKind = "ClientIPRestrictions"
3235
CloudAuditLogRetention EntitlementKind = "CloudAuditLogRetention"
3336
DB EntitlementKind = "DB"
3437
Desktop EntitlementKind = "Desktop"
@@ -39,6 +42,7 @@ const (
3942
Identity EntitlementKind = "Identity"
4043
JoinActiveSessions EntitlementKind = "JoinActiveSessions"
4144
K8s EntitlementKind = "K8s"
45+
LicenseAutoUpdate EntitlementKind = "LicenseAutoUpdate"
4246
MobileDeviceManagement EntitlementKind = "MobileDeviceManagement"
4347
OIDC EntitlementKind = "OIDC"
4448
OktaSCIM EntitlementKind = "OktaSCIM"
@@ -49,16 +53,14 @@ const (
4953
UnrestrictedManagedUpdates EntitlementKind = "UnrestrictedManagedUpdates"
5054
UpsellAlert EntitlementKind = "UpsellAlert"
5155
UsageReporting EntitlementKind = "UsageReporting"
52-
LicenseAutoUpdate EntitlementKind = "LicenseAutoUpdate"
53-
AccessGraphDemoMode EntitlementKind = "AccessGraphDemoMode"
54-
ClientIPRestrictions EntitlementKind = "ClientIPRestrictions"
5556
WorkloadClusters EntitlementKind = "WorkloadClusters"
5657
)
5758

5859
// AllEntitlements returns all Entitlements; should be 1:1 with the const declared above.
5960
var AllEntitlements = []EntitlementKind{
60-
AccessLists, AccessMonitoring, AccessRequests, App, CloudAuditLogRetention, DB, Desktop, DeviceTrust,
61-
ExternalAuditStorage, FeatureHiding, HSM, Identity, JoinActiveSessions, K8s, MobileDeviceManagement, OIDC, OktaSCIM,
62-
OktaUserSync, Policy, SAML, SessionLocks, UnrestrictedManagedUpdates, UpsellAlert, UsageReporting, LicenseAutoUpdate, AccessGraphDemoMode,
63-
ClientIPRestrictions, WorkloadClusters,
61+
AccessGraph, AccessGraphDemoMode, AccessLists, AccessMonitoring, AccessRequests, App,
62+
ClientIPRestrictions, CloudAuditLogRetention, DB, Desktop, DeviceTrust,
63+
ExternalAuditStorage, FeatureHiding, HSM, Identity, JoinActiveSessions, K8s, LicenseAutoUpdate,
64+
MobileDeviceManagement, OIDC, OktaSCIM, OktaUserSync, Policy, SAML, SessionLocks,
65+
UnrestrictedManagedUpdates, UpsellAlert, UsageReporting, WorkloadClusters,
6466
}

lib/modules/modules_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,14 @@ func TestFeatures_ToProto(t *testing.T) {
138138
RecoveryCodes: true,
139139
AccessMonitoringConfigured: false,
140140
Entitlements: map[string]*proto.EntitlementInfo{
141+
string(entitlements.AccessGraph): {Enabled: true},
142+
string(entitlements.AccessGraphDemoMode): {Enabled: true},
141143
string(entitlements.AccessLists): {Enabled: true, Limit: 111},
142144
string(entitlements.AccessMonitoring): {Enabled: true, Limit: 2113},
143145
string(entitlements.AccessRequests): {Enabled: true, Limit: 39},
144146
string(entitlements.App): {Enabled: false},
145147
string(entitlements.CloudAuditLogRetention): {Enabled: true},
148+
string(entitlements.ClientIPRestrictions): {Enabled: true},
146149
string(entitlements.DB): {Enabled: true},
147150
string(entitlements.Desktop): {Enabled: true},
148151
string(entitlements.DeviceTrust): {Enabled: true, Limit: 103},
@@ -152,6 +155,7 @@ func TestFeatures_ToProto(t *testing.T) {
152155
string(entitlements.Identity): {Enabled: true},
153156
string(entitlements.JoinActiveSessions): {Enabled: true},
154157
string(entitlements.K8s): {Enabled: true},
158+
string(entitlements.LicenseAutoUpdate): {Enabled: true},
155159
string(entitlements.MobileDeviceManagement): {Enabled: true},
156160
string(entitlements.OIDC): {Enabled: true},
157161
string(entitlements.OktaSCIM): {Enabled: true},
@@ -161,10 +165,7 @@ func TestFeatures_ToProto(t *testing.T) {
161165
string(entitlements.SessionLocks): {Enabled: true},
162166
string(entitlements.UpsellAlert): {Enabled: true},
163167
string(entitlements.UsageReporting): {Enabled: true},
164-
string(entitlements.LicenseAutoUpdate): {Enabled: true},
165-
string(entitlements.AccessGraphDemoMode): {Enabled: true},
166168
string(entitlements.UnrestrictedManagedUpdates): {Enabled: true},
167-
string(entitlements.ClientIPRestrictions): {Enabled: true},
168169
string(entitlements.WorkloadClusters): {Enabled: true},
169170
},
170171
// Deprecated fields
@@ -194,10 +195,13 @@ func TestFeatures_ToProto(t *testing.T) {
194195
AccessMonitoringConfigured: false,
195196
CloudAnonymizationKey: []byte("001"),
196197
Entitlements: map[entitlements.EntitlementKind]modules.EntitlementInfo{
198+
entitlements.AccessGraph: {Enabled: true, Limit: 0},
199+
entitlements.AccessGraphDemoMode: {Enabled: true, Limit: 0},
197200
entitlements.AccessLists: {Enabled: true, Limit: 111},
198201
entitlements.AccessMonitoring: {Enabled: true, Limit: 2113},
199202
entitlements.AccessRequests: {Enabled: true, Limit: 39},
200203
entitlements.App: {Enabled: false, Limit: 0},
204+
entitlements.ClientIPRestrictions: {Enabled: true, Limit: 0},
201205
entitlements.CloudAuditLogRetention: {Enabled: true, Limit: 0},
202206
entitlements.DB: {Enabled: true, Limit: 0},
203207
entitlements.Desktop: {Enabled: true, Limit: 0},
@@ -208,6 +212,7 @@ func TestFeatures_ToProto(t *testing.T) {
208212
entitlements.Identity: {Enabled: true, Limit: 0},
209213
entitlements.JoinActiveSessions: {Enabled: true, Limit: 0},
210214
entitlements.K8s: {Enabled: true, Limit: 0},
215+
entitlements.LicenseAutoUpdate: {Enabled: true, Limit: 0},
211216
entitlements.MobileDeviceManagement: {Enabled: true, Limit: 0},
212217
entitlements.OIDC: {Enabled: true, Limit: 0},
213218
entitlements.OktaSCIM: {Enabled: true, Limit: 0},
@@ -217,10 +222,7 @@ func TestFeatures_ToProto(t *testing.T) {
217222
entitlements.SessionLocks: {Enabled: true, Limit: 0},
218223
entitlements.UpsellAlert: {Enabled: true, Limit: 0},
219224
entitlements.UsageReporting: {Enabled: true, Limit: 0},
220-
entitlements.LicenseAutoUpdate: {Enabled: true, Limit: 0},
221-
entitlements.AccessGraphDemoMode: {Enabled: true, Limit: 0},
222225
entitlements.UnrestrictedManagedUpdates: {Enabled: true, Limit: 0},
223-
entitlements.ClientIPRestrictions: {Enabled: true, Limit: 0},
224226
entitlements.WorkloadClusters: {Enabled: true, Limit: 0},
225227
},
226228
}

lib/web/apiserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2061,7 +2061,7 @@ func (h *Handler) getWebConfig(w http.ResponseWriter, r *http.Request, p httprou
20612061
// if Entitlements are present, GetWebCfgEntitlements will populate the fields appropriately
20622062
Entitlements: GetWebCfgEntitlements(clusterFeatures.GetEntitlements()),
20632063
IdentitySecurity: webclient.IdentitySecurity{
2064-
IsClusterLicensed: modules.GetProtoEntitlement(&clusterFeatures, entitlements.Policy).Enabled,
2064+
IsClusterLicensed: modules.GetProtoEntitlement(&clusterFeatures, entitlements.AccessGraph).Enabled || modules.GetProtoEntitlement(&clusterFeatures, entitlements.Policy).Enabled,
20652065
AccessGraphConfigSet: rsp.GetEnabled() && rsp.GetAddress() != "",
20662066
SessionSummarizationEnabled: sessionSummarizerEnabled,
20672067
},

lib/web/apiserver_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4915,10 +4915,13 @@ func TestGetWebConfig_WithEntitlements(t *testing.T) {
49154915
AutomaticUpgrades: false,
49164916
Edition: testModules.BuildType(),
49174917
Entitlements: map[string]webclient.EntitlementInfo{
4918+
string(entitlements.AccessGraph): {Enabled: false},
4919+
string(entitlements.AccessGraphDemoMode): {Enabled: false},
49184920
string(entitlements.AccessLists): {Enabled: false},
49194921
string(entitlements.AccessMonitoring): {Enabled: false},
49204922
string(entitlements.AccessRequests): {Enabled: false},
49214923
string(entitlements.App): {Enabled: true},
4924+
string(entitlements.ClientIPRestrictions): {Enabled: false},
49224925
string(entitlements.CloudAuditLogRetention): {Enabled: false},
49234926
string(entitlements.DB): {Enabled: true},
49244927
string(entitlements.Desktop): {Enabled: true},
@@ -4929,6 +4932,7 @@ func TestGetWebConfig_WithEntitlements(t *testing.T) {
49294932
string(entitlements.Identity): {Enabled: false},
49304933
string(entitlements.JoinActiveSessions): {Enabled: true},
49314934
string(entitlements.K8s): {Enabled: true},
4935+
string(entitlements.LicenseAutoUpdate): {Enabled: false},
49324936
string(entitlements.MobileDeviceManagement): {Enabled: false},
49334937
string(entitlements.OIDC): {Enabled: false},
49344938
string(entitlements.OktaSCIM): {Enabled: false},
@@ -4938,10 +4942,7 @@ func TestGetWebConfig_WithEntitlements(t *testing.T) {
49384942
string(entitlements.SessionLocks): {Enabled: false},
49394943
string(entitlements.UpsellAlert): {Enabled: false},
49404944
string(entitlements.UsageReporting): {Enabled: false},
4941-
string(entitlements.LicenseAutoUpdate): {Enabled: false},
4942-
string(entitlements.AccessGraphDemoMode): {Enabled: false},
49434945
string(entitlements.UnrestrictedManagedUpdates): {Enabled: false},
4944-
string(entitlements.ClientIPRestrictions): {Enabled: false},
49454946
string(entitlements.WorkloadClusters): {Enabled: false},
49464947
},
49474948
TunnelPublicAddress: "",

web/packages/teleport/src/entitlement.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818

1919
// entitlement list should be 1:1 with EntitlementKinds in entitlements/entitlements.go
2020
type entitlement =
21+
| 'AccessGraph'
22+
| 'AccessGraphDemoMode'
2123
| 'AccessLists'
2224
| 'AccessMonitoring'
2325
| 'AccessRequests'
24-
| 'AccessGraphDemoMode'
2526
| 'App'
27+
| 'ClientIPRestrictions'
2628
| 'CloudAuditLogRetention'
2729
| 'DB'
2830
| 'Desktop'
@@ -42,18 +44,19 @@ type entitlement =
4244
| 'SessionLocks'
4345
| 'UnrestrictedManagedUpdates'
4446
| 'UpsellAlert'
45-
| 'UsageReporting'
46-
| 'ClientIPRestrictions';
47+
| 'UsageReporting';
4748

4849
export const defaultEntitlements: Record<
4950
entitlement,
5051
{ enabled: boolean; limit: number }
5152
> = {
53+
AccessGraph: { enabled: false, limit: 0 },
54+
AccessGraphDemoMode: { enabled: false, limit: 0 },
5255
AccessLists: { enabled: false, limit: 0 },
5356
AccessMonitoring: { enabled: false, limit: 0 },
54-
AccessGraphDemoMode: { enabled: false, limit: 0 },
5557
AccessRequests: { enabled: false, limit: 0 },
5658
App: { enabled: false, limit: 0 },
59+
ClientIPRestrictions: { enabled: false, limit: 0 },
5760
CloudAuditLogRetention: { enabled: false, limit: 0 },
5861
DB: { enabled: false, limit: 0 },
5962
Desktop: { enabled: false, limit: 0 },
@@ -74,5 +77,4 @@ export const defaultEntitlements: Record<
7477
UnrestrictedManagedUpdates: { enabled: false, limit: 0 },
7578
UpsellAlert: { enabled: false, limit: 0 },
7679
UsageReporting: { enabled: false, limit: 0 },
77-
ClientIPRestrictions: { enabled: false, limit: 0 },
7880
};

0 commit comments

Comments
 (0)