| 1 |
REST |
| 2 |
==== |
| 3 |
|
| 4 |
============== ===== ======== |
| 5 |
Authentication Users Password |
| 6 |
============== ===== ======== |
| 7 |
✔ ✔ ✔ |
| 8 |
============== ===== ======== |
| 9 |
|
| 10 |
Presentation |
| 11 |
------------ |
| 12 |
|
| 13 |
This backend can be used to delegate authentication to some webservices. |
| 14 |
|
| 15 |
Configuration |
| 16 |
------------- |
| 17 |
|
| 18 |
In Manager, go in ``General Parameters`` > ``Authentication modules`` |
| 19 |
and choose REST for authentication, users and/or password modules. |
| 20 |
|
| 21 |
Then, go in ``REST parameters`` and you just have to set REST URL to |
| 22 |
provide wanted services: |
| 23 |
|
| 24 |
===================== ==================================== |
| 25 |
Module Parameter |
| 26 |
===================== ==================================== |
| 27 |
Authentication level Authentication level for this module |
| 28 |
Authentication Authentication URL |
| 29 |
User database User data URL |
| 30 |
Password confirmation Password confirmation URL |
| 31 |
Password change Password change URL |
| 32 |
===================== ==================================== |
| 33 |
|
| 34 |
|
| 35 |
.. tip:: |
| 36 |
|
| 37 |
You can then choose any other module for users and |
| 38 |
password. |
| 39 |
|
| 40 |
REST Dialog |
| 41 |
----------- |
| 42 |
|
| 43 |
LemonLDAP::NG will call the endpoints you declared at various steps |
| 44 |
during the login process. |
| 45 |
|
| 46 |
The request performed by LemonLDAP::NG is a POST on the URL you |
| 47 |
specified, the content of the POST is a JSON document |
| 48 |
(``Content-Type: application/json``). |
| 49 |
|
| 50 |
REST web services must respond with a success HTTP code (200), and the |
| 51 |
response must be a JSON document containing a ``result`` key. |
| 52 |
Auth/UserDB endpoints can add an ``info`` array that will be stored in |
| 53 |
session data (without reading "Exported variables"). |
| 54 |
|
| 55 |
========================= ======================================= =================================================== |
| 56 |
URL Query Response |
| 57 |
========================= ======================================= =================================================== |
| 58 |
Authentication URL ``{"user":$user,"password":$password}`` ``{"result":true/false,"info":{...}}`` |
| 59 |
User data URL ``{"user":$user}`` ``{"result":true/false,"info":{"uid":"dwho",...}}`` |
| 60 |
Password confirmation URL ``{"user":$user,"password":$password}`` ``{"result":true/false}`` |
| 61 |
Password change URL ``{"user":$user,"password":$password}`` ``{"result":true/false}`` |
| 62 |
========================= ======================================= =================================================== |
| 63 |
|
| 64 |
|
| 65 |
.. tip:: |
| 66 |
|
| 67 |
To have only one REST call during the login process, you can |
| 68 |
set REST only as an Authentication backend, configure Null as your User |
| 69 |
Database, and make sure the REST authentication URL send all your user |
| 70 |
attributes in the ``info`` response key |
| 71 |
|
| 72 |
|
| 73 |
.. _rest-args: |
| 74 |
|
| 75 |
Additional arguments |
| 76 |
-------------------- |
| 77 |
|
| 78 |
.. versionadded:: 2.23.0 |
| 79 |
|
| 80 |
You can define additional arguments that will be sent along ``user``, ``password``, etc. in the body of the REST request. |
| 81 |
|
| 82 |
In the *arguments* section, specify the name of the JSON parameter as the *key* and a perl expression as the *value*. |
| 83 |
|
| 84 |
However keep in mind that in most situations, user attributes will not be available yet. But you can still use CGI environment variables. |
| 85 |
|
| 86 |
For example, setting a key of ``ip`` and a value of ``$ENV{REMOTE_ADDR}`` will result in the following REST authentication request: |
| 87 |
|
| 88 |
.. code:: json |
| 89 |
|
| 90 |
{ |
| 91 |
"ip": "127.0.0.1", |
| 92 |
"password": "dwho", |
| 93 |
"user": "dwho" |
| 94 |
} |