Custom functions allow one to extend LL::NG, they can be used in headers, rules or form replay data.
Create your Perl module with custom functions. You can name your module as you want, for example SSOExtensions.pm
:
vi /root/SSOExtensions.pm
package SSOExtensions; sub function1 { my (@args) = @_; # Your nice code here return $result; } 1;
Just declare files or Perl module that must be loaded:
[all] require = /path/to/functions.pl, /path/to/func2.pm # OR require = My::Func1, My::Func2
Your module has to be loaded by Apache (for example after Handler load):
# Perl environment
PerlRequire Lemonldap::NG::Handler
PerlRequire /root/SSOExtensions.pm
PerlOptions +GlobalRequest
You've just to incicate to LLNG FastCGI server the file to read using either -f
option or CUSTOM_FUNCTIONS_FILE
environment variable. Using packages, you just have to modify your /etc/default/llng-fastcgi-server
(or /etc/default/lemonldap-ng-fastcgi-server
) file:
# Number of process (default: 7) #NPROC = 7 # Unix socket to listen to SOCKET=/var/run/llng-fastcgi-server/llng-fastcgi.sock # Pid file PID=/var/run/llng-fastcgi-server/llng-fastcgi-server.pid # User and GROUP USER=www-data GROUP=www-data # Custom functions file CUSTOM_FUNCTIONS_FILE=/root/SSOExtensions.pm
Go in Manager, General Parameters
» Advanced Parameters
» Custom functions
and set:
SSOExtensions::function1
You can now use your function in a macro, an header or an access rule, for example:
Custom-Header => function1( $uid, $ENV{REMOTE_ADDR} )