class IInternalPrincipal(interface.Interface): """Principal information""" login = TextLine(title=_("Login"), description=_("The Login/Username of the principal. " "This value can change.")) def setPassword(password, passwordManagerName=None): pass password = Password(title=_("Password"), description=_("The password for the principal.")) passwordManagerName = Choice( title=_("Password Manager"), vocabulary="Password Manager Names", description=_("The password manager will be used" " for encode/check the password"), default="Plain Text", # TODO: The password manager name may be changed only # if the password changed readonly=True) title = TextLine(title=_("Title"), description=_("Provides a title for the principal.")) description = Text( title=_("Description"), description=_("Provides a description for the principal."), required=False, missing_value='', default=u'')
class ISearchSchema(interface.Interface): """Search Interface for this Principal Provider""" search = TextLine(title=_("Search String"), description=_("A Search String"), required=False, default=u'', missing_value=u'')
class IPluggableAuthentication(ILogout, IContainer): """Provides authentication services with the help of various plugins. IPluggableAuthentication implementations will also implement zope.app.security.interfaces.IAuthentication. The `authenticate` method of this interface in an IPluggableAuthentication should annotate the IPrincipalInfo with the credentials plugin and authentication plugin used. The `getPrincipal` method should annotate the IPrincipalInfo with the authentication plugin used. """ contains(IPlugin) credentialsPlugins = zope.schema.List( title=_('Credentials Plugins'), description=_("""Used for extracting credentials. Names may be of ids of non-utility ICredentialsPlugins contained in the IPluggableAuthentication, or names of registered ICredentialsPlugins utilities. Contained non-utility ids mask utility names."""), value_type=zope.schema.Choice(vocabulary='CredentialsPlugins'), default=[], ) authenticatorPlugins = zope.schema.List( title=_('Authenticator Plugins'), description=_("""Used for converting credentials to principals. Names may be of ids of non-utility IAuthenticatorPlugins contained in the IPluggableAuthentication, or names of registered IAuthenticatorPlugins utilities. Contained non-utility ids mask utility names."""), value_type=zope.schema.Choice(vocabulary='AuthenticatorPlugins'), default=[], ) def getCredentialsPlugins(): """Return iterable of (plugin name, actual credentials plugin) pairs. Looks up names in credentialsPlugins as contained ids of non-utility ICredentialsPlugins first, then as registered ICredentialsPlugin utilities. Names that do not resolve are ignored.""" def getAuthenticatorPlugins(): """Return iterable of (plugin name, actual authenticator plugin) pairs. Looks up names in authenticatorPlugins as contained ids of non-utility IAuthenticatorPlugins first, then as registered IAuthenticatorPlugin utilities. Names that do not resolve are ignored.""" prefix = zope.schema.TextLine( title=_('Prefix'), default=u'', required=True, readonly=True, ) def logout(request): """Performs a logout by delegating to its authenticator plugins."""
class IPrincipal(zope.security.interfaces.IGroupClosureAwarePrincipal): groups = zope.schema.List( title=_("Groups"), description=_("""ids of groups to which the principal directly belongs. Plugins may append to this list. Mutating the list only affects the life of the principal object, and does not persist (so persistently adding groups to a principal should be done by working with a plugin that mutates this list every time the principal is created, like the group folder in this package.) """), value_type=zope.schema.TextLine(), required=False)
class IGroupFolder(zope.app.container.interfaces.IContainer): zope.app.container.constraints.contains(IGroupInformation) prefix = schema.TextLine( title=_("Group ID prefix"), description=_("Prefix added to IDs of groups in this folder"), readonly=True, ) def getGroupsForPrincipal(principalid): """Get groups the given principal belongs to""" def getPrincipalsForGroup(groupid): """Get principals which belong to the group"""
def checkName(self, name, object): """Limit ids Ids can only contain printable, non-space, 7-bit ASCII strings: >>> from zope.app.authentication.idpicker import IdPicker >>> IdPicker({}).checkName(u'1', None) True >>> IdPicker({}).checkName(u'bob', None) True >>> IdPicker({}).checkName(u'bob\xfa', None) ... # doctest: +NORMALIZE_WHITESPACE Traceback (most recent call last): ... UserError: Ids must contain only printable 7-bit non-space ASCII characters >>> IdPicker({}).checkName(u'big bob', None) ... # doctest: +NORMALIZE_WHITESPACE Traceback (most recent call last): ... UserError: Ids must contain only printable 7-bit non-space ASCII characters Ids also can't be over 100 characters long: >>> IdPicker({}).checkName(u'x' * 100, None) True >>> IdPicker({}).checkName(u'x' * 101, None) Traceback (most recent call last): ... UserError: Ids can't be more than 100 characters long. """ NameChooser.checkName(self, name, object) if not ok(name): raise UserError( _("Ids must contain only printable 7-bit non-space" " ASCII characters") ) if len(name) > 100: raise UserError( _("Ids can't be more than 100 characters long.") ) return True
class IGroupSearchCriteria(interface.Interface): search = schema.TextLine( title=_("Group Search String"), required=False, missing_value=u'', )
def checkName(self, name, object): """Limit ids Ids can only contain printable, non-space, 7-bit ASCII strings: >>> from zope.app.authentication.idpicker import IdPicker >>> IdPicker({}).checkName(u'1', None) True >>> IdPicker({}).checkName(u'bob', None) True >>> IdPicker({}).checkName(u'bob\xfa', None) ... # doctest: +NORMALIZE_WHITESPACE Traceback (most recent call last): ... UserError: Ids must contain only printable 7-bit non-space ASCII characters >>> IdPicker({}).checkName(u'big bob', None) ... # doctest: +NORMALIZE_WHITESPACE Traceback (most recent call last): ... UserError: Ids must contain only printable 7-bit non-space ASCII characters Ids also can't be over 100 characters long: >>> IdPicker({}).checkName(u'x' * 100, None) True >>> IdPicker({}).checkName(u'x' * 101, None) Traceback (most recent call last): ... UserError: Ids can't be more than 100 characters long. """ NameChooser.checkName(self, name, object) if not ok(name): raise UserError( _("Ids must contain only printable 7-bit non-space" " ASCII characters")) if len(name) > 100: raise UserError(_("Ids can't be more than 100 characters long.")) return True
class IInternalPrincipalContainer(interface.Interface): """A container that contains internal principals.""" prefix = TextLine( title=_("Prefix"), description=_( "Prefix to be added to all principal ids to assure " "that all ids are unique within the authentication service"), missing_value=u"", default=u'', readonly=True) def getIdByLogin(login): """Return the principal id currently associated with login. The return value includes the container prefix, but does not include the PAU prefix. KeyError is raised if no principal is associated with login. """ contains(IInternalPrincipal)
class IGroupInformation(interface.Interface): title = schema.TextLine( title=_("Title"), description=_("Provides a title for the permission."), required=True) description = schema.Text( title=_("Description"), description=_("Provides a description for the permission."), required=False) principals = schema.List( title=_("Principals"), value_type=schema.Choice( source=zope.app.security.vocabulary.PrincipalSource()), description=_( "List of ids of principals which belong to the group"), required=False)
class AddAuthenticationRegistration( zope.app.component.browser.registration.AddUtilityRegistration, ): label = _("Register a pluggable authentication utility") name = '' provided = zope.app.security.interfaces.IAuthentication
$Id$ """ __docformat__ = "reStructuredText" from zope.app.authentication.i18n import ZopeMessageFactory as _ from zope.formlib.interfaces import IInputWidget, InputErrors from zope.formlib.interfaces import ISourceQueryView from zope.formlib.interfaces import WidgetsError, MissingInputError from zope.formlib.utility import setUpWidgets from zope.i18n import translate from zope.interface import implements from zope.schema import getFieldsInOrder from zope.traversing.api import getName, getPath search_label = _('search-button', 'Search') source_label = _(u"Source path") source_title = _(u"Path to the source utility") class QuerySchemaSearchView(object): implements(ISourceQueryView) def __init__(self, context, request): self.context = context self.request = request def render(self, name): schema = self.context.schema sourcename = getName(self.context) sourcepath = getPath(self.context) setUpWidgets(self, schema, IInputWidget, prefix=name+'.field')
This vocabulary provides terms for authentication utility plugins. $Id: vocabulary.py 73548 2007-03-25 09:05:22Z dobe $ """ __docformat__ = "reStructuredText" import zope.dublincore.interfaces from zope import interface, component, i18n from zope.schema import vocabulary from zope.schema.interfaces import IVocabularyFactory from zope.app.authentication.i18n import ZopeMessageFactory as _ from zope.app.authentication import interfaces UTILITY_TITLE = _('zope.app.authentication.vocabulary-utility-plugin-title', '${name} (a utility)') CONTAINED_TITLE = _( 'zope.app.authentication.vocabulary-contained-plugin-title', '${name} (in contents)') MISSING_TITLE = _('zope.app.authentication.vocabulary-missing-plugin-title', '${name} (not found; deselecting will remove)') def _pluginVocabulary(context, interface, attr_name): """Vocabulary that provides names of plugins of a specified interface. Given an interface, the options should include the unique names of all of the plugins that provide the specified interface for the current context-- which is expected to be a pluggable authentication utility, hereafter referred to as a PAU).
"""Search interface for queriables. $Id: schemasearch.py 73548 2007-03-25 09:05:22Z dobe $ """ __docformat__ = "reStructuredText" from zope.interface import implements from zope.i18n import translate from zope.schema import getFieldsInOrder from zope.app.zapi import getName, getPath from zope.app.form.utility import setUpWidgets, getWidgetsData from zope.app.form.interfaces import IInputWidget from zope.app.form.browser.interfaces import ISourceQueryView from zope.app.authentication.i18n import ZopeMessageFactory as _ search_label = _('search-button', 'Search') source_label = _(u"Source path") source_title = _(u"Path to the source utility") class QuerySchemaSearchView(object): implements(ISourceQueryView) def __init__(self, context, request): self.context = context self.request = request def render(self, name): schema = self.context.schema sourcename = getName(self.context) sourcepath = getPath(self.context)
$Id$ """ __docformat__ = "reStructuredText" import zope.dublincore.interfaces from zope import interface, component, i18n from zope.schema import vocabulary from zope.schema.interfaces import IVocabularyFactory from zope.app.authentication.i18n import ZopeMessageFactory as _ from zope.pluggableauth import interfaces UTILITY_TITLE = _( 'zope.app.authentication.vocabulary-utility-plugin-title', '${name} (a utility)') CONTAINED_TITLE = _( 'zope.app.authentication.vocabulary-contained-plugin-title', '${name} (in contents)') MISSING_TITLE = _( 'zope.app.authentication.vocabulary-missing-plugin-title', '${name} (not found; deselecting will remove)') def _pluginVocabulary(context, interface, attr_name): """Vocabulary that provides names of plugins of a specified interface. Given an interface, the options should include the unique names of all of the plugins that provide the specified interface for the current context-- which is expected to be a pluggable authentication utility, hereafter referred to as a PAU).