From 01509db714038a26a335447f59a92ac4e44ef25e Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Tue, 15 Nov 2016 17:14:31 -0800 Subject: [PATCH] Add class to repository scope Signed-off-by: Derek McGowan (github: dmcgowan) --- registry/auth/auth.go | 5 +++-- registry/auth/token/token.go | 1 + registry/client/auth/session.go | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/registry/auth/auth.go b/registry/auth/auth.go index 0cb37235b..5d40ea3dc 100644 --- a/registry/auth/auth.go +++ b/registry/auth/auth.go @@ -66,8 +66,9 @@ type UserInfo struct { // Resource describes a resource by type and name. type Resource struct { - Type string - Name string + Type string + Class string + Name string } // Access describes a specific action that is diff --git a/registry/auth/token/token.go b/registry/auth/token/token.go index 634eb75b2..74ce92994 100644 --- a/registry/auth/token/token.go +++ b/registry/auth/token/token.go @@ -34,6 +34,7 @@ var ( // ResourceActions stores allowed actions on a named and typed resource. type ResourceActions struct { Type string `json:"type"` + Class string `json:"class"` Name string `json:"name"` Actions []string `json:"actions"` } diff --git a/registry/client/auth/session.go b/registry/client/auth/session.go index ffc3384b1..d6d884ffd 100644 --- a/registry/client/auth/session.go +++ b/registry/client/auth/session.go @@ -147,13 +147,18 @@ type Scope interface { // to a repository. type RepositoryScope struct { Repository string + Class string Actions []string } // String returns the string representation of the repository // using the scope grammar func (rs RepositoryScope) String() string { - return fmt.Sprintf("repository:%s:%s", rs.Repository, strings.Join(rs.Actions, ",")) + repoType := "repository" + if rs.Class != "" { + repoType = fmt.Sprintf("%s(%s)", repoType, rs.Class) + } + return fmt.Sprintf("%s:%s:%s", repoType, rs.Repository, strings.Join(rs.Actions, ",")) } // RegistryScope represents a token scope for access