pavlenkodev commented on issue #10518:
URL: https://github.com/apache/apisix/issues/10518#issuecomment-1819043142
> @pavlenkodev Are you talking about using this in key-auth plugin? Can you
provide the full plugin configuration which you're trying to use?
I'm using a basic configuration for consumer
and the route. It is presented here - https://api
sys.apache.org/docs/apisix/terminology/consumer/
Following the example at the link https://api
sys.apache.org/docs/apisix/terminology/consumer/#example , I am trying to
configure the key-auth plugin using my own variable, which I register using
serverless-pre-function globally
Here is an example from the documentation :
```
curl http://127.0.0.1:9180/apisix/admin/consumers \
-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"username": "jack",
"plugins": {
"key-auth": {
"key": "auth-one"
},
"limit-count": {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
}
}
}'
```
And here is an example that I would like to implement. The request has a jwt
token and I get a parameter from it in the globally configured
serverless-pre-function plugin and register it in the $my_value variable.
I know what values will come in this variable. For example: 1, 2, 3.
To do this, I will configure key-auth as shown below
```
curl http://127.0.0.1:9180/apisix/admin/consumers \
-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"username": "jack",
"plugins": {
"key-auth": {
"key": "1" -- or 2 or 3
},
"limit-count": {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
}
}
}'
```
After such a configuration, I would like to add the `apiKey: 1 `header at
every request using the proxy-rewrite globaly, so that key-auth accepts it and
opens access for routes that are waiting for it.
This is my idea of using. I managed to configure the key-auth plugin, there
are no problems with this. The problem is that I can't get consumer to accept
my apiKey:1 header for authorization and allow me to make a request
Do you have any ideas how this can be done? Or is it impossible?
--
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]