Skip to content

Commit abf14d9

Browse files
chore: rename feature rbac to template_rbac (#4486)
* chore: rename feature rbac to template_rbac * Fix feature visibility on FE * fixup! Fix feature visibility on FE Co-authored-by: Bruno Quaresma <bruno@coder.com>
1 parent 0f3221f commit abf14d9

21 files changed

+114
-113
lines changed

codersdk/features.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const (
2020
FeatureBrowserOnly = "browser_only"
2121
FeatureSCIM = "scim"
2222
FeatureWorkspaceQuota = "workspace_quota"
23-
FeatureRBAC = "rbac"
23+
FeatureTemplateRBAC = "template_rbac"
2424
)
2525

2626
var FeatureNames = []string{
@@ -29,7 +29,7 @@ var FeatureNames = []string{
2929
FeatureBrowserOnly,
3030
FeatureSCIM,
3131
FeatureWorkspaceQuota,
32-
FeatureRBAC,
32+
FeatureTemplateRBAC,
3333
}
3434

3535
type Feature struct {

enterprise/cli/features_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestFeaturesList(t *testing.T) {
6868
assert.Equal(t, codersdk.EntitlementNotEntitled,
6969
entitlements.Features[codersdk.FeatureWorkspaceQuota].Entitlement)
7070
assert.Equal(t, codersdk.EntitlementNotEntitled,
71-
entitlements.Features[codersdk.FeatureRBAC].Entitlement)
71+
entitlements.Features[codersdk.FeatureTemplateRBAC].Entitlement)
7272
assert.Equal(t, codersdk.EntitlementNotEntitled,
7373
entitlements.Features[codersdk.FeatureSCIM].Entitlement)
7474
assert.False(t, entitlements.HasLicense)

enterprise/coderd/authorize_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestCheckACLPermissions(t *testing.T) {
2828
// Create adminClient, member, and org adminClient
2929
adminUser := coderdtest.CreateFirstUser(t, adminClient)
3030
_ = coderdenttest.AddLicense(t, adminClient, coderdenttest.LicenseOptions{
31-
RBACEnabled: true,
31+
TemplateRBACEnabled: true,
3232
})
3333

3434
memberClient := coderdtest.CreateAnotherUser(t, adminClient, adminUser.OrganizationID)

enterprise/coderd/coderd.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func New(ctx context.Context, options *Options) (*API, error) {
7070

7171
r.Route("/templates/{template}/acl", func(r chi.Router) {
7272
r.Use(
73-
api.rbacEnabledMW,
73+
api.templateRBACEnabledMW,
7474
apiKeyMiddleware,
7575
httpmw.ExtractTemplateParam(api.Database),
7676
)
@@ -80,7 +80,7 @@ func New(ctx context.Context, options *Options) (*API, error) {
8080

8181
r.Route("/groups/{group}", func(r chi.Router) {
8282
r.Use(
83-
api.rbacEnabledMW,
83+
api.templateRBACEnabledMW,
8484
apiKeyMiddleware,
8585
httpmw.ExtractGroupParam(api.Database),
8686
)
@@ -157,7 +157,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
157157
codersdk.FeatureBrowserOnly: api.BrowserOnly,
158158
codersdk.FeatureSCIM: len(api.SCIMAPIKey) != 0,
159159
codersdk.FeatureWorkspaceQuota: api.UserWorkspaceQuota != 0,
160-
codersdk.FeatureRBAC: api.RBACEnabled,
160+
codersdk.FeatureTemplateRBAC: api.RBACEnabled,
161161
})
162162
if err != nil {
163163
return err

enterprise/coderd/coderd_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ func TestEntitlements(t *testing.T) {
4141
})
4242
_ = coderdtest.CreateFirstUser(t, client)
4343
coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
44-
UserLimit: 100,
45-
AuditLog: true,
46-
RBACEnabled: true,
44+
UserLimit: 100,
45+
AuditLog: true,
46+
TemplateRBACEnabled: true,
4747
})
4848
res, err := client.Entitlements(context.Background())
4949
require.NoError(t, err)

enterprise/coderd/coderdenttest/coderdenttest.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,18 @@ func NewWithAPI(t *testing.T, options *Options) (*codersdk.Client, io.Closer, *c
8787
}
8888

8989
type LicenseOptions struct {
90-
AccountType string
91-
AccountID string
92-
Trial bool
93-
AllFeatures bool
94-
GraceAt time.Time
95-
ExpiresAt time.Time
96-
UserLimit int64
97-
AuditLog bool
98-
BrowserOnly bool
99-
SCIM bool
100-
WorkspaceQuota bool
101-
RBACEnabled bool
90+
AccountType string
91+
AccountID string
92+
Trial bool
93+
AllFeatures bool
94+
GraceAt time.Time
95+
ExpiresAt time.Time
96+
UserLimit int64
97+
AuditLog bool
98+
BrowserOnly bool
99+
SCIM bool
100+
WorkspaceQuota bool
101+
TemplateRBACEnabled bool
102102
}
103103

104104
// AddLicense generates a new license with the options provided and inserts it.
@@ -135,9 +135,9 @@ func GenerateLicense(t *testing.T, options LicenseOptions) string {
135135
workspaceQuota = 1
136136
}
137137

138-
rbac := int64(0)
139-
if options.RBACEnabled {
140-
rbac = 1
138+
rbacEnabled := int64(0)
139+
if options.TemplateRBACEnabled {
140+
rbacEnabled = 1
141141
}
142142

143143
c := &license.Claims{
@@ -159,7 +159,7 @@ func GenerateLicense(t *testing.T, options LicenseOptions) string {
159159
BrowserOnly: browserOnly,
160160
SCIM: scim,
161161
WorkspaceQuota: workspaceQuota,
162-
RBAC: rbac,
162+
TemplateRBAC: rbacEnabled,
163163
},
164164
}
165165
tok := jwt.NewWithClaims(jwt.SigningMethodEdDSA, c)

enterprise/coderd/coderdenttest/coderdenttest_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
3333
ctx, _ := testutil.Context(t)
3434
admin := coderdtest.CreateFirstUser(t, client)
3535
license := coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
36-
RBACEnabled: true,
36+
TemplateRBACEnabled: true,
3737
})
3838
group, err := client.CreateGroup(ctx, admin.OrganizationID, codersdk.CreateGroupRequest{
3939
Name: "testgroup",

enterprise/coderd/groups_test.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestCreateGroup(t *testing.T) {
2424
user := coderdtest.CreateFirstUser(t, client)
2525

2626
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
27-
RBACEnabled: true,
27+
TemplateRBACEnabled: true,
2828
})
2929
ctx, _ := testutil.Context(t)
3030
group, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
@@ -43,7 +43,7 @@ func TestCreateGroup(t *testing.T) {
4343
user := coderdtest.CreateFirstUser(t, client)
4444

4545
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
46-
RBACEnabled: true,
46+
TemplateRBACEnabled: true,
4747
})
4848
ctx, _ := testutil.Context(t)
4949
_, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
@@ -67,7 +67,7 @@ func TestCreateGroup(t *testing.T) {
6767
user := coderdtest.CreateFirstUser(t, client)
6868

6969
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
70-
RBACEnabled: true,
70+
TemplateRBACEnabled: true,
7171
})
7272
ctx, _ := testutil.Context(t)
7373
_, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
@@ -90,7 +90,7 @@ func TestPatchGroup(t *testing.T) {
9090
user := coderdtest.CreateFirstUser(t, client)
9191

9292
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
93-
RBACEnabled: true,
93+
TemplateRBACEnabled: true,
9494
})
9595
ctx, _ := testutil.Context(t)
9696
group, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
@@ -112,7 +112,7 @@ func TestPatchGroup(t *testing.T) {
112112
user := coderdtest.CreateFirstUser(t, client)
113113

114114
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
115-
RBACEnabled: true,
115+
TemplateRBACEnabled: true,
116116
})
117117
_, user2 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
118118
_, user3 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
@@ -138,7 +138,7 @@ func TestPatchGroup(t *testing.T) {
138138
user := coderdtest.CreateFirstUser(t, client)
139139

140140
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
141-
RBACEnabled: true,
141+
TemplateRBACEnabled: true,
142142
})
143143
_, user2 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
144144
_, user3 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
@@ -173,7 +173,7 @@ func TestPatchGroup(t *testing.T) {
173173
user := coderdtest.CreateFirstUser(t, client)
174174

175175
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
176-
RBACEnabled: true,
176+
TemplateRBACEnabled: true,
177177
})
178178
ctx, _ := testutil.Context(t)
179179
group, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
@@ -197,7 +197,7 @@ func TestPatchGroup(t *testing.T) {
197197
user := coderdtest.CreateFirstUser(t, client)
198198

199199
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
200-
RBACEnabled: true,
200+
TemplateRBACEnabled: true,
201201
})
202202
ctx, _ := testutil.Context(t)
203203
group, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
@@ -221,7 +221,7 @@ func TestPatchGroup(t *testing.T) {
221221
user := coderdtest.CreateFirstUser(t, client)
222222

223223
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
224-
RBACEnabled: true,
224+
TemplateRBACEnabled: true,
225225
})
226226
_, user2 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
227227
ctx, _ := testutil.Context(t)
@@ -247,7 +247,7 @@ func TestPatchGroup(t *testing.T) {
247247
user := coderdtest.CreateFirstUser(t, client)
248248

249249
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
250-
RBACEnabled: true,
250+
TemplateRBACEnabled: true,
251251
})
252252
ctx, _ := testutil.Context(t)
253253
group, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
@@ -276,7 +276,7 @@ func TestGroup(t *testing.T) {
276276
user := coderdtest.CreateFirstUser(t, client)
277277

278278
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
279-
RBACEnabled: true,
279+
TemplateRBACEnabled: true,
280280
})
281281
ctx, _ := testutil.Context(t)
282282
group, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
@@ -296,7 +296,7 @@ func TestGroup(t *testing.T) {
296296
user := coderdtest.CreateFirstUser(t, client)
297297

298298
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
299-
RBACEnabled: true,
299+
TemplateRBACEnabled: true,
300300
})
301301
_, user2 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
302302
_, user3 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
@@ -326,7 +326,7 @@ func TestGroup(t *testing.T) {
326326
user := coderdtest.CreateFirstUser(t, client)
327327

328328
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
329-
RBACEnabled: true,
329+
TemplateRBACEnabled: true,
330330
})
331331
client1, _ := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
332332

