2016-10-15 19:57:54 +02:00
<!DOCTYPE html>
< html lang = "fr" dir = "ltr" >
< head >
< meta http-equiv = "content-type" content = "text/html; charset=UTF-8" >
< meta charset = "utf-8" / >
2017-02-07 17:35:26 +01:00
< title > documentation:2.0:customfunctions< / title > <!-- //if:usedebianlibs
< link rel = "stylesheet" type = "text/css" href = "/javascript/bootstrap/css/bootstrap.min.css" / >
//elsif:useexternallibs
< link rel = "stylesheet" type = "text/css" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" > < / script >
//elsif:cssminified
< link rel = "stylesheet" type = "text/css" href = "/static/bwr/bootstrap/dist/css/bootstrap.min.css" / >
//else --><!-- //endif -->
2016-10-15 19:57:54 +02:00
< meta name = "generator" content = "DokuWiki" / >
2017-04-04 20:05:25 +02:00
< meta name = "robots" content = "index,follow" / >
2016-10-15 19:57:54 +02:00
< meta name = "keywords" content = "documentation,2.0,customfunctions" / >
< link rel = "search" type = "application/opensearchdescription+xml" href = "lib/exe/opensearch.html" title = "LemonLDAP::NG" / >
< link rel = "start" href = "customfunctions.html" / >
< link rel = "contents" href = "customfunctions.html" title = "Sitemap" / >
< link rel = "stylesheet" type = "text/css" href = "lib/exe/css.php.t.bootstrap3.css" / >
2017-02-07 17:35:26 +01:00
< link rel = "stylesheet" type = "text/css" href = "/static/bwr/bootstrap/dist/css/bootstrap.css" / >
2016-10-15 19:57:54 +02:00
< script type = "text/javascript" > / * < ! [ C D A T A [ * / v a r N S = ' d o c u m e n t a t i o n : 2 . 0 ' ; v a r J S I N F O = { " i d " : " d o c u m e n t a t i o n : 2 . 0 : c u s t o m f u n c t i o n s " , " n a m e s p a c e " : " d o c u m e n t a t i o n : 2 . 0 " } ;
/*!]]>*/< / script >
2017-02-07 17:35:26 +01:00
< script type = "text/javascript" charset = "utf-8" src = "lib/exe/js.php.t.bootstrap3.js" > < / script > <!-- //if:usedebianlibs
< script type = "text/javascript" src = "/javascript/jquery/jquery.min.js" > < / script >
//elsif:useexternallibs
< script type = "text/javascript" src = "http://code.jquery.com/jquery-2.2.0.min.js" > < / script >
//elsif:jsminified
< script type = "text/javascript" src = "/static/bwr/jquery/dist/jquery.min.js" > < / script >
//else -->
< script type = "text/javascript" src = "/static/bwr/jquery/dist/jquery.js" > < / script > <!-- //endif --> <!-- //if:usedebianlibs
< script type = "text/javascript" src = "/javascript/jquery-ui/jquery-ui.min.js" > < / script >
//elsif:useexternallibs
< script type = "text/javascript" src = "http://code.jquery.com/ui/1.10.4/jquery-ui.min.js" > < / script >
//elsif:jsminified
2018-03-08 13:29:31 +01:00
< script type = "text/javascript" src = "/static/bwr/jquery-ui/jquery-ui.min.js" > < / script >
2017-02-07 17:35:26 +01:00
//else -->
2018-03-08 13:29:31 +01:00
< script type = "text/javascript" src = "/static/bwr/jquery-ui/jquery-ui.js" > < / script > <!-- //endif -->
2017-02-07 17:35:26 +01:00
2016-10-15 19:57:54 +02:00
< / head >
< body >
< div class = "dokuwiki export container" > <!-- TOC START -->
< div id = "dw__toc" >
< h3 class = "toggle" > Table of Contents< / h3 >
< div >
< ul class = "toc" >
< li class = "level1" > < div class = "li" > < a href = "#write_custom_functions_library" > Écrire une librairie de fonctions personnalisées< / a > < / div > < / li >
< li class = "level1" > < div class = "li" > < a href = "#import_custom_functions_in_lemonldapng" > Importer les fonctions personnalisées dans LemonLDAP::NG< / a > < / div >
< ul class = "toc" >
< li class = "level2" > < div class = "li" > < a href = "#declare_module_in_handler_server" > Declarer le module dans le serveur « handler »< / a > < / div >
< ul class = "toc" >
2017-10-24 13:04:03 +02:00
< li class = "level3" > < div class = "li" > < a href = "#new_method" > New method< / a > < / div > < / li >
< li class = "level3" > < div class = "li" > < a href = "#old_method" > Old method< / a > < / div > < / li >
2016-10-15 19:57:54 +02:00
< / ul >
< / li >
< li class = "level2" > < div class = "li" > < a href = "#declare_custom_functions" > Declarer les fonctions personnalisées< / a > < / div > < / li >
< / ul >
< / li >
< li class = "level1" > < div class = "li" > < a href = "#use_it" > Les utiliser< / a > < / div > < / li >
< / ul >
< / div >
< / div > <!-- TOC END -->
< h1 class = "sectionedit1" id = "custom_functions" > Fonctions personnalisées< / h1 >
< div class = "level1" >
< p >
2017-02-07 17:35:26 +01:00
Custom functions allow one to extend < abbr title = "LemonLDAP::NG" > LL::NG< / abbr > , they can be used in < a href = "writingrulesand_headers.html#headers" class = "wikilink1" title = "documentation:2.0:writingrulesand_headers" > headers< / a > , < a href = "writingrulesand_headers.html#rules" class = "wikilink1" title = "documentation:2.0:writingrulesand_headers" > rules< / a > or < a href = "formreplay.html" class = "wikilink1" title = "documentation:2.0:formreplay" > form replay data< / a > .
2016-10-15 19:57:54 +02:00
< / p >
2017-02-07 17:35:26 +01:00
< / div > <!-- EDIT1 SECTION "Custom functions" [1 - 219] -->
2016-10-15 19:57:54 +02:00
< h2 class = "sectionedit2" id = "write_custom_functions_library" > Écrire une librairie de fonctions personnalisées< / h2 >
< div class = "level2" >
< p >
Créer un module Perl avec des fonctions personnalisées. Le module peut être appelé à la diligence du rédacteur, par exemple < code > SSOExtensions.pm< / code > :
< / p >
< pre class = "code" > vi /root/SSOExtensions.pm< / pre >
< pre class = "code file perl" > < a href = "http://perldoc.perl.org/functions/package.html" > < span class = "kw3" > package< / span > < / a > SSOExtensions< span class = "sy0" > ;< / span >
< span class = "kw2" > sub< / span > function1 < span class = "br0" > {< / span >
2017-03-30 07:08:56 +02:00
< span class = "kw1" > my< / span > < span class = "br0" > (< / span > < span class = "re0" > @args< / span > < span class = "br0" > )< / span > < span class = "sy0" > =< / span > < span class = "co5" > @_< / span > < span class = "sy0" > ;< / span >
2016-10-15 19:57:54 +02:00
2017-03-30 07:08:56 +02:00
< span class = "co1" > # Your nice code here< / span >
< a href = "http://perldoc.perl.org/functions/return.html" > < span class = "kw3" > return< / span > < / a > < span class = "re0" > $result< / span > < span class = "sy0" > ;< / span >
2016-10-15 19:57:54 +02:00
< span class = "br0" > }< / span >
< span class = "nu0" > 1< / span > < span class = "sy0" > ;< / span > < / pre >
2017-03-30 07:08:56 +02:00
< / div > <!-- EDIT2 SECTION "Write custom functions library" [220 - 554] -->
2016-10-15 19:57:54 +02:00
< h2 class = "sectionedit3" id = "import_custom_functions_in_lemonldapng" > Importer les fonctions personnalisées dans LemonLDAP::NG< / h2 >
< div class = "level2" >
2017-03-30 07:08:56 +02:00
< / div > <!-- EDIT3 SECTION "Import custom functions in LemonLDAP::NG" [555 - 608] -->
2016-10-15 19:57:54 +02:00
< h3 class = "sectionedit4" id = "declare_module_in_handler_server" > Declarer le module dans le serveur « handler »< / h3 >
< div class = "level3" >
< / div >
2017-10-24 13:04:03 +02:00
< h4 id = "new_method" > New method< / h4 >
2016-10-15 19:57:54 +02:00
< div class = "level4" >
2017-10-24 13:04:03 +02:00
< p >
Just declare files or Perl module that must be loaded:
< / p >
< pre class = "code file :ini" > < span class = "re0" > < span class = "br0" > [< / span > all< span class = "br0" > ]< / span > < / span >
< span class = "re1" > require< / span > < span class = "sy0" > =< / span > < span class = "re2" > /path/to/functions.pl, /path/to/func2.pm< / span >
# OR
< span class = "re1" > require< / span > < span class = "sy0" > =< / span > < span class = "re2" > My::Func1, My::Func2< / span > < / pre >
< / div >
< h4 id = "old_method" > Old method< / h4 >
< div class = "level4" >
< div class = "notewarning" > This method is available but unusable by Portal under Apache. So if your rule may be used by the menu, use the new method.
< / div >
< / div >
< h5 id = "apache" > Apache< / h5 >
< div class = "level5" >
2016-10-15 19:57:54 +02:00
< p >
Le module doit être chargé par Apache (par exemple après le chargement de l'agent) :
< / p >
< pre class = "code file apache" > < span class = "co1" > # Perl environment< / span >
PerlRequire Lemonldap::NG::Handler
PerlRequire /root/SSOExtensions.pm
PerlOptions +GlobalRequest< / pre >
< / div >
2017-10-24 13:04:03 +02:00
< h5 id = "fastcgi_server_nginx" > Serveur FastCGI (Nginx)< / h5 >
< div class = "level5" >
2016-10-15 19:57:54 +02:00
< p >
Il faut indiquer au < a href = "fastcgiserver.html" class = "wikilink1" title = "documentation:2.0:fastcgiserver" > serveur FastCGI de LLNG< / a > le fichier à lire en utilisant l'option < code > -f< / code > ou la variable d'environnement < code > CUSTOM_FUNCTIONS_FILE< / code > . En utilisant les packages, il suffit de modifier le fichier < code > /etc/default/llng-fastcgi-server< / code > (ou < code > /etc/default/lemonldap-ng-fastcgi-server< / code > ) :
< / p >
< pre class = "code file sh" > # Nombre de processus (défaut : 7)
#NPROC = 7
# Socket Unix d'écoute
SOCKET=/var/run/llng-fastcgi-server/llng-fastcgi.sock
# Fichier identifiant de processus (PID)
PID=/var/run/llng-fastcgi-server/llng-fastcgi-server.pid
# Utilisateur et groupe
USER=www-data
GROUP=www-data
# Fichier éventuel de fonctions personnalisées
CUSTOM_FUNCTIONS_FILE=/root/SSOExtensions.pm< / pre >
2017-10-24 13:04:03 +02:00
< / div > <!-- EDIT4 SECTION "Declare module in handler server" [609 - 1892] -->
2016-10-15 19:57:54 +02:00
< h3 class = "sectionedit5" id = "declare_custom_functions" > Declarer les fonctions personnalisées< / h3 >
< div class = "level3" >
< p >
Aller dans le manager, < code > Paramètres généraux< / code > » < code > Paramètres avancés< / code > » < code > Fonctions personnalisées< / code > et indiquer :
< / p >
< pre class = "code" > SSOExtensions::function1< / pre >
< div class = "noteimportant" > Si la fonction n'est pas compatible avec la < a href = "safejail.html" class = "wikilink1" title = "documentation:2.0:safejail" > cage saine< / a > , il faut désactiver la mise en cage.
< / div >
2017-10-24 13:04:03 +02:00
< / div > <!-- EDIT5 SECTION "Declare custom functions" [1893 - 2189] -->
2016-10-15 19:57:54 +02:00
< h2 class = "sectionedit6" id = "use_it" > Les utiliser< / h2 >
< div class = "level2" >
< p >
Les fonctions peuvent être utilisées dans une macro, un en-tête ou une règle d'accès, par exemple:
< / p >
2017-03-30 07:08:56 +02:00
< pre class = "code" > Custom-Header => function1( $uid, $ENV{REMOTE_ADDR} )< / pre >
2016-10-15 19:57:54 +02:00
2017-10-24 13:04:03 +02:00
< / div > <!-- EDIT6 SECTION "Use it" [2190 - ] -->
2016-10-15 19:57:54 +02:00
< / div >
< / body >
< / html >