User tools

Website tools


rest.php

Differences

The differences between two versions are shown here.

Link to this comparison view

Both sides of the previous revisionPrevious revision
Next revision
Previous revision
rest.php [2017/01/09 05:58] – gelöscht lwsystemsrest.php [2019/02/04 07:54] (current) – [Session Request] lwsystems
Line 1: Line 1:
 +====== rest.php ======
 +
 +  * REST-Frontend mit Benutzer-Authentisierung
 +  * Authentisierung per HTTP BASIC Auth oder Session-Cookie
 +  * Jeder BASIC AUTH Request eröffnet eine Session und liefert einen Cookie zurück
 +  * Dokumentation des [[REST API]]
 +
 +
 +====== Authentisierung ======
 +
 +===== HTTP BASIC Auth =====
 +
 +Hier wird der Request bei erfolgreicher Authentisierung ausgeführt.
 +Der Client muss Informationen wie das Archiv kennen.
 +
 +<code bash>
 +curl -u admin:secret \
 +  --data start=0 \
 +  --data limit=20 \
 +  --data archive=BennoContainer \
 +  --data 'query=Text:*hallo*' \
 +  -D - -k https://mailarchiv.lw-systems.net/benno/rest.php/search/
 +</code>
 +
 +===== Session =====
 +
 +From Benno Web version 2.2.2 onwards, authentication via session ID is also possible.
 +
 +==== Session erstellen ====
 +
 +Bei erfolgreichem Login wird ein User-Objekt mit den Userdaten und "Session-Name:Session-Id" als Wert des //password// Attributs zurück gegeben.
 +Das Attribut //archive// ist ein Array mit den Archiven, auf die der User Zugriff hat.
 +
 +<code bash>
 +curl -D - -k 'https://mailarchiv.lw-systems.net/benno/rest.php/login/?username=admin&password=secret'
 +
 +HTTP/1.1 200 OK
 +Date: Tue, 22 Nov 2016 14:24:11 GMT
 +Server: Apache/2.4.10 (Debian)
 +X-Powered-By: PHP/5.6.27-0+deb8u1
 +Set-Cookie: BENNOSID=c223e75ohpq5u1i0j9hhv36n60; path=/benno/rest.php
 +Expires: Thu, 19 Nov 1981 08:52:00 GMT
 +Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
 +Pragma: no-cache
 +Content-Length: 138
 +Content-Type: application/json; charset=UTF-8
 +
 +{"id":"admin","password":"BENNOSID:c223e75ohpq5u1i0j9hhv36n60","name":"Admin User","archive":["BennoContainer"],"addresses":["*@*"],"role":"ADMIN"}
 +</code>
 +
 +==== Search Request ====
 +
 +<code bash>
 +curl --cookie BENNOSID=c223e75ohpq5u1i0j9hhv36n60 \
 +  --data start=0 \
 +  --data limit=20 \
 +  --data archive=BennoContainer \
 +  --data 'query=Text:*hallo*' \
 +  -D - -k https://mailarchiv.lw-systems.net/benno/rest.php/search/
 +</code>
 +
  
rest.php.1483941487.txt.gz · Zuletzt geändert: 2017/01/09 05:58 von lwsystems