Merge pull request #5781 from cd1989/insufficient-scope-problem

Add pull scope to post/put/patch method
This commit is contained in:
Wenkai Yin 2018-09-03 14:26:31 +08:00 committed by GitHub
commit c4fc79ef75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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:
scope.Actions = []string{"pull"}
case http.MethodPost, http.MethodPut, http.MethodPatch:
scope.Actions = []string{"push"}
scope.Actions = []string{"pull", "push"}
case http.MethodDelete:
scope.Actions = []string{"*"}
default:

View File

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