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/09/29 23:01]
cmaudoux [token]
documentation:latest:extendedfunctions [2020/04/16 15:12] (current)
maxbes inGroup doc
Line 26: Line 26:
     * [[#​iso2unicode|iso2unicode]]     * [[#​iso2unicode|iso2unicode]]
     * [[#​groupMatch|groupMatch]]     * [[#​groupMatch|groupMatch]]
 +    * [[#​listMatch|listMatch]] ({{..:​new.png?​direct&​35|}} // since 2.0.7)//
 +    * [[#​inGroup|inGroup]] ({{..:​new.png?​direct&​35|}} // since 2.0.8)//
     * [[#​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 163:
 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.
 +
 +==== inGroup ====
 +({{..:​new.png?​direct&​35|}} // since 2.0.8)//
 +
 +This function lets you test if the user is in a given group. It is case-insensitive.
 +
 +Usage example:
 +<​code>​
 +inGroup('​admins'​)
 +
 +inGroup('​test users'​)
 +</​code>​
 +
 +The function returns 1 if the user belongs to the given group, and 0 if they don't.
  
 ==== encrypt ==== ==== encrypt ====
Line 185: Line 223:
 <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>​