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/26 05:06:10 UTC

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

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


##########
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:
   ok, minor refactoring, now the local `xxx_phase` variable is not needed and the `phase` is not modified.



-- 
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