The collective.pwexpiry
package is an add-on Product for Plone that brings the
feature of controlling the password expiration in Plone. It is useful when there's
a need of forcing the portal's members to follow the specific password policy.
Add collective.pwexpiry to your plone.recipe.zope2instance section's eggs::
[instance] recipe = plone.recipe.zope2instance ... eggs = ... collective.pwexpiry
Install the Product via portal_quickinstaller.
The password's period of validity is set in the configuration registry tool, and have a default value of 90 days. It can be easily customized by creating a registry.xml file in your custom pakage's gereric setup profile containing the configuration code::
<registry>
<record name="collective.pwexpiry.validity_period">
<value>360</value>
</record>
</registry>
To disable password expiration, set validity_period
to 0
.
It's possible to check if the new password has already been used (a history of the last password_history_size
password hashes is kept).
password_history_size
defaults to 0, which means: there is no active check for re-used passwords.
You need to manualy activate that feature with a registry record in registry.xml::
<registry>
<record name="collective.pwexpiry.password_history_size">
<value>10</value>
</record>
</registry>
By default - there is a notification action defined that sends the notification email to the user when his password period of validity is going to end in 15 days. But there is a possibility to register a custom methods that would be triggered according to their implementation.
To register your own notification action you need to::
Register adapter providing IExpirationCheck
interface::
Implement the adapter's __call__
and notification_action
methods::
class LastFewDaysBeforeExpiration(object): implements(IExpirationCheck)
# Trigger on number of days before password expiration
notify_on = (7, 4, 3, 2, 1)
def __init__(self, context):
self.context = context
def __call__(self, days_to_expire):
"""
Returns True whe n the notification_action
method have to be executed
"""
try:
notify_on = iter(self.notify_on)
except TypeError:
notify_on = (self.notify_on,)
if days_to_expire in notify_on:
return True
else:
return False
def notification_action(self, userdata, days_to_expire):
"""
Implementation of the notification action.
In this case it's sendin an email notification
"""
send_notification_email(userdata, days_to_expire)
The package allows to define your own password valdation methods executed when the user set his initial password on registration or changing his actual password by in the change password form or throught the password reset mechanizm.
To register your own notification action you need to::
Register adapter providing ICustomPasswordValidator
interface::
Implement the adapter's __call__
and notification_action
methods::
class MyPasswordValidator(object): implements(ICustomPasswordValidator)
def __init__(self, context):
self.context = context
def validate(self, password, data):
if len(password) < 8:
return _(u'Passwords must be at least 8 characters in length.')
The notification script should be executed once a day to check the user's passwords expiration dates and trigger relevant notification actions.
For convenience, a new command called notify_and_expire
was added to zopectl,
you only need to provide the absolute path to your Plone instance as only argument.
Here's an example of how the script can be executed from the command line::
$ cd ${buildoout:directory}
$ ./bin/instance notify_and_expire /opt/plone/buildout/notify_and_expire.log /Plone
This assuming your Plone site id is Plone
and lives at the Zope root, and that you want to save the log in a notify_and_expire.log
file in /opt/plone/buildout
The email template will try to get the server URL and server NAME from the request,
and the notification script already puts them in there if it can find it as
environment variables. So if you want to provide users with a better email,
which includes links to reset or change the password, and a message detailing
where the email is coming from, you need to define SERVER_URL
and SERVER_NAME
environment variables.
In order to do this in buildout, you need to set your environment-vars
in your
[instance]
section.
When the package is installed, a new PAS plugin is included, which will count invalid password attempts when logging in. If the number of invalid attempts is higher than a configurable threshold, the account will be locked out for a certain amount of hours. If the account hasn't been locked yet, entering the password correctly will reset this counter to zero. An account can be re-activated by an administrator changing its password.
The collective.pwexpiry
package creates new user's properties:
password_date
- the date when the user has changed his passowordlast_notification_date
- the date when the last notification action has been performed for the useraccount_locked_date
- the date when the account was lockedaccount_locked
- boolean telling if the account was locked or notpassword_tries
- the number of incorrect password attemptsIn order to be able to control manually the new user's properties manually - there's a
control panel form available under url: /@@pwexpiry-controlpanel
.
This is managed with values in the registry:
collective.pwexpiry.allowed_tries
- Allows you to choose how many attempts are allowedcollective.pwexpiry.disable_time
- Allows you to specify for how many hours the user should be locked out:Author:
radoslaw.jankiewicz@stxnext.pl
This package is licensed under the Zope Public License.
.. _Plone 4.2
: http://pypi.python.org/pypi/Plone/4.2