Esempio n. 1
0
    def requestAvatar(self, username, mind, *interfaces):
        """"
        The connection has already been authenticated at this point. Our job
        is to return some objects representing the logged in user.

        `username' is also known as the Avatar ID in `twisted.cred' terminology.
        """

        try:
            # treat username as an OTP and attempt
            transport, protocol = self.tickets.pop(username)

            # reset routing ticket since it is one-time only.
            ticket = tickets.newTicket()
            self.tickets[ticket] = (transport, protocol)
            log.msg("Reset routing ticket from %s to %s" % (
                username,
                ticket,
            ))

            u = ConchUser()

            # Add a custom field to indicate that this connection
            # is going to be connected (routed) using this ticket.
            u._connectTo = (transport, protocol)

            u.factory = self.factory
            u.options = self.factory.options
            return IConchUser, u, lambda: None

        except KeyError:
            log.msg(
                'Username %r not recognized as access ticket. Connecting to public AMP subsystem only!'
                % (username, ))
            # logged in user gets access to AMP subsystem only. No shells.
            u = ConchUser()
            u.factory = self.factory
            u.options = self.factory.options
            u.channelLookup['session'] = AMPSession
            return IConchUser, u, lambda: None
Esempio n. 2
0
 def requestAvatar(avatar_id, mind, *interfaces):
     user = ConchUser()
     user.channelLookup['session'] = SimpleSession
     return IConchUser, user, lambda: None
Esempio n. 3
0
 def requestAvatar(self, avatarId, mind, *interfaces):
     user = ConchUser()
     user.channelLookup['session'] = SimpleSession
     return IConchUser, user, nothing
Esempio n. 4
0
 def requestAvatar(self, avatarId, mind, *interfaces):
     avatar = ConchUser()
     avatar.channelLookup = self.channelLookup
     return (IConchUser, avatar, lambda: None)