@@ -347,7 +347,7 @@ func TestGroup(t *testing.T) {
347347
client := coderdenttest.New(t, nil)
348348
user := coderdtest.CreateFirstUser(t, client)
349349
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
350-
RBACEnabled: true,
350+
TemplateRBACEnabled: true,
351351
})
352352

353353
_, user1 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
@@ -380,7 +380,7 @@ func TestGroup(t *testing.T) {
380380
client := coderdenttest.New(t, nil)
381381
user := coderdtest.CreateFirstUser(t, client)
382382
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
383-
RBACEnabled: true,
383+
TemplateRBACEnabled: true,
384384
})
385385

386386
_, user1 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
@@ -421,7 +421,7 @@ func TestGroups(t *testing.T) {
421421
client := coderdenttest.New(t, nil)
422422
user := coderdtest.CreateFirstUser(t, client)
423423
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
424-
RBACEnabled: true,
424+
TemplateRBACEnabled: true,
425425
})
426426
_, user2 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
427427
_, user3 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
@@ -467,7 +467,7 @@ func TestDeleteGroup(t *testing.T) {
467467
user := coderdtest.CreateFirstUser(t, client)
468468

469469
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
470-
RBACEnabled: true,
470+
TemplateRBACEnabled: true,
471471
})
472472
ctx, _ := testutil.Context(t)
473473
group1, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
@@ -492,7 +492,7 @@ func TestDeleteGroup(t *testing.T) {
492492
user := coderdtest.CreateFirstUser(t, client)
493493

494494
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
495-
RBACEnabled: true,
495+
TemplateRBACEnabled: true,
496496
})
497497
ctx, _ := testutil.Context(t)
498498
err := client.DeleteGroup(ctx, user.OrganizationID)

