@@ -52,8 +52,6 @@ type Ctx struct {
5252}
5353
5454// AuthZRequest authorized the request to the docker daemon using authZ plugins
55- // Side effect: If the authz plugin is invalid, then update ctx.plugins, so that
56- // the caller(middleware) can update its list and stop retrying with invalid plugins.
5755func (ctx * Ctx ) AuthZRequest (w http.ResponseWriter , r * http.Request ) error {
5856 var body []byte
5957 if sendBody (ctx .requestURI , r .Header ) && r .ContentLength > 0 && r .ContentLength < maxBodySize {
@@ -85,14 +83,11 @@ func (ctx *Ctx) AuthZRequest(w http.ResponseWriter, r *http.Request) error {
8583 }
8684 }
8785
88- for i , plugin := range ctx .plugins {
86+ for _ , plugin := range ctx .plugins {
8987 logrus .Debugf ("AuthZ request using plugin %s" , plugin .Name ())
9088
9189 authRes , err := plugin .AuthZRequest (ctx .authReq )
9290 if err != nil {
93- if err == ErrInvalidPlugin {
94- ctx .plugins = append (ctx .plugins [:i ], ctx .plugins [i + 1 :]... )
95- }
9691 return fmt .Errorf ("plugin %s failed with error: %s" , plugin .Name (), err )
9792 }
9893
@@ -105,8 +100,6 @@ func (ctx *Ctx) AuthZRequest(w http.ResponseWriter, r *http.Request) error {
105100}
106101
107102// AuthZResponse authorized and manipulates the response from docker daemon using authZ plugins
108- // Side effect: If the authz plugin is invalid, then update ctx.plugins, so that
109- // the caller(middleware) can update its list and stop retrying with invalid plugins.
110103func (ctx * Ctx ) AuthZResponse (rm ResponseModifier , r * http.Request ) error {
111104 ctx .authReq .ResponseStatusCode = rm .StatusCode ()
112105 ctx .authReq .ResponseHeaders = headers (rm .Header ())
@@ -115,14 +108,11 @@ func (ctx *Ctx) AuthZResponse(rm ResponseModifier, r *http.Request) error {
115108 ctx .authReq .ResponseBody = rm .RawBody ()
116109 }
117110
118- for i , plugin := range ctx .plugins {
111+ for _ , plugin := range ctx .plugins {
119112 logrus .Debugf ("AuthZ response using plugin %s" , plugin .Name ())
120113
121114 authRes , err := plugin .AuthZResponse (ctx .authReq )
122115 if err != nil {
123- if err == ErrInvalidPlugin {
124- ctx .plugins = append (ctx .plugins [:i ], ctx .plugins [i + 1 :]... )
125- }
126116 return fmt .Errorf ("plugin %s failed with error: %s" , plugin .Name (), err )
127117 }
128118
0 commit comments