[Zope-CVS] CVS: Products/PluggableAuthService -
PluggableAuthService.py:1.29.2.1.2.1 __init__.py:1.6.4.1
Sidnei da Silva
sidnei at enfoldsystems.com
Sat Aug 13 00:35:03 EDT 2005
Update of /cvs-repository/Products/PluggableAuthService
In directory cvs.zope.org:/tmp/cvs-serv7291
Modified Files:
Tag: sidnei-challenge-protocol-chooser
PluggableAuthService.py __init__.py
Log Message:
- Implement Challenge Protocol Chooser, with functional doctests
=== Products/PluggableAuthService/PluggableAuthService.py 1.29.2.1 => 1.29.2.1.2.1 ===
--- Products/PluggableAuthService/PluggableAuthService.py:1.29.2.1 Wed Feb 23 09:57:59 2005
+++ Products/PluggableAuthService/PluggableAuthService.py Sat Aug 13 00:34:32 2005
@@ -65,6 +65,8 @@
from interfaces.plugins import IGroupEnumerationPlugin
from interfaces.plugins import IRoleEnumerationPlugin
from interfaces.plugins import IRoleAssignerPlugin
+from interfaces.plugins import IChallengeProtocolChooser
+from interfaces.plugins import IRequestTypeSniffer
from permissions import SearchPrincipals
@@ -989,8 +991,19 @@
resp._has_challenged = True
def challenge(self, request, response):
- # Go through all challenge plugins
plugins = self._getOb('plugins')
+
+ # Find valid protocols for this request type
+ valid_protocols = []
+ choosers = plugins.listPlugins( IChallengeProtocolChooser )
+
+ for chooser_id, chooser in choosers:
+ choosen = chooser.chooseProtocols(request)
+ if choosen is None:
+ continue
+ valid_protocols.extend(choosen)
+
+ # Go through all challenge plugins
challengers = plugins.listPlugins( IChallengePlugin )
protocol = None
@@ -998,6 +1011,9 @@
for challenger_id, challenger in challengers:
challenger_protocol = getattr(challenger, 'protocol',
challenger_id)
+ if valid_protocols and challenger_protocol not in valid_protocols:
+ # Skip invalid protocol for this request type.
+ continue
if protocol is None or protocol == challenger_protocol:
if challenger.challenge(request, response):
protocol = challenger_protocol
@@ -1171,6 +1187,17 @@
, 'role_assigner'
, "Role Assigner plugins allow the Pluggable Auth Service to assign"
" roles to principals."
+ )
+ , ( IChallengeProtocolChooser
+ , 'IChallengeProtocolChooser'
+ , 'challenge_protocol_chooser'
+ , "Challenge Protocol Chooser plugins decide what authorization"
+ "protocol to use for a given request type."
+ )
+ , ( IRequestTypeSniffer
+ , 'IRequestTypeSniffer'
+ , 'request_type_sniffer'
+ , "Request Type Sniffer plugins detect the type of an incoming request."
)
)
=== Products/PluggableAuthService/__init__.py 1.6 => 1.6.4.1 ===
--- Products/PluggableAuthService/__init__.py:1.6 Thu Jan 27 14:00:22 2005
+++ Products/PluggableAuthService/__init__.py Sat Aug 13 00:34:32 2005
@@ -43,6 +43,8 @@
from plugins import SearchPrincipalsPlugin as SPP
from plugins import RecursiveGroupsPlugin as RGP
from plugins import DynamicGroupsPlugin as DGP
+from plugins import ChallengeProtocolChooser as CPC
+from plugins import RequestTypeSniffer as RTS
registerMultiPlugin(HBAH.HTTPBasicAuthHelper.meta_type)
registerMultiPlugin(IAH.InlineAuthHelper.meta_type)
@@ -58,6 +60,8 @@
registerMultiPlugin(SPP.SearchPrincipalsPlugin.meta_type)
registerMultiPlugin(RGP.RecursiveGroupsPlugin.meta_type)
registerMultiPlugin(DGP.DynamicGroupsPlugin.meta_type)
+registerMultiPlugin(CPC.ChallengeProtocolChooser.meta_type)
+registerMultiPlugin(RTS.RequestTypeSniffer.meta_type)
# monkey patch Zope to cause zmi logout to be PAS-aware
from App.Management import Navigation
@@ -224,4 +228,22 @@
DGP.addDynamicGroupsPlugin, )
, visibility=None
, icon='plugins/www/DynamicGroupsPlugin.png'
+ )
+
+ context.registerClass( CPC.ChallengeProtocolChooser
+ , permission=ManageUsers
+ , constructors=(
+ CPC.manage_addChallengeProtocolChooserForm,
+ CPC.addChallengeProtocolChooserPlugin, )
+ , visibility=None
+ , icon='plugins/www/DelegatingMultiPlugin.png'
+ )
+
+ context.registerClass( RTS.RequestTypeSniffer
+ , permission=ManageUsers
+ , constructors=(
+ RTS.manage_addRequestTypeSnifferForm,
+ RTS.addRequestTypeSnifferPlugin, )
+ , visibility=None
+ , icon='plugins/www/DelegatingMultiPlugin.png'
)
More information about the Zope-CVS
mailing list