summaryrefslogtreecommitdiff
path: root/paste/auth/multi.py
diff options
context:
space:
mode:
authorcce <devnull@localhost>2005-12-30 22:24:56 +0000
committercce <devnull@localhost>2005-12-30 22:24:56 +0000
commit99f6ac00dace34f66a6fc0e64189909ee5483390 (patch)
treebbf5dc84590dcc22dc75ddda17b1f4475908f8f6 /paste/auth/multi.py
parent2a9484240e705b3844d9a8beb48219843bb4c534 (diff)
downloadpaste-99f6ac00dace34f66a6fc0e64189909ee5483390.tar.gz
- fixes for restructed text
Diffstat (limited to 'paste/auth/multi.py')
-rw-r--r--paste/auth/multi.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/paste/auth/multi.py b/paste/auth/multi.py
index 2fe3ba6..f3370b9 100644
--- a/paste/auth/multi.py
+++ b/paste/auth/multi.py
@@ -3,12 +3,12 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php
# This code was written with funding by http://prometheusresearch.com
"""
-Multi Authentication
+Authentication via Multiple Methods
In some environments, the choice of authentication method to be used
-depends upon the environment and is not "fixed". This middleware
-allows N authentication methods to be registered along with a goodness
-function which determines which method should be used.
+depends upon the environment and is not "fixed". This middleware allows
+N authentication methods to be registered along with a goodness function
+which determines which method should be used.
Strictly speaking this is not limited to authentication, but it is a
common requirement in that domain; this is why it isn't named
@@ -16,12 +16,18 @@ AuthMultiHandler (for now).
"""
class MultiHandler:
- """ This middleware provides two othogonal facilities:
- (a) a way to register any number of middlewares
- (b) a way to register predicates which cause one of
- the registered middlewares to be used
- If none of the predicates returns True, then the
- application is invoked directly without middleware
+ """
+ Multiple Authentication Handler
+
+ This middleware provides two othogonal facilities:
+
+ - a manner to register any number of authentication middlewares
+
+ - a mechanism to register predicates which cause one of the
+ registered middlewares to be used depending upon the request
+
+ If none of the predicates returns True, then the application is
+ invoked directly without middleware
"""
def __init__(self, application):
self.application = application
@@ -33,16 +39,10 @@ class MultiHandler:
def add_predicate(self, name, checker):
self.predicate.append((checker,self.binding[name]))
def set_default(self, name):
- """
- This method sets the default middleware to be executed,
- if none of the rules apply.
- """
+ """ set default authentication method """
self.default = self.binding[name]
def set_query_argument(self, name, key = '*authmeth', value = None):
- """
- This method indicates that the named middleware component should
- be executed if the given key/value pair occurs in the query args.
- """
+ """ choose authentication method based on a query argument """
lookfor = "%s=%s" % (key, value or name)
self.add_predicate(name,
lambda environ: lookfor in environ.get('QUERY_STRING',''))