Basic
Last updated
Was this helpful?
Last updated
Was this helpful?
Add Basic Authentication to your APIs, with username and password protection. The plugin will check for valid credentials in the Authorization
header.
The plain basic auth config:
Here is a simple definition of the available configurations.
Configuration
Description
name
Name of the plugin to use, in this case: basic_auth
enabled
Is the plugin enabled?
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.
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 "Authorization:Bearer yourToken" username=lanister password=pay-your-debt
FORM PARAMETER
Description
username
The username to use in the Basic Authentication
password
The password to use in the Basic Authentication
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:
curl -X POST -H 'authorization: Bearer yourToken' -H 'content-type: application/json' -d '{"username": "lanister", "password": "pay-your-debt"}'
http -v "Authorization:Basic bGFuaXN0ZXI6cGF5LXlvdXItZGVidA=="
curl -v -H 'Authorization:Basic bGFuaXN0ZXI6cGF5LXlvdXItZGVidA=='