Baoyuantop commented on issue #12349:
URL: https://github.com/apache/apisix/issues/12349#issuecomment-2999090285

   Hi @guilhermevillote, let me address your three questions one by one:
   
   ### 1) Accessing route and consumer configurations separately
   
   **Current State**: You're absolutely correct that currently only the merged 
configuration is available in the access phase. Based on source code analysis 
([apisix/plugin.lua:711-750](https://github.com/apache/apisix/blob/master/apisix/plugin.lua#L711-L750)),
 consumer configuration directly overwrites route configuration:
   
   ```lua
   for name, conf in pairs(consumer_conf.plugins) do
       new_route_conf.value.plugins[name] = conf  -- Direct overwrite
   end
   ```
   
   **Solution**: Your idea is correct - saving the original configuration in 
the rewrite phase is the most viable approach.
   
   ### 2) How the merge strategy works internally
   
   The current merge strategy is indeed **complete replacement** rather than 
hierarchical merging. As evident from your example:
   - `acl` plugin: route's `{"allow_groups": ["infra"]}` is completely replaced 
by consumer's `{"groups": ["devops"]}`
   - This is plugin-level complete overwrite, not field-level intelligent 
merging
   
   APISIX currently doesn't have built-in hierarchical merging - this is a 
design choice for simplicity.
   
   ### 3) Recommended solution
   
   **I don't recommend using `type = 'auth'`** - as you correctly worry, this 
would indeed mix responsibilities.
   
   Your analysis is very accurate. The current limitation does exist, and 
saving the original configuration in the rewrite phase is currently the most 
practical solution.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to