Hi,
So between a manual try and running the test via automation, the only differences in the initial post seems to be not including the following:
Content-Length: 168
Origin: [initialwebsite]
Connection: keep-alive
Referer: [initialwebsite]
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
In the body text, for both, its providing a valid AntiCSRF token as well as the correct username and password. Such as:
__RequestVerificationToken=[validtoken]&UserName=[validusername]&Password=[validpassword]
Each time a login occurs, a new token is generated and becomes part of the URL.
When I query our database that the page uses, it has definitely created a valid session in both cases too. It is just when its automated, it does not progress past the authentication in OWASP Zap, as I can see from logging the session is there and the __RequestVerificationToken that it should be using is in the POST request.
As mentioned in my original post, if I manually open the browser via ZAP and login then run the automated tests it will then pass the first time it has to Spider. If I then run it again, it fails as though its using the old Anti-CSRF token.
Is there anyway to make sure it is refreshing this on each run, or if I've not done it manually first, that it can correctly process the token on the first try?