[Checkins] SVN: Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/ Add IUpdateLoginNamePlugin plugin interface.
Maurits van Rees
cvs-admin at zope.org
Fri Jan 4 12:32:12 UTC 2013
Log message for revision 129012:
Add IUpdateLoginNamePlugin plugin interface.
Changed:
U Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/PluggableAuthService.py
U Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/interfaces/authservice.py
U Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/interfaces/plugins.py
U Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/plugins/ZODBUserManager.py
-=-
Modified: Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/PluggableAuthService.py
===================================================================
--- Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/PluggableAuthService.py 2013-01-04 10:05:13 UTC (rev 129011)
+++ Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/PluggableAuthService.py 2013-01-04 12:32:12 UTC (rev 129012)
@@ -56,6 +56,7 @@
from .interfaces.plugins import IGroupsPlugin
from .interfaces.plugins import IRolesPlugin
from .interfaces.plugins import IUpdatePlugin
+from .interfaces.plugins import IUpdateLoginNamePlugin
from .interfaces.plugins import IValidationPlugin
from .interfaces.plugins import IUserEnumerationPlugin
from .interfaces.plugins import IUserAdderPlugin
@@ -1248,6 +1249,57 @@
for resetter_id, resetter in cred_resetters:
resetter.resetCredentials(request, response)
+
+ security.declareProtected( ManageUsers, 'updateLoginName')
+ def updateLoginName(self, user_id, login_name):
+ """Update login name of user.
+ """
+ logger.info("Called updateLoginName, user_id=%r, login_name=%r",
+ user_id, login_name)
+ login_name = self.applyTransform(login_name)
+ user = self.getUserById(user_id)
+ if user is None:
+ return
+ if user.getUserName() == login_name:
+ logger.info("login name is the same: %r", login_name)
+ plugins = self._getOb('plugins')
+ updaters = plugins.listPlugins(IUpdateLoginNamePlugin)
+
+ for updater_id, updater in updaters:
+ try:
+ updater.updateUser(user_id, login_name)
+ except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
+ reraise(updater)
+ logger.debug('UpdateLoginNamePlugin %s error' % updater_id,
+ exc_info=True)
+
+ security.declarePublic('updateOwnLoginName')
+ def updateOwnLoginName(self, login_name):
+ """Update own login name of authenticated user.
+ """
+ logger.info("Called updateOwnLoginName, login_name=%r", login_name)
+ login_name = self.applyTransform(login_name)
+ user = getSecurityManager().getUser()
+ if aq_base(user) is nobody:
+ return
+ if user.getUserName() == login_name:
+ logger.info("login name is the same: %r", login_name)
+ return
+ user_id = user.getId()
+ plugins = self._getOb('plugins')
+ updaters = plugins.listPlugins(IUpdateLoginNamePlugin)
+ logger.info('UpdateLoginNamePlugins: %r', updaters)
+ for updater_id, updater in updaters:
+ try:
+ updater.updateUser(user_id, login_name)
+ except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
+ reraise(updater)
+ logger.debug('UpdateLoginNamePlugin %s error' % updater_id,
+ exc_info=True)
+ else:
+ logger.info("login name changed to: %r", login_name)
+
+
classImplements( PluggableAuthService
, (IPluggableAuthService, IObjectManager, IPropertyManager)
)
@@ -1344,6 +1396,11 @@
, "Update plugins allow the user or the application to update "
"the user's properties."
)
+ , ( IUpdateLoginNamePlugin
+ , 'IUpdateLoginNamePlugin'
+ , 'update_login_name'
+ , "Login name updater plugins allow to set a new login name for a user."
+ )
, ( IValidationPlugin
, 'IValidationPlugin'
, 'validation'
Modified: Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/interfaces/authservice.py
===================================================================
--- Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/interfaces/authservice.py 2013-01-04 10:05:13 UTC (rev 129011)
+++ Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/interfaces/authservice.py 2013-01-04 12:32:12 UTC (rev 129012)
@@ -210,11 +210,20 @@
default implementation redirects to HTTP_REFERER).
"""
- def resetCredentials(self, request, response):
+ def resetCredentials(request, response):
"""Reset credentials by informing all active resetCredentials
plugins
"""
+ def updateLoginName(user_id, login_name):
+ """Update login name of user.
+ """
+
+ def updateOwnLoginName(login_name):
+ """Update own login name of authenticated user.
+ """
+
+
# The IMutableUserFolder and IEnumerableFolder are not supported
# out-of-the-box by the pluggable authentication service. These
# interfaces describe contracts that other standard Zope user folders
Modified: Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/interfaces/plugins.py
===================================================================
--- Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/interfaces/plugins.py 2013-01-04 10:05:13 UTC (rev 129011)
+++ Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/interfaces/plugins.py 2013-01-04 12:32:12 UTC (rev 129012)
@@ -267,6 +267,16 @@
""" Update backing store for 'set_id' using 'set_info'.
"""
+class IUpdateLoginNamePlugin( Interface ):
+
+ """ Update the login name of a user.
+ """
+
+ def updateUser( user_id, login_name ):
+ """ Update the login name of the user with id user_id.
+ """
+
+
class IValidationPlugin( Interface ):
""" Specify allowable values for user properties.
Modified: Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/plugins/ZODBUserManager.py
===================================================================
--- Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/plugins/ZODBUserManager.py 2013-01-04 10:05:13 UTC (rev 129011)
+++ Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/plugins/ZODBUserManager.py 2013-01-04 12:32:12 UTC (rev 129012)
@@ -38,6 +38,8 @@
import IUserEnumerationPlugin
from Products.PluggableAuthService.interfaces.plugins \
import IUserAdderPlugin
+from Products.PluggableAuthService.interfaces.plugins \
+ import IUpdateLoginNamePlugin
from Products.PluggableAuthService.permissions import ManageUsers
from Products.PluggableAuthService.permissions import SetOwnPassword
@@ -554,6 +556,7 @@
, IAuthenticationPlugin
, IUserEnumerationPlugin
, IUserAdderPlugin
+ , IUpdateLoginNamePlugin
)
InitializeClass( ZODBUserManager )
More information about the checkins
mailing list