Example #1
0
 def lookup_nonce(self, oauth_consumer, oauth_token, nonce):
     
     if oauth_token is None:
         return None
     
     logger.debug("!!! In GAEOAuthDataStore.lookup_nonce  key_:%s, consumer_key: %s, token_key:%s"%(nonce,oauth_consumer.key_,oauth_token.key_))
     
     nonces = Nonce.all()\
         .filter('consumer_key =',oauth_consumer.key_)\
         .filter('token_key =',oauth_token.key_)\
         .filter('key_ =',nonce).fetch(1000)
     
     if len(nonces) == 1:
         nonce = nonces[0]
         return nonce.key_
     elif len(nonces) == 0:
         #create a nonce
         nonce_obj = Nonce(consumer_key=oauth_consumer.key_, 
             token_key=oauth_token.key_,
             key_=nonce)
         nonce_obj.put()
         return None
     else:
         raise Exception('More then one nonce matches consumer_key "%s", \
             token_key "%s", key_ "%S"'%(oauth_consumer.key,oauth_token.key, nonce))
Example #2
0
    def lookup_nonce(self, oauth_consumer, oauth_token, nonce):

        if oauth_token is None:
            return None

        nonces = (Nonce.all().filter(
            'consumer_key =', oauth_consumer.key_).filter(
                'token_key =', oauth_token.key_).filter('key_ =',
                                                        nonce).fetch(1000))

        # Filter out all expired nonces
        #
        # TODO: one day we may need to do this at the datastore query level
        # and create the appropriate index to do so in case we have a very
        # active client w/ an old token who has submitted 1000+ identical
        # legitimate Nonces.
        nonces = [n for n in nonces if not n.is_expired]

        if len(nonces) == 1:
            nonce = nonces[0]
            return nonce.key_
        elif len(nonces) == 0:
            #create a nonce
            nonce_obj = Nonce(consumer_key=oauth_consumer.key_,
                              token_key=oauth_token.key_,
                              key_=nonce,
                              created=datetime.datetime.now())
            nonce_obj.put()
            return None
        else:
            raise Exception('More than one nonce matches consumer_key "%s", \
                token_key "%s", key_ "%S"' %
                            (oauth_consumer.key, oauth_token.key, nonce))
Example #3
0
    def lookup_nonce(self, oauth_consumer, oauth_token, nonce):

        if oauth_token is None:
            return None

        nonces = (Nonce.all().
                filter('consumer_key =', oauth_consumer.key_).
                filter('token_key =', oauth_token.key_).
                filter('key_ =', nonce).
                fetch(1000))

        # Filter out all expired nonces
        #
        # TODO: one day we may need to do this at the datastore query level
        # and create the appropriate index to do so in case we have a very
        # active client w/ an old token who has submitted 1000+ identical
        # legitimate Nonces.
        nonces = [n for n in nonces if not n.is_expired]

        if len(nonces) == 1:
            nonce = nonces[0]
            return nonce.key_
        elif len(nonces) == 0:
            #create a nonce
            nonce_obj = Nonce(consumer_key=oauth_consumer.key_,
                token_key=oauth_token.key_,
                key_=nonce,
                created=datetime.datetime.now())
            nonce_obj.put()
            return None
        else:
            raise Exception('More than one nonce matches consumer_key "%s", \
                token_key "%s", key_ "%S"'%(oauth_consumer.key,oauth_token.key, nonce))
Example #4
0
    def lookup_nonce(self, oauth_consumer, oauth_token, nonce):

        if oauth_token is None:
            return None

        logger.debug(
            "!!! In GAEOAuthDataStore.lookup_nonce  key_:%s, consumer_key: %s, token_key:%s"
            % (nonce, oauth_consumer.key_, oauth_token.key_))

        nonces = Nonce.all()\
            .filter('consumer_key =',oauth_consumer.key_)\
            .filter('token_key =',oauth_token.key_)\
            .filter('key_ =',nonce).fetch(1000)

        if len(nonces) == 1:
            nonce = nonces[0]
            return nonce.key_
        elif len(nonces) == 0:
            #create a nonce
            nonce_obj = Nonce(consumer_key=oauth_consumer.key_,
                              token_key=oauth_token.key_,
                              key_=nonce)
            nonce_obj.put()
            return None
        else:
            raise Exception('More then one nonce matches consumer_key "%s", \
                token_key "%s", key_ "%S"' %
                            (oauth_consumer.key, oauth_token.key, nonce))
Example #5
0
    def lookup_nonce(self, oauth_consumer, oauth_token, nonce):

        if oauth_token is None:
            return None

        nonces = (Nonce.all().
                filter('consumer_key =', oauth_consumer.key_).
                filter('token_key =', oauth_token.key_).
                filter('key_ =', nonce).
                fetch(1000))

        if len(nonces) == 1:
            nonce = nonces[0]
            return nonce.key_
        elif len(nonces) == 0:
            #create a nonce
            nonce_obj = Nonce(consumer_key=oauth_consumer.key_,
                token_key=oauth_token.key_,
                key_=nonce)
            nonce_obj.put()
            return None
        else:
            raise Exception('More then one nonce matches consumer_key "%s", \
                token_key "%s", key_ "%S"'%(oauth_consumer.key,oauth_token.key, nonce))
Example #6
0
    def lookup_nonce(self, oauth_consumer, oauth_token, nonce):

        if oauth_token is None:
            return None

        nonces = (Nonce.all().filter(
            'consumer_key =', oauth_consumer.key_).filter(
                'token_key =', oauth_token.key_).filter('key_ =',
                                                        nonce).fetch(1000))

        if len(nonces) == 1:
            nonce = nonces[0]
            return nonce.key_
        elif len(nonces) == 0:
            #create a nonce
            nonce_obj = Nonce(consumer_key=oauth_consumer.key_,
                              token_key=oauth_token.key_,
                              key_=nonce)
            nonce_obj.put()
            return None
        else:
            raise Exception('More then one nonce matches consumer_key "%s", \
                token_key "%s", key_ "%S"' %
                            (oauth_consumer.key, oauth_token.key, nonce))