lightSAML: Unknown InResponseTo
I get random critical errors like this in Symfony when users try to log in with Okta.
Uncaught PHP Exception LightSaml\Error\LightSamlContextException: "Unknown InResponseTo '_7ab8386ad4fcf931733b87639a2bb45a5505a0e9af'" at /services/applications/red-secure/vendor/lightsaml/lightsaml/src/LightSaml/Action/Profile/Inbound/StatusResponse/InResponseToValidatorAction.php line 55
Bug or something I can fix?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 25 (1 by maintainers)
We have figured out what this problem means. When your client accesses your login URL and gets redirected to the IDP a RequestID is generated and sent. When the IDP resolves the logging process and will return to your login_check URL it adds the InResponseTo as part of the request. The thing is that: 1 - InResponseTo is not a mandatory part of the SAML protocol, 2 - if the bundle sees the InResponseTo it tries to MATCH it. The matching is done through the RequestStore.
So in the same way that you implement (by following the tutorial SpBundle+symfony bridge) your own id_entry IdStore, you will have to implement a persistent RequestStore with it’s set, get and remove. The workflow will call your implementation when it first sets the id, then verify when it receives the request with the “InResponseTo” and if it matches, it will call for the removal. The logic behind the Request store is that it will make sure you only receive requests originating from your own system (/login -> setID -> IDP login verification -> /login_check + InResponseTo) and also, that you don’t receive a duplicated request (by removing the ID from your persistent resource ).
If it still doesn’t make sense let me know and I can share the code. Take a look here: https://gist.github.com/djonatanb/194118e5b15727331b8b6279d84e29fe (fixed the link)
I store requests in DB, using Doctrine. Symfony 4.4:
Sorry for the mess in my code, I have not got enough time to make it look nice, but for now it works for me