Skip to content

Commit 5e3b6f8

Browse files
committed
Add new entitlement to control this feature
1 parent f092c50 commit 5e3b6f8

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

codersdk/deployment.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const (
4040
FeatureBrowserOnly FeatureName = "browser_only"
4141
FeatureSCIM FeatureName = "scim"
4242
FeatureTemplateRBAC FeatureName = "template_rbac"
43+
FeatureUserRoleManagement FeatureName = "user_role_management"
4344
FeatureHighAvailability FeatureName = "high_availability"
4445
FeatureMultipleGitAuth FeatureName = "multiple_git_auth"
4546
FeatureExternalProvisionerDaemons FeatureName = "external_provisioner_daemons"
@@ -61,6 +62,7 @@ var FeatureNames = []FeatureName{
6162
FeatureAppearance,
6263
FeatureAdvancedTemplateScheduling,
6364
FeatureWorkspaceProxy,
65+
FeatureUserRoleManagement,
6466
}
6567

6668
// Humanize returns the feature name in a human-readable format.

enterprise/coderd/userauth.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/google/uuid"
77
"golang.org/x/xerrors"
88

9+
"cdr.dev/slog"
910
"github.com/coder/coder/coderd"
1011
"github.com/coder/coder/coderd/database"
1112
"github.com/coder/coder/codersdk"
@@ -53,6 +54,17 @@ func (api *API) setUserGroups(ctx context.Context, db database.Store, userID uui
5354
}
5455

5556
func (api *API) setUserSiteRoles(ctx context.Context, db database.Store, userID uuid.UUID, roles []string) error {
57+
api.entitlementsMu.RLock()
58+
enabled := api.entitlements.Features[codersdk.FeatureUserRoleManagement].Enabled
59+
api.entitlementsMu.RUnlock()
60+
61+
if !enabled {
62+
api.Logger.Warn(ctx, "attempted to assign OIDC user roles without enterprise entitlement, roles left unchanged.",
63+
slog.F("user_id", userID), slog.F("roles", roles),
64+
)
65+
return nil
66+
}
67+
5668
// Should this be feature protected?
5769
return db.InTx(func(tx database.Store) error {
5870
_, err := coderd.UpdateSiteUserRoles(ctx, db, database.UpdateUserRolesParams{

0 commit comments

Comments
 (0)