Last active
August 29, 2015 14:27
-
-
Save full-of-foo/8084527abd278a524969 to your computer and use it in GitHub Desktop.
This file contains 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
def assert_valid_persona_request(): | |
"""Send the assertion to Mozilla's verifier service""" | |
assertion_key = flask.request.headers.get("PERSONA_ASSERTION") | |
if assertion_key is None: | |
raise PersonaAuthenticationError() | |
audience = flask.request.headers.get("Origin", None) | |
if audience is None: | |
audience = flask.request.url_root | |
assertion = {"assertion": assertion_key, "audience": audience} | |
resp = requests.post("https://verifier.login.persona.org/verify", data=assertion, verify=True) | |
if not resp.ok or resp.json().get('status') != "okay": | |
raise PersonaAuthenticationError() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment