This pull request adds the dependencies for and implements a basic version of JWT authentication to the Docks API. The only username and password combination accepted right now is admin/admin.
All Docks-API endpoints have authorization enabled except for the new token endpoint.
The token endpoint can be reached at /api/auth/token. To obtain a token, make a POST request to the token endpoint with the following JSON body:
{username: "admin", password: "admin"}
The API will then return the JWT inside of a JSON object as follows:
{jwt: long.jwt.here}
To access any of the authorized endpoints, you need to send the JWT along inside of the Authorization HTTP header in the following format:
This pull request adds the dependencies for and implements a basic version of JWT authentication to the Docks API. The only username and password combination accepted right now is
admin/admin
.All Docks-API endpoints have authorization enabled except for the new token endpoint.
The token endpoint can be reached at
/api/auth/token
. To obtain a token, make a POST request to the token endpoint with the following JSON body:The API will then return the JWT inside of a JSON object as follows:
To access any of the authorized endpoints, you need to send the JWT along inside of the
Authorization
HTTP header in the following format:Example of the above commands using curl:
-> {"jwt":"eyJhbGciOiJIUzI1NiIsInR5cC..."}
curl http://localhost:8080/docker/containers/json -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cC..."
-> [{"Id":"f65163fe4a1e5bbb2a4c32f99273e8d6c3381e5a9f2f4807dd3f6c4b23b60141","Names":[...
curl -I http://localhost:8080/docker/container/json -> HTTP/1.1 401 Unauthorized