Skip to content

Commit 1e0f685

Browse files
authored
Merge pull request moby#5321 from morpheu/ignore_invalid_scope
util/resolver: ignore invalid (empty) scope
2 parents b473b7a + 3367fda commit 1e0f685

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

util/resolver/authorizer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,9 @@ func parseScopes(s []string) scopes {
450450
// https://docs.docker.com/registry/spec/auth/scope/
451451
m := map[string]map[string]struct{}{}
452452
for _, scopeStr := range s {
453+
if scopeStr == "" {
454+
return nil
455+
}
453456
// The scopeStr may have strings that contain multiple scopes separated by a space.
454457
for _, scope := range strings.Split(scopeStr, " ") {
455458
parts := strings.SplitN(scope, ":", 3)

util/resolver/authorizer_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ func TestParseScopes(t *testing.T) {
1111
input []string
1212
expected scopes
1313
}{
14+
{
15+
name: "InvalidScope",
16+
input: []string{""},
17+
expected: nil,
18+
},
1419
{
1520
name: "SeparateStrings",
1621
input: []string{

0 commit comments

Comments
 (0)