You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/07/25 06:04:38 UTC

[GitHub] [apisix] spacewander commented on a diff in pull request #7531: fix: auth plugin repeats the rewrite phase

spacewander commented on code in PR #7531:
URL: https://github.com/apache/apisix/pull/7531#discussion_r928495875


##########
apisix/plugin.lua:
##########
@@ -875,14 +875,20 @@ function _M.run_plugin(phase, plugins, api_ctx)
         return api_ctx
     end
 
+    local ori_phase = phase
     if phase ~= "log"
         and phase ~= "header_filter"
         and phase ~= "body_filter"
         and phase ~= "delayed_body_filter"
     then
         for i = 1, #plugins, 2 do
-            if phase == "rewrite_in_consumer" and plugins[i + 1]._from_consumer
-                    and plugins[i].type ~= "auth"then
+            if ori_phase == "rewrite_in_consumer" and not plugins[i + 1]._from_consumer
+                    and plugins[i].type == "auth" then
+                plugins[i + 1]._skip_rewrite_in_consumer = true
+            end
+
+            if ori_phase == "rewrite_in_consumer" and plugins[i + 1]._from_consumer

Review Comment:
   Will it be more readable if we use a local `xxx_phase` variable and keep the `phase` passed as the argument unchanged? The reasons are:
   1. better not to rename the variable which is passed as the argument
   2. the new `xxx_phase`'s scope will not pass through a step in  `for i = 1, #plugins, 2 do` loop. It won't affect the next plugin.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org