Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
documentation:2.1:notifications [2019/07/10 18:23]
coudot [Notification server]
documentation:2.1:notifications [2019/08/29 10:39] (current)
cmaudoux [Notification format]
Line 1: Line 1:
 ====== Notifications system ====== ====== Notifications system ======
  
-Since version 0.9.4, ​LemonLDAP::​NG can be used to notify some messages to users: if a user has a messagethe message ​will be displayed when he will access to the portal. If the message contains check boxes, the user has to check all of them else he can not access to the portal and get his session cookie.+LemonLDAP::​NG can notify some messages to users: if a user has got messagesthey will be displayed when he access to the portal. If message contains ​some check boxes, the user has to check all of them else he can not access to the portal and retrieves ​his session cookie.
  
-Since 1.1.0, a notification explorer is available in Manager, and notifications can be done for all users, with the possibility to display conditions. When the user accept the notification, ​the reference is stored in his persistent session.+notification explorer is available in Manager, and notifications can be set for all users, with possibility to use display conditions. When the user accept the notification, ​notification ​reference is stored in his persistent session.
  
 ===== Installation ===== ===== Installation =====
Line 9: Line 9:
 ==== Activation ==== ==== Activation ====
  
-You just have to activate Notifications in the Manager (General Parameters > Advanced Parameters > Notifications > Activation) or in lemonldap-ng.ini:​+You just have to activate Notifications in the Manager (General Parameters > Advanced Parameters > Notifications > Activation) or in ''​lemonldap-ng.ini''​ [portal] section:
 <file ini> <file ini>
 [portal] [portal]
Line 88: Line 88:
 ===== Using notification system ===== ===== Using notification system =====
  
-<note important>​Since version 2.0, notifications are now stored in JSON format. If you want to keep old format, select "use old format"​ in the manager. Note that the server ​for inserting notifications is paired with the chosen format: REST for JSON and SOAP for XML.</​note>​+<note important>​Since version 2.0, notifications are now stored in JSON format. If you want to keep old format, select "use old format"​ in the Manager. Note that notification ​server ​depends on chosen format: REST for JSON and SOAP for XML.</​note>​
  
 ==== Notification format ==== ==== Notification format ====
Line 152: Line 152:
 </​file>​ </​file>​
  
 +<note tip>JSON format notifications are displayed sorted by date and reference</​note>​
 ==== Create new notifications with notifications explorer ==== ==== Create new notifications with notifications explorer ====
  
Line 163: Line 164:
  
 ==== Notification server ==== ==== Notification server ====
 +LemonLDAP::​NG provides two notification servers : SOAP and REST depending on format.
  
-New JSON notifications can be inserted using REST or SOAP server. ​If enabled, the server URL is https://​auth.your.domain/​notifications.+If enabled, the server URL is https://​auth.your.domain/​notifications.
  
 <note important>​If notification server is enabled, you have to protect this URL using the webserver because there is no authentication required to use it.</​note>​ <note important>​If notification server is enabled, you have to protect this URL using the webserver because there is no authentication required to use it.</​note>​
Line 170: Line 172:
 Example: Example:
 <file apache> <file apache>
-<file apache>​ +# REST/SOAP functions for insert/​delete/​list notifications ​(disabled by default)
-# REST/SOAP functions for notification insertion ​(disabled by default)+
 <​LocationMatch ^/​(index\.fcgi/​)?​notifications>​ <​LocationMatch ^/​(index\.fcgi/​)?​notifications>​
     <​IfVersion >= 2.3>     <​IfVersion >= 2.3>
Line 183: Line 184:
 </​LocationMatch>​ </​LocationMatch>​
 </​file>​ </​file>​
- 
-=== JSON notifications through REST === 
- 
-Using JSON, you just have to POST json files. 
- 
-For example with curl: 
-<​code>​ 
-curl -X POST -H "​Content-Type:​ application/​json"​ -H "​Accept:​ application/​json"​ -d @notif.json http://​auth.example.com/​notifications 
-</​code>​ 
  
 === XML notifications trough SOAP === === XML notifications trough SOAP ===
  
-If you use old XML format, new notifications can be inserted using SOAP request.+If you use old XML format, new notifications can be inserted ​or deleted by using SOAP request, once SOAP is activated:
  
-== Insertion example in Perl ==+== Insertion example in Perl ==
  
 <code perl> <code perl>
Line 231: Line 223:
 </​code>​ </​code>​
  
-You can also delete some notifications with SOAP, once SOAP is activated: 
  
-==Deletion example in Perl ===+== Deletion example in Perl ==
  
 <code perl> <code perl>
Line 255: Line 246:
     print "$res notification(s) have been deleted\n";​     print "$res notification(s) have been deleted\n";​
 } }
 +</​code>​
 +
 +
 +=== JSON notifications trough REST ===
 +
 +REST server provides three API to insert (POST), delete (DELETE) or list (GET) notification(s).
 +HTTP methods can enabled/​disabled in Manager: ''​General Parameters''​ » ''​Plugins''​ » ''​Notifications''​ » ''​Server''​ » ''​HTTP methods''​.
 +
 +Notifications parameters returned by ''​GET''​ method can be specfied in Manager, ''​General Parameters''​ » ''​Plugins''​ » ''​Notifications''​ » ''​Server''​ » ''​Notifications parameters to send''​. By default: 'uid reference date title subtitle text check'
 +
 +== * Insertion example with REST API ==
 +
 +Using JSON, you just have to POST json files.
 +
 +For example with curl:
 +<​code>​
 +curl -X POST -H "​Content-Type:​ application/​json"​ -H "​Accept:​ application/​json"​ -d @notif.json http://​auth.example.com/​notifications
 +</​code>​
 +
 +
 +== * Deletion example with REST API ==
 +
 +For example with curl:
 +<​code>​
 +curl -X DELETE -H "​Content-Type:​ application/​json"​ -H "​Accept:​ application/​json"​ http://​auth.example.com/​notifications/<​uid>/<​reference>​
 +</​code>​
 +
 +== * List example with REST API ==
 +
 +For example with curl:
 +<​code>​
 +curl -X GET -H "​Content-Type:​ application/​json"​ -H "​Accept:​ application/​json"​ http://​auth.example.com/​notifications
 +
 +curl -X GET -H "​Content-Type:​ application/​json"​ -H "​Accept:​ application/​json"​ http://​auth.example.com/​notifications/<​uid>​
 +
 +curl -X GET -H "​Content-Type:​ application/​json"​ -H "​Accept:​ application/​json"​ http://​auth.example.com/​notifications/<​uid>/<​reference>​
 </​code>​ </​code>​
  
 ==== Test notification ==== ==== Test notification ====
  
-You'​ve ​simply ​to insert a notification and connect to the portal using the same UID. You will be prompted.+You'​ve ​just to insert a notification and connect to the portal using the same UID. You will be prompted.
  
 {{  :​documentation:​portal-notification.png?​nolink ​ |}} {{  :​documentation:​portal-notification.png?​nolink ​ |}}