Hash: SHA1

On 04/13/2012 10:58 AM, Jim Carroll wrote:

> Hi, I'm struggling a bit to get rid of the friendly form identifier 
> and challenger, and do my own Authenticator in a turbogears 2.1 
> project.
> I've got a 'faceless' web services server that won't even have a
> login form, since no human will ever visit the site.  So I want to
> retain the session cookie mechanism, and the sa_auth module that uses
> the default Group, User, and Permission model in SQL Alchemy.  I just
> am going to do my own Authentication, and get rid of the Challenger.

Are you "authenticating" clients based on the subnet, or something?
Otherwise you need a chellenger of some sort.  Note that you may still
need some kind of challenger to cope with requests which come from
"hostile" / random sources.

> So far I've implemented an IAuthenticator
> class ShaAuthenticator(IAuthenticator): #implements(IAuthenticator)
> def authenticate(self, environment, identity):
> if not 'user_email' in identity: return None ...
> and in app_cfg.py
> hash_auth = ShaAuthenticator base_config.sa_auth.authenticators = 
> [('hash_auth', hash_auth)]
> # got rid of the challenger base_config.sa_auth.form_plugin = None
> #and am keeping base_config.auth_backend = 'sqlalchemy' 
> base_config.sa_auth.dbsession = model.DBSession
> If I try to run at the moment I see:
> ValueError: hash_auth: An object has failed to implement interface 
> <InterfaceClass repoze.who.interfaces.IAuthenticator>
> The authenticate attribute was not provided.
> I didn't find much help on the turbogears google group, I'm hoping 
> someone might be able to point me in the right direction here. 
> Thanks,

I'm not quite sure what else might be going on, but I do see that you
haven't created an instance of ShaAuthenticator.  You have also commented
out the 'implements' class advisor.

FWIW, I ususally have unit tests like the following for classes that are
supposed to implement a given interface::

 class MyObjTests(unittest.TestCase):

     def _getTargetClass(self):
         from mypackage.myobj import MyObj
         return MyObj

     def _makeOne(self, *args, **kw):
         return self._getTargetClass()(*args, **kw)

     def test_class_conforms_to_IFoo(self):
         from zope.interface.verify import verifyClass
         from whatever.package.interfaces import IFoo
         verifyClass(IFoo, self._getTargetClass()

     def test_instance_conforms_to_IFoo(self):
         from zope.interface.verify import verifyObject
         from whatever.package.interfaces import IFoo
         verifyObject(IFoo, self._makeOne())

- -- 
Tres Seaver          +1 540-429-0999          tsea...@palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

Repoze-dev mailing list

Reply via email to