User Tools

Site Tools


reference:password_strength_checking_script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
reference:password_strength_checking_script [2014/02/27 17:29] – created paulreference:password_strength_checking_script [2016/10/24 09:34] paul
Line 3: Line 3:
 You can tell VPOP3 to enforce password strength checks by using a Lua script which performs the checks for you. You can tell VPOP3 to enforce password strength checks by using a Lua script which performs the checks for you.
  
-The Lua script is stored in a file called **passwordcheck.lua** in the VPOP3 directory. VPOP3 calls a function called **Check** which should have the following prototype:+The Lua script can be edited in Settings -> Scripts and is called **passwordcheck.lua** (in older versions of VPOP3 it is stored in a file called **passwordcheck.lua** in the VPOP3 directory). VPOP3 calls a function called **Check** which should have the following prototype:
  
   Check(<username>, <password>, <min password length>)   Check(<username>, <password>, <min password length>)
Line 19: Line 19:
  else  else
   return true   return true
 + end
 +end
 +</code>
 +
 +A more complex example is:
 +<code>
 +blockedWords = {"password", "letmein", "computer"}
 +minTypes = 3
 +
 +function Check(Username, Password, minlength)
 + lowerPassword = string.lower(Password)
 + if Password == Username then
 +     return false
 + end
 +
 +  for _, value in pairs(blockedWords) do
 +    if lowerPassword == value then
 +      return false
 +    end
 +  end
 +
 + hasDigit = 0
 + hasCaps = 0
 + hasLower = 0
 + hasSpecial = 0
 + if string.find(Password, "%d") then
 +    hasDigit = 1
 + end
 + if string.find(Password, "[A-Z]") then
 +    hasCaps = 1
 + end
 + if string.find(Password, "[a-z]") then
 +     hasLower = 1
 + end
 + if string.find(Password, "[^a-zA-Z0-9]") then
 +     hasSpecial = 1
 + end
 + differentTypes = hasDigit + hasCaps + hasLower + hasSpecial
 + 
 + if differentTypes >= minTypes then
 +     return true
 + else
 +     return false
  end  end
 end end
reference/password_strength_checking_script.txt · Last modified: 2018/11/14 10:45 by 127.0.0.1