Skip to main content

PyBrowserID: a python library for the BrowserID Protocol

This is a python client library for the BrowserID protocol that underlies Mozilla Persona:

https://login.persona.org/

For the vast majority of deployments, you will simply want to call the module- level “verify” functon to verify a given assertion:

>>> data = browserid.verify(BROWSERIDASSERTION, "http://mysite.com")
>>> print data["email"]
"test@example.com"

The precise implementation of this function will change depending on the current recommendations of the BrowserID team. Currently it POSTs the assertion to the remote verifier service on persona.org.

Note that you must specify your site’s root URL as the second argument to that function. This is the “expected audience” and is a key security feature of BrowserID.

If you are not able to determine the precise hostname by which your site is being accessed (e.g. due to virtual hosting) then you may specify one or more wildcard patterns like so:

>>> data = browserid.verify(BROWSERIDASSERTION, ["http://*.mysite.com"])
>>> print data["email"]
"test@example.com"

For finer control over the verification process, you can create an instance of a “Verifier” class and avoid having to specify the audience patterns over and over again:

>>> verifier = browserid.RemoteVerifier(["*.mysite.com"])
>>> data = verifier.verify(BROWSERIDASSERTION)
>>> 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 by using the LocalVerifier class like so:

>>> verifier = browserid.LocalVerifier(["*.mysite.com"])
>>> data = verifier.verify(BROWSERIDASSERTION)
>>> print data["email"]
"test@example.com"

Note that the details of the BrowserID Protocol are still in flux, so local verification might break due to incompatible changes. As things stabilise this will become the default implementation.

0.14.0 - 2018-01-12

  • Silence warnings about assertion format changes, since there’s now no risk of this.

0.13.0 - 2017-12-20

  • Use LocalVerifier by default, now that the hosted verifier has shut down.

0.12.0 - 2017-05-29

  • Add support for extra “idpClaims” and “userClaims” when using the LocalVerifier class.

0.11.0 - 2016-05-11

  • Have the local verifier validate that the email address is well-formed, to avoid passing e.g. null bytes through to code that doesn’t properly handle them.

0.10.0 - 2016-03-09

  • Add support for “idpClaims” and “userClaims” when generating test assertions. This helps when using this library to interact with Firefox Accounts.

0.9.2 - 2014-04-13

  • Remove tuple paramter unpacking for python3.

  • Add “description” attribute to Error objects.

0.9.1 - 2012-11-26

  • Fix data-decoding bug in fallback crypto routines.

0.9.0 - 2012-10-04

  • Support for Python 3.

0.8.0 - 2012-08-01

  • Correct the pure-python RSA implementation. Unfortunately this requires a small backwards-incompatible API change on RSKey objects (the SIZE property is now DIGESTSIZE and it gives the size of the internal hex digest string in bytes)

0.7.0 - 2012-07-26

  • Added a pure-python implementation of the JWT crypto routines, for use when M2Crypto is not available.

  • Added “from_pem_data” and “to_pem_data” methods to Key objects. Currently these are only available when M2Crypto is installed.

  • Added support for delegation of authority; thanks @kylef.

  • Use https://verifier.login.persona.org/verify for remote verification

0.6.2 - 2012-07-17

  • Add persona.org and related sites to the list of default trusted secondaries.

0.6.1 - 2012-06-07

  • Disable certificate chaining for now. This feature is not used by any servers in the wild, and the spec for it is going to change soon.

0.6.0 - 2012-31-05

  • Remove ability to use a custom JWT parser class, it’s not used and adds needless complexity.

  • Add a way to skip the ssl verification when getting certificates with the CertificateManager.

0.5.0 - 2012-04-18

  • add support of requests rather than custom code for ssl checking when retrieving certificates.

  • removed patch utility for secure_urlopen (we are now using requests)

  • add more verbose errors when dealing with RSA/DSA Keys.

0.4.0 - 2012-03-13

  • Renamed from PyVEP to PyBrowserID, in keeping with Mozilla branding.

  • Audience checking now accepts glob-style patterns as well as fixed audience strings.

  • Verifier objects now accept a list of audience patterns as their first argument. This is designed to encourage doing the right thing rather than, say, passing in the hostname from the request.

  • Allowed LocalVerifier to use of a custom JWT parser.

  • Removed 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.

  • Split certificate loading and caching into a separate class, in browserid.certificates:CertificatesManager.

  • Removed the DummyVerifier class in favour of supporting functions in browserid.tests.support.

Metadata

Release files for PyBrowserID 0.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyBrowserID 0.14.0
File Size Uploaded
PyBrowserID-0.14.0.tar.gz 36.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyBrowserID 0.14.0
File Interpreter ABI Platform
PyBrowserID-0.14.0-py2-none-any.whl Python 2 none any Details

Total release size: 86.3 kB

Release files / PyBrowserID-0.14.0.tar.gz

Download URL PyBrowserID-0.14.0.tar.gz
Size 36.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6c227669e87cc25796ae76f6a0ef65025528c8ad82d352679fa9a3e5663a71e3
BLAKE2b-256 checksum
How to use checksums
e42ee9bb9e24e600da08ff6a4d003362434eed717151f58413d8f73427e7e315
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / PyBrowserID-0.14.0-py2-none-any.whl

Download URL PyBrowserID-0.14.0-py2-none-any.whl
Size 49.8 kB
Tags Python 2
SHA-256 checksum
How to use checksums
8e237d6a2bc9ead849a4472a84d3e6a9309bec99cf8e10d36213710dda8df8ca
BLAKE2b-256 checksum
How to use checksums
0584c05bc305cfa581f958e191aa635ef0d1fd750072b68ef103e5b7170ecdf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.14.0 This release

2 release files

0.13.0

1 release file

0.12.0

1 release file

0.11.0

1 release file

0.10.0

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.8.0

1 release file

0.7.0

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page