basic-auth
This works well with a . Consumers of the API can then add their key to the header to authenticate their requests.
For Consumer:
Name | Type | Required | Default | Description |
---|---|---|---|---|
hide_credentials | boolean | False | false | Set to true to pass the authorization request headers to the Upstream. |
To enable the Plugin, you have to create a Consumer object with the authentication configuration:
You can also use the APISIX Dashboard to complete the operation through a web UI.
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/hello",
"plugins": {
},
"upstream": {
"type": "roundrobin",
"nodes": {
}
}'
After you have configured the Plugin as mentioned above, you can make a request to the Route as shown below:
HTTP/1.1 200 OK
...
hello, world
If the request is not authorized, an error will be thrown:
HTTP/1.1 401 Unauthorized
To disable the jwt-auth
Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect.