← Prev in month
← Prev in thread
Next in thread →
Next in month →
Decoding SAMLRequest.
Hello list,
From the spec, for HTTP-Resirect binding, the SAMLRequest is DEFLATE-compressed, then Base 64 encoded, then URL encoded.
I do this in Python for decoding the SAMLRequest to get the AuthnRequest. Was wondering if this will always work? Is there any better alternative in C / Python.
def decode_authn_request(authn_request):
""" AuthnRequest is always deflated, base64 encoded and url-escaped.
:Parameters:
-`authn_request`: AuthnRequest
:Return:
The decoded AuthnRequest if successful else empty string.
"""
decoded = ''
a = urllib.unquote(authn_request)
a = a.strip('SAMLRequest=')
try:
decoded = zlib.decompress(base64.b64decode(a), -8)
except (zlib.error, TypeError):
try:
decoded = zlib.decompress(base64.b64decode(a))
except (zlib.error, TypeError):
pass
return decoded
Thanks,
Bhaskar.
← Prev in month
← Prev in thread
Next in thread →
Next in month →