diff --git a/auth/auth.go b/auth/auth.go index 43992ac83c..486b7ab507 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -5,10 +5,13 @@ import ( "net/http" ) +// User represents an entity type User struct { Name string } +// Resource represents something that can be accessed and manipulated +// by a User type Resource struct { Type string `json:"type"` Name string `json:"name"` @@ -86,8 +89,8 @@ func (ss SimpleScope) ID() string { return string(ss) } -// TODO: possibly rename to Equals // Compare compares to the given scope for equality. +// TODO: possibly rename to Equals func (ss SimpleScope) Compare(toCompare Scope) bool { return ss.ID() == toCompare.ID() } diff --git a/auth/token/authorizer.go b/auth/token/authorizer.go index 87315f70dd..cc5d9d7aa5 100644 --- a/auth/token/authorizer.go +++ b/auth/token/authorizer.go @@ -18,6 +18,8 @@ import ( "github.com/docker/vetinari/utils" ) +// ConfigSection is the name used to identify the tokenAuthorizer config +// in the config json const ConfigSection string = "token_auth" type tokenConfig struct { @@ -90,7 +92,7 @@ type tokenAuthorizer struct { trustedKeys map[string]libtrust.PublicKey } -// newAccessController creates an accessController using the given options. +// NewTokenAuthorizer creates an Authorizer that operates with JWTs. func NewTokenAuthorizer(conf []byte) (auth.Authorizer, error) { tokenConf := new(tokenConfig) err := json.Unmarshal(conf, tokenConf) diff --git a/utils/http.go b/utils/http.go index a61f6df59a..ad286dc556 100644 --- a/utils/http.go +++ b/utils/http.go @@ -48,6 +48,9 @@ func (root *rootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } +// ResourceName parses the name of the resource being accessed from the request. +// It relies on gorilla mux being used and will need to be updated if that +// changes func ResourceName(r *http.Request) string { params := mux.Vars(r) if resource, ok := params["imageName"]; ok {