Skip to content

Instantly share code, notes, and snippets.

@aaronsw
Created August 14, 2011 21:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aaronsw/1145340 to your computer and use it in GitHub Desktop.
Save aaronsw/1145340 to your computer and use it in GitHub Desktop.
basic browserid support for web.py
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