Version: 2.3.0
basic-auth
Summary#
Name#
basic-auth is an authentication plugin that need to work with consumer. Add Basic Authentication to a service or route.
The consumer then adds its key to the request header to verify its request.
For more information on Basic authentication, refer to Wiki for more information.
Attributes#
| Name | Type | Requirement | Default | Valid | Description |
|---|---|---|---|---|---|
| username | string | required | Different consumer should have different value which is unique. When different consumer use a same username, a request matching exception would be raised. | ||
| password | string | required | the user's password |
How To Enable#
1. set a consumer and config the value of the basic-auth option#
you can visit Dashboard http://127.0.0.1:9080/apisix/dashboard/ and add a Consumer through the web console:

then add basic-auth plugin in the Consumer page:

2. add a Route or add a Service, and enable the basic-auth plugin#
Test Plugin#
- missing Authorization header
- user is not exists:
- password is invalid:
- success:
Disable Plugin#
When you want to disable the basic-auth plugin, it is very simple,
you can delete the corresponding json configuration in the plugin configuration,
no need to restart the service, it will take effect immediately: