Only return nonce from given payload

This commit is contained in:
Daniel Zohar
2016-04-17 16:00:35 +01:00
parent 06ca2c5a58
commit f905a957f4
+5 -4
View File
@@ -27,9 +27,10 @@ import hmac
import hashlib
try: # py3
from urllib.parse import unquote, urlencode
from urllib.parse import unquote, urlencode, parse_qs
except ImportError:
from urllib import unquote, urlencode
from urlparse import parse_qs
from pydiscourse.exceptions import DiscourseError
@@ -63,9 +64,9 @@ def sso_validate(payload, signature, secret):
if this_signature != signature:
raise DiscourseError('Payload does not match signature.')
nonce = decoded.split('=')[1]
return nonce
# Discourse returns querystring encoded value. We only need `nonce`
qs = parse_qs(decoded)
return qs['nonce'][0]
def sso_payload(secret, **kwargs):