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:latest:extendedfunctions [2019/01/15 15:54]
127.0.0.1 external edit
documentation:latest:extendedfunctions [2019/11/22 18:59] (current)
Line 26: Line 26:
     * [[#​iso2unicode|iso2unicode]]     * [[#​iso2unicode|iso2unicode]]
     * [[#​groupMatch|groupMatch]]     * [[#​groupMatch|groupMatch]]
 +    * [[#​listMatch|listMatch]] ({{..:​new.png?​direct&​35|}} // since 2.0.7)//
     * [[#​encrypt|encrypt]]     * [[#​encrypt|encrypt]]
     * [[#​token|token]]     * [[#​token|token]]
     * [[#​isInNet6|isInNet6]]     * [[#​isInNet6|isInNet6]]
 +    * [[#​varIsInUri|varIsInUri]]
  
 <note tip>To know more about the jail, check [[http://​perldoc.perl.org/​Safe.html|Safe module documentation]].</​note>​ <note tip>To know more about the jail, check [[http://​perldoc.perl.org/​Safe.html|Safe module documentation]].</​note>​
Line 160: Line 162:
 groupMatch($hGroups,​ '​description',​ '​Service 1') groupMatch($hGroups,​ '​description',​ '​Service 1')
 </​code>​ </​code>​
 +
 +==== listMatch ====
 +({{..:​new.png?​direct&​35|}} // since 2.0.7)//
 +
 +This function lets you test if a particular value can be found with a multi-valued session attribute.
 +
 +Function parameter:
 +  * **list**: Variable containing several values (plain string with separator, array or hash) 
 +  * **value**: Value to search in the list
 +  * **ignorecase**:​ Ignore case, by default the search is case-sensitive
 +
 +Simple usage example:
 +<​code>​
 +# Case sensitive match
 +listMatch($roles,​ '​role-app1'​)
 +
 +# Case insensitive match
 +listMatch($roles,​ '​RoLe-aPp1',​ 1)
 +</​code>​
 +
 +The function returns 1 if the value was found, and 0 if it was not found.
  
 ==== encrypt ==== ==== encrypt ====
Line 165: Line 188:
 <note tip>​Since version 2.0, this function is now compliant with [[safejail|Safe jail]].</​note>​ <note tip>​Since version 2.0, this function is now compliant with [[safejail|Safe jail]].</​note>​
  
-This function uses the secret key of LLNG configuration to crypt a data. This can be used to anonymize ​identifier given to the protected application.+This function uses the secret key of LLNG configuration to crypt a data. This can be used for anonymizing ​identifier given to the protected application.
  
 <​code>​ <​code>​
Line 173: Line 196:
 ==== token ==== ==== token ====
  
-This function generates token used to [[documentation:​2.0:​servertoserver|handle ​server webservice calls]].+This function generates token used for [[documentation:​2.0:​servertoserver|handling ​server webservice calls]].
  
 <​code>​ <​code>​
Line 185: Line 208:
 <code perl> <code perl>
 isInNet6($ipAddr,​ '​fe80::/​10'​) isInNet6($ipAddr,​ '​fe80::/​10'​)
 +</​code>​
 +
 +==== varIsInUri ====
 +
 +Function to check if a variable is in requested URI (Require LL::NG >= 2.0.7).
 +
 +Example //check if $uid is in /​check-auth/​ URI//:
 +
 +<code perl>
 +varIsInUri($ENV{REQUEST_URI},​ '/​check-auth/',​ $uid)
 +
 +https://​test1.example.com/​check-auth/​dwho ​    -> true
 +https://​test1.example.com/​check-auth/​dwho/​api -> true
 +https://​test1.example.com/​check-auth/​dwh ​     -> false
 +</​code>​
 +
 +* You can set "​restricted"​ flag to match exact URI:
 +
 +<code perl>
 +varIsInUri($ENV{REQUEST_URI},​ '/​check-auth/',​ "​$uid/",​ 1)
 +
 +https://​test1.example.com/​check-auth/​rtyler/ ​    -> true
 +https://​test1.example.com/​check-auth/​rtyler/​api ​ -> false
 +https://​test1.example.com/​check-auth/​rtyler ​     -> false
 </​code>​ </​code>​