Add a HTTP Basic Authentication Plugin
This example adds an HTTP Basic Authentication Plugin to a new route on the echo-service.
Add a Consumer with HTTP Basic Auth Credentials
A Consumer is an individual or application that requires access to a Service. A Consumer must have at least one credential.
- Click Consumers on the menu.
- Click the Add action icon.
- Enter the Consumer name, for example "consumer-app-1".
- Enter the Consumer description, for example "The consumer for app 1".
- Click SAVE, the Credentials tabs will be displayed
- Click the HTTP BASIC AUTH tab
- Click the Credentials Add action icon.
- Enter the Credential description, for example "HTTP Basic Auth credential for user user-1"
- Enter the Username, for example "user-1".
- Enter the Password, for example "password-1".
- Click SAVE
Create a New Route
- Click Services on the menu.
- Click the echo-service on the Services list.
- Click the Routes tab.
- Click the Add action icon.
- Enter the Route name, for example "echo-route-http-basic-auth".
- Enter the description, for example "Route and authenticate requests with URI prefix /echo-http-auth".
- Select the Paths field.
- Enter /echo-http-auth and press ENTER.
- Click SAVE.
Add the Plugin
- Click Services on the menu.
- Click the echo-service Service.
- Click the Routes tab.
- Click the echo-route-http-basic-auth Route.
- Click the Plugins tab.
- Click the Add action icon.
- Select the "HTTP Basic Authentication" plugin type.
- Enter the Plugin description, for example "Authenticate consumer-app-1".
- From the Consumers list, select consumer-app-1.
- Click SAVE.
Test the Configuration
- From the Console Dashboard, start the gateway or redeploy the gateway configuration.
- In a browser, enter the authenticated route URL using the address of the gateway listener, for example http://nonstop-host:19091/echo-http-auth.
- The browser should raise an authorization dialog.
- Enter the HTTP authentication credentials, username "user-1", password "password-1".
- The response should be returned.