Commits

ianb  committed b98d603

Patch from Brad Clements to add Paste Deploy support for paste.auth methods

  • Participants
  • Parent commits 12bf77d

Comments (0)

Files changed (4)

File paste/auth/basic.py

 
 __all__ = ['AuthBasicHandler']
 
+def make_basic(app, global_conf, realm, authfunc, **kw):
+    """
+    Grant access via basic authentication
+
+    Config looks like this::
+
+      [filter:grant]
+      use = egg:Paste#auth_basic
+      realm=myrealm
+      authfunc=somepackage.somemodule:somefunction
+      
+    """
+    from paste.util.import_string import eval_import
+    import types
+    authfunc = eval_import(authfunc)
+    assert isinstance(authfunc, types.FunctionType), "authfunc must resolve to a function"
+    return AuthBasicHandler(app, realm, authfunc)
+    
+
 if "__main__" == __name__:
     import doctest
     doctest.testmod(optionflags=doctest.ELLIPSIS)

File paste/auth/digest.py

 
 __all__ = ['digest_password', 'AuthDigestHandler' ]
 
+def make_digest(app, global_conf, realm, authfunc, **kw):
+    """
+    Grant access via digest authentication
+
+    Config looks like this::
+
+      [filter:grant]
+      use = egg:Paste#auth_digest
+      realm=myrealm
+      authfunc=somepackage.somemodule:somefunction
+      
+    """
+    from paste.util.import_string import eval_import
+    import types
+    authfunc = eval_import(authfunc)
+    assert isinstance(authfunc, types.FunctionType), "authfunc must resolve to a function"
+    return AuthDigestHandler(app, realm, authfunc)
+
 if "__main__" == __name__:
     import doctest
     doctest.testmod(optionflags=doctest.ELLIPSIS)

File paste/auth/form.py

 
 __all__ = ['AuthFormHandler']
 
+def make_form(app, global_conf, realm, authfunc, **kw):
+    """
+    Grant access via form authentication
+
+    Config looks like this::
+
+      [filter:grant]
+      use = egg:Paste#auth_form
+      realm=myrealm
+      authfunc=somepackage.somemodule:somefunction
+      
+    """
+    from paste.util.import_string import eval_import
+    import types
+    authfunc = eval_import(authfunc)
+    assert isinstance(authfunc, types.FunctionType), "authfunc must resolve to a function"
+    return AuthFormHandler(app, realm, authfunc)
+
 if "__main__" == __name__:
     import doctest
     doctest.testmod(optionflags=doctest.ELLIPSIS)
       wdg_validate = paste.debug.wdg_validate:WDGValidateMiddleware [subprocess]
       evalerror = paste.evalexception:EvalException
       auth_tkt = paste.auth.auth_tkt:make_auth_tkt_middleware
+      auth_basic = paste.auth.basic:make_basic
+      auth_digest = paste.auth.digest:make_digest
+      auth_form = paste.auth.form:make_form
       grantip = paste.auth.grantip:make_grantip
       openid = paste.auth.open_id:make_open_id_middleware [openid]
       recorder = paste.debug.recorder.record:make_recorder