Created
August 14, 2011 21:37
-
-
Save aaronsw/1145340 to your computer and use it in GitHub Desktop.
basic browserid support for web.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib, json | |
class FalseStorage(web.storage): | |
def __nonzero__(self): return False | |
def browserid(): | |
c = web.cookies() | |
if c.get('browserid_assertion'): | |
out = urllib.urlencode(dict(audience=web.ctx.host, assertion=c.browserid_assertion)) | |
o = json.loads(urllib.urlopen('https://browserid.org/verify', out).read()) | |
if o['status'] == 'failure': | |
return FalseStorage(o) | |
else: | |
return web.storage(o) | |
else: | |
return web.storage() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment