Add verb to authorizer attributes

This commit is contained in:
Jordan Liggitt
2015-09-28 21:11:51 -04:00
parent 719cf5617e
commit e024e55e8e
3 changed files with 38 additions and 29 deletions

View File

@@ -362,11 +362,10 @@ func (r *requestAttributeGetter) GetAttribs(req *http.Request) authorizer.Attrib
}
}
attribs.ReadOnly = IsReadOnlyReq(*req)
apiRequestInfo, _ := r.apiRequestInfoResolver.GetAPIRequestInfo(req)
attribs.APIGroup = apiRequestInfo.APIGroup
attribs.Verb = apiRequestInfo.Verb
// If a path follows the conventions of the REST object store, then
// we can extract the resource. Otherwise, not.
@@ -441,7 +440,8 @@ type APIRequestInfoResolver struct {
// /api/{version}/watch/namespaces/{namespace}/{resource}
func (r *APIRequestInfoResolver) GetAPIRequestInfo(req *http.Request) (APIRequestInfo, error) {
requestInfo := APIRequestInfo{
Raw: splitPath(req.URL.Path),
Raw: splitPath(req.URL.Path),
Verb: strings.ToLower(req.Method),
}
currentParts := requestInfo.Raw
@@ -489,8 +489,9 @@ func (r *APIRequestInfoResolver) GetAPIRequestInfo(req *http.Request) (APIReques
requestInfo.Verb = "patch"
case "DELETE":
requestInfo.Verb = "delete"
default:
requestInfo.Verb = ""
}
}
// URL forms: /namespaces/{namespace}/{kind}/*, where parts are adjusted to be relative to kind