mozilla-services/repoze.who.plugins.browserid — Issue #5: New assertion format isn't supported
Author: catlee
Created: 2012-01-28 16:54:11+00:00
State: open

Since browserid changed the assertion format, repoze.who.plugins.browserid can't verify remote assertions.

The error occurs in parse_assertion:
Traceback (most recent call last):
File "/home/catlee/projects/treestatus/vendor/lib/python/repoze/who/plugins/browserid/utils.py", line 100, in parse_assertion
data = vep.utils.decode_json_bytes(assertion)
File "/home/catlee/projects/treestatus/vendor/lib/python/vep/utils.py", line 99, in decode_json_bytes
obj = json.loads(decode_bytes(value))
File "/home/catlee/projects/treestatus/vendor/lib/python/vep/utils.py", line 77, in decode_bytes
raise ValueError(str(e))
ValueError: Incorrect padding

I also have this local patch to browserid/__init__.py:
diff --git a/lib/python/repoze/who/plugins/browserid/__init__.py b/lib/python/repoze/who/plugins/browserid/__init
index 25fbb9a..091434f 100644
--- a/lib/python/repoze/who/plugins/browserid/__init__.py
+++ b/lib/python/repoze/who/plugins/browserid/__init__.py
@@ -254,17 +254,17 @@ class BrowserIDPlugin(object):
challenge_vars["assertion_field"] = self.assertion_field
challenge_vars["came_from_field"] = self.came_from_field
challenge_vars["csrf_field"] = self.csrf_field
challenge_vars["came_from"] = came_from
challenge_vars["request_url"] = request_url
challenge_vars["request_method"] = environ.get("REQUEST_METHOD")
challenge_vars["csrf_token"] = csrf_token
challenge_vars["error_message"] = error_message
- challenge_body = self.challenge_body % challenge_vars
+ challenge_body = str(self.challenge_body % challenge_vars)
# Send the challenge page as text/html.
headers.append(("Content-Type", "text/html"))
start_response(status, headers)
return [challenge_body]
return challenge_app

def authenticate(self, environ, identity):
"""Authenticate and extract identity from a BrowserID assertion.

Otherwise I get this exception:
ERROR:werkzeug:Error on request:
Traceback (most recent call last):
File "/home/catlee/projects/treestatus/vendor/lib/python/werkzeug/serving.py", line 159, in run_wsgi
execute(app)
File "/home/catlee/projects/treestatus/vendor/lib/python/werkzeug/serving.py", line 149, in execute
write(data)
File "/home/catlee/projects/treestatus/vendor/lib/python/werkzeug/serving.py", line 129, in write
assert type(data) is str, 'applications must write bytes'
AssertionError: applications must write bytes