Add pull scope to post/put/patch method

Signed-off-by: 陈德 <chende@caicloud.io>
This commit is contained in:
陈德 2018-09-03 10:48:52 +08:00
parent 22c53d9f34
commit 6eb972c383
2 changed files with 4 additions and 5 deletions

View File

@ -164,7 +164,7 @@ func parseScopes(req *http.Request) ([]*token.ResourceActions, error) {
case http.MethodGet, http.MethodHead: case http.MethodGet, http.MethodHead:
scope.Actions = []string{"pull"} scope.Actions = []string{"pull"}
case http.MethodPost, http.MethodPut, http.MethodPatch: case http.MethodPost, http.MethodPut, http.MethodPatch:
scope.Actions = []string{"push"} scope.Actions = []string{"pull", "push"}
case http.MethodDelete: case http.MethodDelete:
scope.Actions = []string{"*"} scope.Actions = []string{"*"}
default: default:

View File

@ -116,10 +116,9 @@ func TestParseScopes(t *testing.T) {
assert.Nil(t, err) assert.Nil(t, err)
assert.Equal(t, 1, len(scopses)) assert.Equal(t, 1, len(scopses))
assert.EqualValues(t, &token.ResourceActions{ assert.EqualValues(t, &token.ResourceActions{
Type: "repository", Type: "repository",
Name: "library/mysql/5.6", Name: "library/mysql/5.6",
Actions: []string{ Actions: []string{"pull", "push"},
"push"},
}, scopses[0]) }, scopses[0])
// invalid // invalid