Skip to content

chore: remove read all provisioners from users #14801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions coderd/rbac/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,6 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
DisplayName: "Member",
Site: Permissions(map[string][]policy.Action{
ResourceAssignRole.Type: {policy.ActionRead},
// All users can see the provisioner daemons.
ResourceProvisionerDaemon.Type: {policy.ActionRead},
// All users can see OAuth2 provider applications.
ResourceOauth2App.Type: {policy.ActionRead},
ResourceWorkspaceProxy.Type: {policy.ActionRead},
Expand Down Expand Up @@ -414,18 +412,15 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
DisplayName: "",
Site: []Permission{},
Org: map[string][]Permission{
organizationID.String(): {
{
// All org members can read the organization
ResourceType: ResourceOrganization.Type,
Action: policy.ActionRead,
},
{
// Can read available roles.
ResourceType: ResourceAssignOrgRole.Type,
Action: policy.ActionRead,
},
},
organizationID.String(): Permissions(map[string][]policy.Action{
// All users can see the provisioner daemons for workspace
// creation.
ResourceProvisionerDaemon.Type: {policy.ActionRead},
// All org members can read the organization
ResourceOrganization.Type: {policy.ActionRead},
// Can read available roles.
ResourceAssignOrgRole.Type: {policy.ActionRead},
}),
},
User: []Permission{
{
Expand Down
5 changes: 2 additions & 3 deletions coderd/rbac/roles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,8 @@ func TestRolePermissions(t *testing.T) {
Actions: []policy.Action{policy.ActionRead},
Resource: rbac.ResourceProvisionerDaemon.InOrg(orgID),
AuthorizeMap: map[bool][]hasAuthSubjects{
// This should be fixed when multi-org goes live
true: {setOtherOrg, owner, templateAdmin, setOrgNotMe, memberMe, orgMemberMe, userAdmin},
false: {},
true: {owner, templateAdmin, setOrgNotMe, orgMemberMe},
false: {setOtherOrg, memberMe, userAdmin},
},
},
{
Expand Down
7 changes: 6 additions & 1 deletion enterprise/coderd/provisionerdaemons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ func TestGetProvisionerDaemons(t *testing.T) {
t.Parallel()
dv := coderdtest.DeploymentValues(t)
dv.Experiments = []string{string(codersdk.ExperimentMultiOrganization)}
client, _ := coderdenttest.New(t, &coderdenttest.Options{
client, first := coderdenttest.New(t, &coderdenttest.Options{
Options: &coderdtest.Options{
DeploymentValues: dv,
},
Expand All @@ -753,6 +753,7 @@ func TestGetProvisionerDaemons(t *testing.T) {
})
org := coderdenttest.CreateOrganization(t, client, coderdenttest.CreateOrganizationOptions{})
orgAdmin, _ := coderdtest.CreateAnotherUser(t, client, org.ID, rbac.ScopedRoleOrgAdmin(org.ID))
outsideOrg, _ := coderdtest.CreateAnotherUser(t, client, first.OrganizationID)

res, err := orgAdmin.CreateProvisionerKey(context.Background(), org.ID, codersdk.CreateProvisionerKeyRequest{
Name: "my-key",
Expand Down Expand Up @@ -800,5 +801,9 @@ func TestGetProvisionerDaemons(t *testing.T) {
assert.Equal(t, buildinfo.Version(), pkDaemons[0].Daemons[0].Version)
assert.Equal(t, proto.CurrentVersion.String(), pkDaemons[0].Daemons[0].APIVersion)
assert.Equal(t, keys[0].ID, pkDaemons[0].Daemons[0].KeyID)

// Verify user outside the org cannot read the provisioners
_, err = outsideOrg.ListProvisionerKeyDaemons(ctx, org.ID)
require.Error(t, err)
})
}
Loading