Basic
Add Basic Authentication to your APIs, with username and password protection. The plugin will check for valid credentials in the Authorization
header.
Configuration
The plain basic auth config:
Here is a simple definition of the available configurations.
Usage
In order to use the plugin, you first need to create some users first. By enabling this plugins in any endpoint There is a simple API that you can use to create new users.
Create an User
You need to create an user that will be used to authenticate. To create an user you can execute the following request:
http -v POST http://localhost:8081/credentials/basic_auth "Authorization:Bearer yourToken" username=lanister password=pay-your-debt
curl -X POST http://localhost:8081/credentials/basic_auth -H 'authorization: Bearer yourToken' -H 'content-type: application/json' -d '{"username": "lanister", "password": "pay-your-debt"}'
Using the Credential
The authorization header must be base64 encoded. For example, if the credential uses lanister
as the username and pay-your-debt
as the password, then the field's value is the base64-encoding of lanister:pay-your-debt, or bGFuaXN0ZXI6cGF5LXlvdXItZGVidA==.
Then the Authorization
header must appear as:
Authorization: Basic bGFuaXN0ZXI6cGF5LXlvdXItZGVidA== Simply make a request with the header:
http -v http://localhost:8080/example "Authorization:Basic bGFuaXN0ZXI6cGF5LXlvdXItZGVidA=="
curl -v http://localhost:8080/example -H 'Authorization:Basic bGFuaXN0ZXI6cGF5LXlvdXItZGVidA=='
Last updated