enterprise/coderd/license/license.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ func Entitlements(ctx context.Context, db database.Store, logger slog.Logger, ke
9696
Enabled: enablements[codersdk.FeatureWorkspaceQuota],
9797
}
9898
}
99-
if claims.Features.RBAC > 0 {
100-
entitlements.Features[codersdk.FeatureRBAC] = codersdk.Feature{
99+
if claims.Features.TemplateRBAC > 0 {
100+
entitlements.Features[codersdk.FeatureTemplateRBAC] = codersdk.Feature{
101101
Entitlement: entitlement,
102-
Enabled: enablements[codersdk.FeatureRBAC],
102+
Enabled: enablements[codersdk.FeatureTemplateRBAC],
103103
}
104104
}
105105
if claims.AllFeatures {
@@ -176,7 +176,7 @@ type Features struct {
176176
BrowserOnly int64 `json:"browser_only"`
177177
SCIM int64 `json:"scim"`
178178
WorkspaceQuota int64 `json:"workspace_quota"`
179-
RBAC int64 `json:"rbac"`
179+
TemplateRBAC int64 `json:"template_rbac"`
180180
}
181181

182182
type Claims struct {

enterprise/coderd/license/license_test.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestEntitlements(t *testing.T) {
2424
codersdk.FeatureBrowserOnly: true,
2525
codersdk.FeatureSCIM: true,
2626
codersdk.FeatureWorkspaceQuota: true,
27-
codersdk.FeatureRBAC: true,
27+
codersdk.FeatureTemplateRBAC: true,
2828
}
2929

3030
t.Run("Defaults", func(t *testing.T) {
@@ -60,12 +60,12 @@ func TestEntitlements(t *testing.T) {
6060
db := databasefake.New()
6161
db.InsertLicense(context.Background(), database.InsertLicenseParams{
6262
JWT: coderdenttest.GenerateLicense(t, coderdenttest.LicenseOptions{
63-
UserLimit: 100,
64-
AuditLog: true,
65-
BrowserOnly: true,
66-
SCIM: true,
67-
WorkspaceQuota: true,
68-
RBACEnabled: true,
63+
UserLimit: 100,
64+
AuditLog: true,
65+
BrowserOnly: true,
66+
SCIM: true,
67+
WorkspaceQuota: true,
68+
TemplateRBACEnabled: true,
6969
}),
7070
Exp: time.Now().Add(time.Hour),
7171
})
@@ -82,14 +82,14 @@ func TestEntitlements(t *testing.T) {
8282
db := databasefake.New()
8383
db.InsertLicense(context.Background(), database.InsertLicenseParams{
8484
JWT: coderdenttest.GenerateLicense(t, coderdenttest.LicenseOptions{
85-
UserLimit: 100,
86-
AuditLog: true,
87-
BrowserOnly: true,
88-
SCIM: true,
89-
WorkspaceQuota: true,
90-
RBACEnabled: true,
91-
GraceAt: time.Now().Add(-time.Hour),
92-
ExpiresAt: time.Now().Add(time.Hour),
85+
UserLimit: 100,
86+
AuditLog: true,
87+
BrowserOnly: true,
88+
SCIM: true,
89+
WorkspaceQuota: true,
90+
TemplateRBACEnabled: true,
91+
GraceAt: time.Now().Add(-time.Hour),
92+
ExpiresAt: time.Now().Add(time.Hour),
9393
}),
9494
Exp: time.Now().Add(time.Hour),
9595
})

0 commit comments

Comments
 (0)