We use OneLogin for SAML authentication. When an user is authenticated against OneLogin and clicks the Sign in link in Confidant - he/she is automatically authenticated. However, if the user is in the OneLogin dashboard and clicks on the Confidant icon (the authentication is initiated from outside of Confidant) - an error is displayed:
{
"errors": [
"invalid_response"
],
"message": "SAML request failed",
"reason": "No AuthNRequest ID from SP found to match with InResponseTo of response"
}
I think that authentication with IdP initiated requests is not currently supported by Confidant. I am not a Python expert but I believe that in order to fix this issue you need to change this piece of code:
try:
request_id = session['saml_authn_request_id']
except KeyError:
logging.warning('No saml_authn_request_id in session')
resp = jsonify(errors=['invalid_response'],
message='SAML request failed',
reason=('No AuthNRequest ID from SP found '
'to match with InResponseTo of response'))
resp.status_code = 401
return resp
Instead of always throwing an exception when the request_id is not found, you should first check if the response contains InResponseTo="..." field and only if it does, then throw an exception.
<samlp:Response xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
ID="R6814b187947641b39d27763029820d5527xxxxx"
Version="2.0"
IssueInstant="2017-03-29T22:00:09Z"
Destination="https://<our_host_here>/v1/saml/consume"
InResponseTo="ONELOGIN_7c4612b6a6361c50f10e2aa2a04f0b5f7dxxxxxx"
>
The InResponseTo field is not present when the authentication request is initiated from the IdP (e.g. Onelogin).
We use OneLogin for SAML authentication. When an user is authenticated against OneLogin and clicks the
Sign inlink in Confidant - he/she is automatically authenticated. However, if the user is in the OneLogin dashboard and clicks on the Confidant icon (the authentication is initiated from outside of Confidant) - an error is displayed:I think that authentication with IdP initiated requests is not currently supported by Confidant. I am not a Python expert but I believe that in order to fix this issue you need to change this piece of code:
Instead of always throwing an exception when the
request_idis not found, you should first check if the response containsInResponseTo="..."field and only if it does, then throw an exception.The
InResponseTofield is not present when the authentication request is initiated from the IdP (e.g. Onelogin).