Skip to content

Latest commit

 

History

History
47 lines (29 loc) · 2.21 KB

File metadata and controls

47 lines (29 loc) · 2.21 KB

Mapbender REST API

Mapbender offers a REST API. A subset of the console commands is also available here for usage e.g. in external tools. If it for example used by the QGIS2Mapbender QGIS Plugin.

Setup

  • Replace the environment variable JWT_PASSPHRASE=<change_me> in the .env or .env.local file. If you are in a
    unix environment this is automatically done (using a random string) when calling the bootstrap script.

⚠️ Each time you change the passphrase you also need to re-generate the encryption keys

Authentication

The JWT token can be obtained by sending authentication data (in JSON format: { "username": "<username>", "password": "<password>" }) to <server_url>/api/login_check

Example Curl command:

curl -X POST <server_url>/api/login_check  -H "Content-Type: application/json"  -d '{"username": "<username>", "password": "<password>"}'`

You will get a JSON response like {"token": "<token>"} in the success case.

Security

All users (except for the super user with the id 1, where this permission is automatically granted) need to have the global permission access_api in order to perform any operation on the API.
Additionally, users need to have the specific permission required to perform an action, e.g. to duplicate an application, they need to have read rights on the existing application as well as the global permission create_applications

Calling the API

Call the API by supplying the obtained token in the Authorization header:

curl -X GET -H "Authorization: Bearer <token>" <server_url>/api/example

↑ Back to top

← Back to README