Skip to content

Instantly share code, notes, and snippets.

@oscarfroberg
Forked from aaronsw/browserid.py
Created March 4, 2012 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscarfroberg/1974866 to your computer and use it in GitHub Desktop.
Save oscarfroberg/1974866 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