[Twisted-Python] Twisted Cred using network connections to check credentials

Devin Jeanpierre jeanpierreda at gmail.com
Tue Feb 22 08:46:55 MST 2011


Hello,

I want to authenticate a user in twisted.cred by attempting to log him in to
an online service. If the authentication step of the connection fails, the
user gets no avatar, and if it succeeds, the user gets an avatar, and that
avatar either is or has a reference to that connection.

How would I do this? I can think of two ugly ways: I can use a global
dictionary mapping avatarIds to protocol instances, and do a lookup on that
dict in the Realm to create the avatar. Otherwise, I can instantiate the
connection as part of the credentials, and keep the reference to it around
when I get the avatar. I'm going ahead with the former, but it's scary.

Another possibility is that perhaps the credentials checker and the realm
could be the same object, and then I could move the global dict into an
attribute. Would that be a better approach?

The background for this is that I have an implementation of the chat part of
the Direct Connect (DC) protocol, and want to write an IRC<->DC bridge. I
chose twisted.words.services on the recommendation of someone, which uses
Cred for auth. DC has authentication as a given nick as part of the
"handshake" during the start of the connection attempt.

Devin Jeanpierre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20110222/0cdb1edc/attachment-0001.html>


More information about the Twisted-Python mailing list