Пример #1
0
Файл: wamp.py Проект: gchoi/VTK
    def onAuthenticate(self, signature, extra):
        """
        Callback fired when a client responds to an authentication challenge.
        """

        ## if there is a pending auth, and the signature provided by client matches ..
        if self._pending_auth and signature == self._pending_auth.signature:

            ## accept the client
            return types.Accept(authid=self._pending_auth.authid,
                                authrole=self._pending_auth.authrole,
                                authmethod=self._pending_auth.authmethod,
                                authprovider=self._pending_auth.authprovider)

        ## deny client
        return types.Deny()
Пример #2
0
Файл: wamp.py Проект: gchoi/VTK
    def onHello(self, realm, details):
        """
        Callback fired when client wants to attach session.
        """

        self._pending_auth = None

        if details.authmethods:
            for authmethod in details.authmethods:
                if authmethod == u"wampcra":

                    authdb = self.factory.authdb

                    ## lookup user in user DB
                    key = yield authdb.get(details.authid)

                    ## if user found ..
                    if key:

                        ## setup pending auth
                        self._pending_auth = PendingAuth(
                            key, details.pending_session, details.authid,
                            "user", authmethod, "authdb")

                        ## send challenge to client
                        extra = {'challenge': self._pending_auth.challenge}

                        ## when using salted passwords, provide the client with
                        ## the salt and then PBKDF2 parameters used
                        extra['salt'] = authdb.AUTHEXTRA['salt']
                        extra['iterations'] = 1000
                        extra['keylen'] = 32

                        defer.returnValue(types.Challenge('wampcra', extra))

        ## deny client
        defer.returnValue(types.Deny())