2008/11/25 Dalius Dobravolskas <[EMAIL PROTECTED]>:
>
>> By the way, you can set the repoze.who cookie name to wathever you want.
> That's OK. Problem is different.
>
>> The only complication is that you must say "hey, my class is an
>> authentifier". Is it really complicated ?
> There is more actually. I need to understand what is IChallenger,
> IIdentifier, IAuthenticator.
>
>> I've write an url based authentification plugin with 20 lines of code.
>> I can do this with a pure WSGI middleware but repoze.who do a lot of
>> things for me. For me, it's the only good reason ;)
> Could you share those 20 lines with me? I will try to write the same
> in WSGI. It might be possible that is not possible to write the same
> with WSGI in this case.
>
Here it is. I don't include imports because it's a part of a big module.
class UrlPlugin(RedirectingFormPlugin):
implements(IChallenger, IIdentifier)
# IIdentifier
def identify(self, environ):
query = parse_dict_querystring(environ)
if 'email' in query and 'secret' in query:
rememberer = self._get_rememberer(environ)
email = query['email']
secret = query['secret']
_secret = sha.new('%s:%s' % (email, rememberer.secret)).hexdigest()
if secret == _secret:
user = sql.one([Utilisateur.email,
Utilisateur.password,
Utilisateur.actif],
sql.and_(Utilisateur.email==email,
Utilisateur.actif==True))
if user:
login, password, actif = user[:]
if actif:
return {'login': login, 'password':password}
return None
--
Gael
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---