cody: replace access-control feature flag with RBAC#58831
Conversation
| } | ||
|
|
||
| func (r *siteResolver) IsCodyEnabled(ctx context.Context) bool { return cody.IsCodyEnabled(ctx) } | ||
| func (r *siteResolver) IsCodyEnabled(ctx context.Context) bool { return cody.IsCodyEnabled(ctx, r.db) } |
There was a problem hiding this comment.
Looks like it's always been this way but feels strange to me that the site resolver is returning if Cody is enabled for the current user, not is Cody enabled for the site.
There was a problem hiding this comment.
Yeah, it is very (functional, but) strange. It's also weird that we have Cody access control enforced in the feature-flag portion of internal/cody.
I haven't set out to 'correct' this in this PR with the hopes of keeping it from increasing in scope/risk
chwarwick
left a comment
There was a problem hiding this comment.
If i'm following correctly the RBAC permissions are only used if the config value is set to enable permissions, which means the default case is that all users have access (same as today 👍 )
But what happens in the RBAC UI? Does it look like you are configuring Cody access for groups/all users but because it's not enabled in the config it isn't considered?
That is correct; however if the RBAC permissions are not being respected then the warning would display at the top of the page indicating you're using the old permission system: The one edge-case here would be if a site admin explicitly disables the new RBAC permissions model ( |
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Co-authored-by: Chris Warwick <christopher.warwick@sourcegraph.com>
…sabled Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
|
@chwarwick or @eseliger would either of you be up for a quick review? I'd love to land this soon as it's blocking some other work :) |
chwarwick
left a comment
There was a problem hiding this comment.
Nice, this looks correct to me. See note about new docs process.
| ## Enable Cody only for some users | ||
|
|
||
| To enable Cody only for some users, for example, when rolling out a Cody POC, follow all the steps mentioned in [Enabling Cody on your Sourcegraph instance](#enable-cody-on-your-sourcegraph-instance). Then, use the feature flag `cody` to turn Cody on selectively for some users. To do so: | ||
| To enable Cody only for some users, for example, when rolling out a Cody POC, follow all the steps mentioned in [Enabling Cody on your Sourcegraph instance](#enable-cody-on-your-sourcegraph-instance). Then, do the following: |
There was a problem hiding this comment.
Docs changes need to go into the new docs repo. I think having them here will fail the build?
| } | ||
| }) | ||
|
|
||
| t.Run("RBAC, Enabled cody, but not completions", func(t *testing.T) { |
There was a problem hiding this comment.
What does but not completions mean? This test looks the same as the one above.
There was a problem hiding this comment.
Good catch, I mirror'd the existing good test suite but for the case of RBAC - and this ended up being redundant. Removed.
eseliger
left a comment
There was a problem hiding this comment.
LGTM, might warrant a changelog entry to make people aware prior to the upgrade that they need to migrate their access settings :)
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
* Revert "Revert "cody: replace access-control feature flag with RBAC (#58831)" (#59540)" This reverts commit 13923a7. * context/resolvers: fix test by correctly mocking user role with Cody access Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com> --------- Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
This change replaces the old feature-flag which controls users who have access to Cody, with an RBAC-based implementation instead.
After this change,
cody.restrictUsersFeatureFlagis deprecated. For Sourcegraph instances that still have it set, it will still be respected it until the site admin removes it from their config. A warning is displayed to let admins know this needs to be done:Once
cody.restrictUsersFeatureFlagis not set in the site config, the new RBAC system is used instead: site admins can manage user roles, and assign/removecody:accessto users or groups of users via the access control web UI.By default, all users have access (admins can change this default via the access control web UI.)
The new Cody RBAC system defaults to enabled unless
cody.restrictUsersFeatureFlagis set in the site config. It can be disabled by setting the newcody.permissionssite config option tofalse, in which case Sourcegraph behaves as it did before this change.Fixes #58623
Helps (
fixes?) #58624Resolves #58627
Remaining TODOs before this PR can be merged
Test plan