From 6eb972c383da951834aebe911a004239f01bf76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BE=B7?= Date: Mon, 3 Sep 2018 10:48:52 +0800 Subject: [PATCH] Add pull scope to post/put/patch method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈德 --- src/common/utils/registry/auth/tokenauthorizer.go | 2 +- src/common/utils/registry/auth/tokenauthorizer_test.go | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/common/utils/registry/auth/tokenauthorizer.go b/src/common/utils/registry/auth/tokenauthorizer.go index 6a0812169..01435d807 100644 --- a/src/common/utils/registry/auth/tokenauthorizer.go +++ b/src/common/utils/registry/auth/tokenauthorizer.go @@ -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: diff --git a/src/common/utils/registry/auth/tokenauthorizer_test.go b/src/common/utils/registry/auth/tokenauthorizer_test.go index bf6615f81..5a564992d 100644 --- a/src/common/utils/registry/auth/tokenauthorizer_test.go +++ b/src/common/utils/registry/auth/tokenauthorizer_test.go @@ -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