Skip to main content
Skip table of contents

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.

  1. Click Consumers on the menu.
  2. Click the Add action icon.
  3. Enter the Consumer name, for example "consumer-app-1".
  4. Enter the Consumer description, for example "The consumer for app 1".
  5. Click SAVE, the Credentials tabs will be displayed
  6. Click the HTTP BASIC AUTH tab
  7. Click the Credentials Add action icon.
  8. Enter the Credential description, for example "HTTP Basic Auth credential for user user-1"
  9. Enter the Username, for example "user-1".
  10. Enter the Password, for example "password-1".
  11. Click SAVE

Create a New Route

  1. Click Services on the menu.
  2. Click the echo-service on the Services list.
  3. Click the Routes tab.
  4. Click the Add action icon.
  5. Enter the Route name, for example "echo-route-http-basic-auth".
  6. Enter the description, for example "Route and authenticate requests with URI prefix /echo-http-auth".
  7. Select the Paths field.
    1. Enter /echo-http-auth and press ENTER.
  8. Click SAVE.

Add the Plugin

  1. Click Services on the menu.
  2. Click the echo-service Service.
  3. Click the Routes tab.
  4. Click the echo-route-http-basic-auth Route.
  5. Click the Plugins tab.
  6. Click the Add action icon.
  7. Select the "HTTP Basic Authentication" plugin type.
  8. Enter the Plugin description, for example "Authenticate consumer-app-1".
  9. From the Consumers list, select consumer-app-1.
  10. Click SAVE.

Test the Configuration

  1. From the Console Dashboard, start the gateway or redeploy the gateway configuration.
  2. In a browser, enter the authenticated route URL using the address of the gateway listener, for example http://nonstop-host:19091/echo-http-auth. 
  3. The browser should raise an authorization dialog. 
  4. Enter the HTTP authentication credentials, username "user-1", password "password-1".
  5. The response should be returned.
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.