Permalink
Browse files

Rename from PyVEP to PyBrowserID

  • Loading branch information...
1 parent bb778f0 commit 3f85301363658f86050155bfb79e779a135fd2d1 @rfk rfk committed Mar 5, 2012
View
@@ -1,11 +1,12 @@
0.4.0 - ????-??-??
==================
+ * Renamed from PyVEP to PyBrowserID, in keeping with Mozilla branding.
* XXX: document refactoring here when we're finished with it.
* Allow LocalVerifier to use of a custom JWT parser.
- * Remove vep.verify_[remote|local|dummy] since they just cause
- confusion. You should either accept the defaults provided by
- vep.verify, or use a full-blown Verifier object.
+ * Remove browserid.verify_[remote|local|dummy] since they just cause
+ confusion. You should either accept the defaults provided by the
+ browserid.verify function, or use a full-blown Verifier object.
0.3.2 - 2012-02-03
==================
View
@@ -1,3 +1,3 @@
include CHANGES.txt
include README.rst
-recursive-include vep *.crt *.key
+recursive-include browserid *.crt *.key
View
@@ -1,20 +1,15 @@
-=======================================================
-PyVEP: a python library for the Verified Email Protocol
-=======================================================
+========================================================
+PyBrowserID: a python library for the BrowserID Protocol
+========================================================
-This is a python client library for the Verified Email Protocol, a.k.a
-Mozilla's BrowserID project. See here for details:
-
- https://wiki.mozilla.org/Identity/Verified_Email_Protocol
-
-And see here for how to integrate it into your website:
+This is a python client library for the BrowserID Protocol:
https://browserid.org/
For the vast majority of deployments, you will simply want to call the "verify"
functon to verify a given assertion::
- >>> data = vep.verify(BROWSERIDASSERTION, "http://mysite.com")
+ >>> data = browserid.verify(BROWSERIDASSERTION, "http://mysite.com")
>>> print data["email"]
"test@example.com"
@@ -26,15 +21,15 @@ If you have specialised needs, you can also create a "verifier" class to
encapsulate any custom settings you may require. For example, here is how
to do remote verification using a custom url-opening function::
- >>> verifier = vep.RemoteVerifier(urlopen=my_urlopen_func)
+ >>> verifier = browserid.RemoteVerifier(urlopen=my_urlopen_func)
>>> data = verifier.verify(BROWSERIDASSERTION, "http://mysite.com")
>>> print data["email"]
"test@example.com"
For improved performance, or if you just want to live on the bleeding edge,
you can explicitly perform verification locally like so::
- >>> verifier = vep.LocalVerifier()
+ >>> verifier = browserid.LocalVerifier()
>>> data = verifier.verify(BROWSERIDASSERTION, "http://mysite.com")
>>> print data["email"]
"test@example.com"
View
@@ -0,0 +1,43 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+"""
+
+Python library for the Verified Email Protocol.
+
+"""
+
+__ver_major__ = 0
+__ver_minor__ = 3
+__ver_patch__ = 2
+__ver_sub__ = ""
+__ver_tuple__ = (__ver_major__, __ver_minor__, __ver_patch__, __ver_sub__)
+__version__ = "%d.%d.%d%s" % __ver_tuple__
+
+
+from browserid.errors import (Error, # NOQA
+ ConnectionError, # NOQA
+ TrustError, # NOAQ
+ ExpiredSignatureError, # NOQA
+ InvalidSignatureError, # NOQA
+ AudienceMismatchError) # NOQA
+
+from browserid.verifiers.remote import RemoteVerifier # NOQA
+from browserid.verifiers.local import LocalVerifier # NOQA
+
+
+_DEFAULT_VERIFIER = None
+
+
+def verify(assertion, audience=None):
+ """Verify the given BrowserID assertion.
+
+ This function uses the "best" verification method available in order to
+ verify the given BrowserID assertion and return a dict of user data. The
+ best method currently involves POSTing to the hosted verifier service on
+ browserid.org; eventually it will do local verification.
+ """
+ global _DEFAULT_VERIFIER
+ if _DEFAULT_VERIFIER is None:
+ _DEFAULT_VERIFIER = RemoteVerifier()
+ return _DEFAULT_VERIFIER.verify(assertion, audience)
File renamed without changes.
@@ -8,11 +8,11 @@
from urlparse import urljoin
-from vep.utils import secure_urlopen
-from vep.errors import (ConnectionError,
- InvalidIssuerError)
+from browserid.utils import secure_urlopen
+from browserid.errors import (ConnectionError,
+ InvalidIssuerError)
-WELL_KNOWN_URL = "/.well-known/vep"
+WELL_KNOWN_URL = "/.well-known/browserid"
class CertificatesManager(object):
@@ -49,11 +49,11 @@ def fetch_public_key(self, hostname):
class FIFOCache(object):
- """A simple in-memory FIFO cache for VEP public keys.
+ """A simple in-memory FIFO cache for BrowseriD public keys.
This is a *very* simple in-memory FIFO cache, used as the default object
- for caching VEP public keys in the LocalVerifier. Items are kept for
- 'cache_timeout' seconds before being evicted from the cache. If the
+ for caching BrowserID public keys in the LocalVerifier. Items are kept
+ for 'cache_timeout' seconds before being evicted from the cache. If the
'max_size' argument is not None and the cache grows above this size,
items will be evicted early in order of insertion into the cache.
@@ -142,9 +142,9 @@ def __len__(self):
def fetch_public_key(hostname, well_known_url=None):
- """Fetch the VEP public key for the given hostname.
+ """Fetch the BrowserID public key for the given hostname.
- This function uses the well-known VEP meta-data file to extract
+ This function uses the well-known BrowserID meta-data file to extract
the public key for the given hostname.
"""
if well_known_url is None:
@@ -155,10 +155,10 @@ def fetch_public_key(hostname, well_known_url=None):
# raise an InvalidIssuerError. Any other connection-related
# errors are passed back up to the caller.
try:
- # Try to read the well-known vep file to load the key.
+ # Try to read the well-known browserid file to load the key.
try:
- vep_url = urljoin(hostname, well_known_url)
- vep_data = urlread(vep_url)
+ browserid_url = urljoin(hostname, well_known_url)
+ browserid_data = urlread(browserid_url)
except ConnectionError, e:
if "404" not in str(e):
raise
@@ -176,15 +176,15 @@ def fetch_public_key(hostname, well_known_url=None):
# The well-known file was found, it must contain the key
# data as part of its JSON response.
try:
- key = json.loads(vep_data)["public-key"]
+ key = json.loads(browserid_data)["public-key"]
except (ValueError, KeyError):
- msg = "Host %r has malformed VEP metadata document"
+ msg = "Host %r has malformed BrowserID metadata document"
raise InvalidIssuerError(msg % (hostname,))
return key
except ConnectionError, e:
if "404" not in str(e):
raise
- msg = "Host %r does not declare support for VEP" % (hostname,)
+ msg = "Host %r does not declare support for BrowserID" % (hostname,)
raise InvalidIssuerError(msg)
@@ -3,18 +3,18 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.
"""
-Error classes for PyVEP.
+Error classes for PyBrowserID.
"""
class Error(Exception):
- """Base error class for all PyVEP exceptions."""
+ """Base error class for all PyBrowserID exceptions."""
pass
class ConnectionError(Error):
- """Error raised when PyVEP fails to connect to a remote server."""
+ """Error raised when PyBrowserID fails to connect to a remote server."""
pass
@@ -24,7 +24,7 @@ class TrustError(Error):
class InvalidSignatureError(TrustError):
- """Error raised when PyVEP encounters an invalid signature."""
+ """Error raised when PyBrowserID encounters an invalid signature."""
pass
@@ -34,7 +34,7 @@ class InvalidIssuerError(TrustError):
class ExpiredSignatureError(TrustError):
- """Error raised when PyVEP encounters an expired signature or assertion."""
+ """Error raised when PyBrowserID encounters an expired signature."""
pass
@@ -10,11 +10,12 @@
import struct
import hashlib
from binascii import unhexlify
-from vep._m2_monkeypatch import DSA as _DSA
-from vep._m2_monkeypatch import RSA as _RSA
-from vep.utils import decode_bytes, encode_bytes
-from vep.utils import decode_json_bytes, encode_json_bytes
+from browserid._m2_monkeypatch import DSA as _DSA
+from browserid._m2_monkeypatch import RSA as _RSA
+
+from browserid.utils import decode_bytes, encode_bytes
+from browserid.utils import decode_json_bytes, encode_json_bytes
def parse(jwt, cls=None):
File renamed without changes.
@@ -1,4 +1,4 @@
This directory contains verious self-signed TLS certificates, used for
-testing the secure_urlopen function for PyVEP.
+testing the secure_urlopen function for PyBrowserID.
File renamed without changes.
File renamed without changes.
@@ -6,11 +6,11 @@
import hashlib
from contextlib import contextmanager
-from vep.utils import encode_bytes, bundle_certs_and_assertion
+from browserid.utils import encode_bytes, bundle_certs_and_assertion
-from vep import certificates
-from vep import jwt
-from vep.verifiers import remote
+from browserid import certificates
+from browserid import jwt
+from browserid.verifiers import remote
# These are values used to generate dummy DSA keys.
# I took them directly from the javacript jwcrypto source code, which claims:
@@ -45,7 +45,7 @@ def _hex(value):
def fetch_public_key(hostname):
- """Fetch the VEP public key for the given hostname.
+ """Fetch the BrowserID public key for the given hostname.
Actually, this implementation generates the key locally based on
a hash of the hostname. This lets us exercise all the crypto code
@@ -94,8 +94,8 @@ def make_assertion(email, audience, issuer=None, exp=None,
new_style=True):
"""Generate a new dummy assertion for the given email address.
- This method lets you generate VEP assertions using dummy private keys.
- Called with just an email and audience it will generate an assertion
+ This method lets you generate BrowserID assertions using dummy private
+ keys. Called with just an email and audience it will generate an assertion
from browserid.org.
By specifying the "exp", "assertion_sig" or "certificate_sig" arguments
@@ -130,7 +130,7 @@ def make_assertion(email, audience, issuer=None, exp=None,
if certificate_sig is not None:
certificate = ".".join(certificate.split(".")[:-1] +
[encode_bytes(certificate_sig)])
- # Combine them into a VEP bundled assertion.
+ # Combine them into a BrowserID bundled assertion.
return bundle_certs_and_assertion([certificate], assertion, new_style)
@@ -4,9 +4,9 @@
import unittest
-from vep.tests.support import get_keypair
-from vep.utils import encode_json_bytes, encode_bytes
-from vep import jwt
+from browserid.tests.support import get_keypair
+from browserid.utils import encode_json_bytes, encode_bytes
+from browserid import jwt
class TestJWT(unittest.TestCase):
@@ -4,8 +4,8 @@
import unittest
-from vep.jwt import int2mpint
-import vep._m2_monkeypatch as _m2
+from browserid.jwt import int2mpint
+import browserid._m2_monkeypatch as _m2
# Dummy RSA key for testing purposes.
@@ -9,9 +9,10 @@
import ssl
import warnings
-from vep.errors import ConnectionError
-from vep.utils import secure_urlopen, encode_bytes, decode_bytes
-from vep.utils import encode_json_bytes, decode_json_bytes, get_assertion_info
+from browserid.errors import ConnectionError
+from browserid.utils import secure_urlopen, encode_bytes, decode_bytes
+from browserid.utils import encode_json_bytes, decode_json_bytes
+from browserid.utils import get_assertion_info
def _filepath(name):
@@ -7,23 +7,23 @@
import unittest
import warnings
-import vep
-from vep.tests.support import (patched_urlopen,
- patched_key_fetching,
- get_keypair,
- fetch_public_key,
- make_assertion)
-from vep import jwt
-from vep import RemoteVerifier, LocalVerifier
-from vep.certificates import FIFOCache, CertificatesManager
-from vep.verifiers.workerpool import WorkerPoolVerifier
-from vep.utils import encode_json_bytes, decode_json_bytes
-from vep.errors import (TrustError,
- ConnectionError,
- ExpiredSignatureError,
- InvalidSignatureError,
- InvalidIssuerError,
- AudienceMismatchError)
+import browserid
+from browserid.tests.support import (patched_urlopen,
+ patched_key_fetching,
+ get_keypair,
+ fetch_public_key,
+ make_assertion)
+from browserid import jwt
+from browserid import RemoteVerifier, LocalVerifier
+from browserid.certificates import FIFOCache, CertificatesManager
+from browserid.verifiers.workerpool import WorkerPoolVerifier
+from browserid.utils import encode_json_bytes, decode_json_bytes
+from browserid.errors import (TrustError,
+ ConnectionError,
+ ExpiredSignatureError,
+ InvalidSignatureError,
+ InvalidIssuerError,
+ AudienceMismatchError)
# This is an old assertion I generated on myfavoritebeer.org.
# It's expired and signed with an old private key.
@@ -176,7 +176,7 @@ def read():
self.verifier.verify, EXPIRED_ASSERTION, now=0)
def test_well_known_doc_with_public_key(self):
- # The browserid.org server doesn't currently have /.well-known/vep.
+ # The browserid.org server doesn't currently have /.well-known/browserid.
# This simulates it with a dummy key.
def urlopen(url, data): # NOQA
class response(object):
@@ -417,4 +417,4 @@ def tearDown(self):
class TestShortcutFunction(unittest.TestCase):
def test_shortcut(self):
- self.assertRaises(TrustError, vep.verify, EXPIRED_ASSERTION)
+ self.assertRaises(TrustError, browserid.verify, EXPIRED_ASSERTION)
Oops, something went wrong.

0 comments on commit 3f85301

Please sign in to comment.