Custom functions

Custom functions allow to extend LL::NG, they can be used in headers, rules or form replay data.

Write custom functions library

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 $url = shift;
  my $param = shift;
 
  # Your nice code here
 
  return $param
}
 
1;

First parameter passed to the custom function is the requested URL, that is

  • portal full URL if custom function is run by portal (e.g. https://auth.example.com/)
  • absolute URL if it is run by handler (e.g. /admin/index.php?param=foo).

Import custom functions in LemonLDAP::NG

Declare module in Apache configuration

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

Declare custom functions

Go in Manager, General Parameters » Advanced Parameters » Custom functions and set:

SSOExtensions::function1

If your function is not compliant with Safe jail, you will need to disable the jail.

Use it

You can now use your function in a macro, an header or an access rule, for example:

Custom-Header => function1($uid)