Skip to content

feat!: drop reading other 'user' permission #8650

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 16 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixing unit tests
  • Loading branch information
Emyrk committed Jul 25, 2023
commit 658e2e28c54e6759c165bb7a35aa4a16e4b92e0b
5 changes: 4 additions & 1 deletion enterprise/coderd/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

// @Summary Get template available acl users/groups
// @ID get-template-available-acl-users-groups
// @ID get-template-available-acl-usersgroups
// @Security CoderSessionToken
// @Produce json
// @Tags Enterprise
Expand Down Expand Up @@ -246,6 +246,9 @@ func (api *API) patchTemplateACL(rw http.ResponseWriter, r *http.Request) {

// nolint TODO fix stupid flag.
func validateTemplateACLPerms(ctx context.Context, db database.Store, perms map[string]codersdk.TemplateRole, field string, isUser bool) []codersdk.ValidationError {
// Validate requires full read access to users and groups
// nolint:gocritic
ctx = dbauthz.AsSystemRestricted(ctx)
var validErrs []codersdk.ValidationError
for k, v := range perms {
if err := validateTemplateRole(v); err != nil {
Expand Down
11 changes: 7 additions & 4 deletions enterprise/coderd/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,13 @@ func TestUpdateTemplateACL(t *testing.T) {
acl, err := client2.TemplateACL(ctx, template.ID)
require.NoError(t, err)

require.Contains(t, acl.Users, codersdk.TemplateUser{
User: user3,
Role: codersdk.TemplateRoleUse,
})
found := false
for _, u := range acl.Users {
if u.ID == user3.ID {
found = true
}
}
require.True(t, found, "user not found in acl")
})

t.Run("allUsersGroup", func(t *testing.T) {
Expand Down