Skip to content

Commit

Permalink
Change DELETE action from "*" to "delete"
Browse files Browse the repository at this point in the history
With token authentication, requiring the "*" action for DELETE requests
makes it impossible to administratively lock a repository against pushes
and pulls but still allow deletion.  This change adds a new "delete"
action for DELETE requests to make that possible.

Signed-off-by: Noah Treuhaft <[email protected]>
  • Loading branch information
nwt committed Jan 3, 2017
1 parent 8e065ad commit ccb839e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions registry/handlers/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,12 +901,10 @@ func appendAccessRecords(records []auth.Access, method string, repo string) []au
Action: "push",
})
case "DELETE":
// DELETE access requires full admin rights, which is represented
// as "*". This may not be ideal.
records = append(records,
auth.Access{
Resource: resource,
Action: "*",
Action: "delete",
})
}
return records
Expand Down
6 changes: 3 additions & 3 deletions registry/handlers/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ func TestAppendAccessRecords(t *testing.T) {
Resource: expectedResource,
Action: "push",
}
expectedAllRecord := auth.Access{
expectedDeleteRecord := auth.Access{
Resource: expectedResource,
Action: "*",
Action: "delete",
}

records := []auth.Access{}
Expand Down Expand Up @@ -271,7 +271,7 @@ func TestAppendAccessRecords(t *testing.T) {

records = []auth.Access{}
result = appendAccessRecords(records, "DELETE", repo)
expectedResult = []auth.Access{expectedAllRecord}
expectedResult = []auth.Access{expectedDeleteRecord}
if ok := reflect.DeepEqual(result, expectedResult); !ok {
t.Fatalf("Actual access record differs from expected")
}
Expand Down

0 comments on commit ccb839e

Please sign in to comment.