Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request help: The plugins that act on the specified consumer do not take effect #6405

Closed
tzssangglass opened this issue Feb 21, 2022 · 3 comments · Fixed by #6502
Closed

Comments

@tzssangglass
Copy link
Member

tzssangglass commented Feb 21, 2022

Issue description

origin mail: https://lists.apache.org/thread/o0zh8pddh50ytcf99g8jr5wnxbf9p9t3

User Description:

And when I use the same config :

\"proxy-rewrite\": {
      \"headers\": {
        \"X-USER-ID\": \"USER1-ID\"
      }
    }

In the route config it works :

curl --location --request PUT
"http://$APISIX_URL:$APISIX_PORT/apisix/admin/routes/api-v1" \
--header "X-API-KEY: $APISIX_API_ADMIN_KEY" \
--header "Content-Type: application/json" \
--data-raw "{
  \"uri\": \"/v1/*\",
  \"host\": \"$APISIX_HOST\",
  \"plugins\": {
    \"key-auth\": {},
    \"consumer-restriction\": {
        \"whitelist\": [
            \"user1\",
            \"user2\"
        ]
    },
    \"proxy-rewrite\": {
      \"headers\": {
        \"X-USER-ID\": \"USER1-ID\"
      }
    }
  },
  \"service_id\": \"api-v1\"
}"

and

I mean that when I configure the plugin proxy-rewrite on the routes I have
the header X-USER-ID set with the value USER1-ID (everything is fine) and
when I configure it on the consumer user1 and I call the endpoint with the
apikey of user1, the header X-USER-ID does not exist.

Environment

  • apisix version (cmd: apisix version):
  • OS (cmd: uname -a):
  • OpenResty / Nginx version (cmd: nginx -V or openresty -V):
  • etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info to get the info from server-info API):
  • apisix-dashboard version, if have:
  • the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
  • luarocks version, if the issue is about installation (cmd: luarocks --version):
@tzssangglass tzssangglass added the checking check first if this issue occurred label Feb 21, 2022
@tzssangglass
Copy link
Member Author

Reproduction steps:

  1. add consumer
curl --location --request PUT 'http://127.0.0.1:9080/apisix/admin/consumers' \
--header 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
--header 'Content-Type: application/json' \
--data-raw '{
    "username": "jack",
    "plugins": {
        "key-auth": {
            "key": "auth-jack"
        },
        "proxy-rewrite": {
            "headers": {
                "X-CONSUMER-ID": "1"
            }
        }
    }
}'
  1. add routes
curl --location --request PUT 'http://127.0.0.1:9080/apisix/admin/routes/1' \
--header 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
--header 'Content-Type: application/json' \
--data-raw '{
    "upstream": {
        "nodes": {
            "httpbin.org:80": 1
        },
        "type": "roundrobin"
    },
    "uri": "/get",
    "plugins": {
        "key-auth": {}
    }
}'
  1. trigger route
curl --location --request GET '127.0.0.1:9080/get' \
--header 'apikey: auth-jack'

{
    "args": {},
    "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate, br",
        "Apikey": "auth-jack",
        "Host": "127.0.0.1",
        "Postman-Token": "c1ac1210-fce9-4e35-91f5-c752ce4dff15",
        "User-Agent": "PostmanRuntime/7.29.0",
        "X-Amzn-Trace-Id": "Root=1-6213bd02-7c52cf461b20d29e1c9e83b7",
        "X-Forwarded-Host": "127.0.0.1"
    },
    "origin": "127.0.0.1, 180.118.91.243",
    "url": "http://127.0.0.1/get"
}

the X-CONSUMER-ID is indeed not added

@membphis
Copy link
Member

membphis commented Feb 22, 2022

This seems like a bug, all right? @tzssangglass

@tzssangglass
Copy link
Member Author

This seems like a bug, all right? @tzssangglass

yes, my understanding is that when the request hits the consumer, APISIX should execute over the plugins configured in the consumer.

Now it is clear that it does not.

However, this test case has a flaw.

Did the request hit the consumer? Maybe it just hit the route.

tzssangglass added a commit to tzssangglass/apisix that referenced this issue Mar 3, 2022
@tzssangglass tzssangglass removed the checking check first if this issue occurred label Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants