Beispiel #1
0
 def test_get_set_delete(self):
     m = MemoryCache()
     self.assertEqual(None, m.get('foo'))
     self.assertEqual(None, m.delete('foo'))
     m.set('foo', 'bar')
     self.assertEqual('bar', m.get('foo'))
     m.delete('foo')
     self.assertEqual(None, m.get('foo'))
 def test_get_set_delete(self):
   m = MemoryCache()
   self.assertEqual(None, m.get('foo'))
   self.assertEqual(None, m.delete('foo'))
   m.set('foo', 'bar')
   self.assertEqual('bar', m.get('foo'))
   m.delete('foo')
   self.assertEqual(None, m.get('foo'))
 def test_get_set_delete(self):
     m = MemoryCache()
     self.assertEqual(None, m.get("foo"))
     self.assertEqual(None, m.delete("foo"))
     m.set("foo", "bar")
     self.assertEqual("bar", m.get("foo"))
     m.delete("foo")
     self.assertEqual(None, m.get("foo"))
Beispiel #4
0
        raise AppIdentityError('Token used too late, %d > %d: %s' %
                               (now, latest, json_body))

    # Check audience.
    if audience is not None:
        aud = parsed.get('aud')
        if aud is None:
            raise AppIdentityError('No aud field in token: %s' % json_body)
        if aud != audience:
            raise AppIdentityError('Wrong recipient, %s != %s: %s' %
                                   (aud, audience, json_body))

    return parsed


_cached_http = httplib2.Http(MemoryCache())


def verify_id_token(id_token,
                    audience,
                    http=None,
                    cert_uri=ID_TOKEN_VERIFICATON_CERTS):
    """Verifies a signed JWT id_token.


    Args:
      id_token: string, A Signed JWT.
      audience: string, The audience 'aud' that the token should be for.
      http: httplib2.Http, instance to use to make the HTTP request. Callers
        should supply an instance that has caching enabled.
      cert_uri: string, URI of the certificates in JSON format to