Skip to content

Commit

Permalink
Use repo edit and repo view permissions for space label handling (har…
Browse files Browse the repository at this point in the history
…ness#2569)

* Use repo edit and repo view permissions for space label handling
  • Loading branch information
darkodraskovic authored and Harness committed Aug 23, 2024
1 parent b837793 commit af6e94b
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/api/controller/space/label_define.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (c *Controller) DefineLabel(
spaceRef string,
in *types.DefineLabelInput,
) (*types.Label, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit)
if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion app/api/controller/space/label_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (c *Controller) DeleteLabel(
spaceRef string,
key string,
) error {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit)
if err != nil {
return fmt.Errorf("failed to acquire access to space: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion app/api/controller/space/label_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (c *Controller) ListLabels(
spaceRef string,
filter *types.LabelFilter,
) ([]*types.Label, int64, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceView)
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoView)
if err != nil {
return nil, 0, fmt.Errorf("failed to acquire access to space: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion app/api/controller/space/label_save.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (c *Controller) SaveLabel(
spaceRef string,
in *types.SaveInput,
) (*types.LabelWithValues, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit)
if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion app/api/controller/space/label_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (c *Controller) UpdateLabel(
key string,
in *types.UpdateLabelInput,
) (*types.Label, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit)
if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion app/api/controller/space/label_value_define.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (c *Controller) DefineLabelValue(
in *types.DefineValueInput,
) (*types.LabelValue, error) {
// TODO: permission check should be based on static vs dynamic label
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit)
if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion app/api/controller/space/label_value_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (c *Controller) DeleteLabelValue(
key string,
value string,
) error {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit)
if err != nil {
return fmt.Errorf("failed to acquire access to space: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion app/api/controller/space/label_value_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (c *Controller) ListLabelValues(
key string,
filter *types.ListQueryFilter,
) ([]*types.LabelValue, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceView)
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoView)
if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion app/api/controller/space/label_value_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (c *Controller) UpdateLabelValue(
value string,
in *types.UpdateValueInput,
) (*types.LabelValue, error) {
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit)
space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionRepoEdit)
if err != nil {
return nil, fmt.Errorf("failed to acquire access to space: %w", err)
}
Expand Down

0 comments on commit af6e94b

Please sign in to comment.