mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 16:06:51 +00:00
Add verb to authorizer attributes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user