Recommend this page to a friend! |
Classes of Cyril Ogana | PHP User Credentials | README.md | Download |
|
DownloadPHP USERCREDENTIALSThis package can implement password authentication and policy management. It can perform several types of check to evaluate if user passwords and authentication procedures comply with security recommendations DescriptionThe PHP UserCredential Package is a pluggable service that enables one to validate passwords and policy. It validates against a set of password policies as recommended by OWASP best practice guidelines for Web applications. The package also provides an Interface that allows plugging in 3rd party libraries, particularly for Multi Factor Authentication methods. To Illustrate how, we have plugged in MultiOTP library (https://github.com/multiOTP/multiotp) for the SMS OTP and Google Authenticator TOTP services that we have provided with this package. InstallingInstall application via Composer
UsageOverviewThis package is intended for PHP applications which use Password for authentication and are required to maintain a User Credential policy of sorts. We also offer Multi Factor authentication services which utilize the MultiOTP Library. The objectives of the Package are
Implementation of OWASP GuidlinesAll authentication controls should fail securely:* The Service is not intrusive. A UserProfile is provided to the service and it does not intervene unless it encounters an issue with the authentication or policy at which point it throws a UserCredentialException, which should then be handled Enforce password complexity requirements established by policy or regulation. Authentication credentials should be sufficient to withstand attacks that are typical of the threats in the deployed environment. (e.g., requiring the use of alphabetic as well as numeric and/or special characters):The service has a method for implementing user defined policy based on length and complexity. However, it does not let one set a Weak policy as it compares the User defined policy to the built in base policy, and if the User defined policy is weak e.g. If Password length is 5 characters in user defined policy, it will fall back to the base (8 characters as per OWASP).NB: Falling back to be introduced and is not yet implemented.* Enforce password length requirements established by policy or regulation. Eight characters is commonly used, but 16 is better or consider the use of multi-word pass phrases:* See previous point Enforce account disabling after an established number of invalid login attempts (e.g., five attempts is common). The account must be disabled for a period of time sufficient to discourage brute force guessing of credentials, but not so long as to allow for a denial-of-service attack to be performed:* The service locks the account temporarily (10 minutes in base policy) for repeated attempts. After 10 minutes, the user may successfully log in with the correct password. However, if at any time after this the User provides another wrong password, the service locks the account indefinitely which will require admin intervention to unlock Enforce the changing of temporary passwords on the next use:* The service will recommend/enforce password change on next attempted login when using a weak password Prevent password re-use:* The service can support this. By default the last 5 passwords are not allowed to be repeated. User defined policy can increase this. We have seen up to 12 previous passwords being used in some environments. Enforce password changes based on requirements established in policy or regulation. Critical systems may require more frequent changes. The time between resets must be administratively controlled:* The service has a default expiry period for passwords of 45 days. A stronger User Defined Policy (e.g. 30 days) can be set using the User defined policy methods. Use MultiFactor Authentication for highly sensitive or high value transactional accounts* The service implements an Interface that can allow for Multi-Factor authentication. Using the PackageNamed Constants
Building Your User's Profile* This service is decoupled from backend store of user and auth info. It will need an array of the userProfile, which you should build and provide to the Service. Sample User Profile
Authenticating A UserThe service comes with 3 Password Authenticating Services which you can Choose From. A Wiki for using each of the services as well as on implementing password policy is in the pipeline. This article here http://bit.ly/29m2aWL that explains using a DB as a backend store might assist with getting started on using the package. Check the test file for these services for some documentation on their workings. UserCredentialPasswordLoginServiceThis service does password authentication only. To use this service, you will need to plug it in to the authentication Framework / Plugin that you are using. UserCredentialSmsTokenLoginServiceThis service generates Tokens which are sent to the mobile number or email that is mapped to the user. This class extends UserCredentialPasswordLoginService which performs the first step of the authentication. UserCredentialGoogleAuthLoginServiceThis service generates TOTP tokens which change in intervals of 30 seconds. Thus, these can support Google Authenticator. This class extends UserCredentialPasswordLoginService which performs the first step of the authentication. Enforcing Password Policy After Authenticating
Enforcing Password Policy During Sessions* Usage during sessions is as above, except you cannot use validateEntropy() etc .... only validatePolicy() e.g on accessing a resource it may calculate that the 45 days have elapsed and throw exception requiring password change Verifying Password Strength with PhpassThe strength checker method is static, to allow for usage without needing instantiation of the UserCredentialManager class. Thus, it can also be used in assisting users when they are changing passwords or setting up new passwords.
TestingPHPUnit Tests are provided with the package Contribute
LicenseBSD 3 CLAUSE |