mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-03 06:28:06 +01:00
Add pull scope to post/put/patch method
Signed-off-by: 陈德 <chende@caicloud.io>
This commit is contained in:
parent
22c53d9f34
commit
6eb972c383
@ -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:
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user