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/11/05 20:20]
cmaudoux [varIsInUri]
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]]
Line 161: 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 190: Line 212:
 ==== varIsInUri ==== ==== varIsInUri ====
  
-Function to check if a variable is in requested URI. Example //check if $uid is in /​check-auth ​URI///:+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> <code perl>
 varIsInUri($ENV{REQUEST_URI},​ '/​check-auth/',​ $uid) varIsInUri($ENV{REQUEST_URI},​ '/​check-auth/',​ $uid)
  
-https://​test1.example.com/​check-auth/​dwho -> true+https://​test1.example.com/​check-auth/​dwho ​    ​-> true
 https://​test1.example.com/​check-auth/​dwho/​api -> true https://​test1.example.com/​check-auth/​dwho/​api -> true
-https://​test1.example.com/​check-auth/​dwh -> false+https://​test1.example.com/​check-auth/​dwh ​     -> false
 </​code>​ </​code>​
  
-You can set "​restricted"​ flag to match exact URI:+You can set "​restricted"​ flag to match exact URI:
  
 <code perl> <code perl>
 varIsInUri($ENV{REQUEST_URI},​ '/​check-auth/',​ "​$uid/",​ 1) varIsInUri($ENV{REQUEST_URI},​ '/​check-auth/',​ "​$uid/",​ 1)
  
-https://​test1.example.com/​check-auth/​rtyler/​ -> true +https://​test1.example.com/​check-auth/​rtyler/ ​    ​-> true 
-https://​test1.example.com/​check-auth/​dwho/api -> false +https://​test1.example.com/​check-auth/​rtyler/api  -> false 
-https://​test1.example.com/​check-auth/​dwh -> false+https://​test1.example.com/​check-auth/​rtyler ​     ​-> false
 </​code>​ </​code>​