Swagger API returns http 401 error
Symptom
In PVWA 12.6 version and PCloud portal 12.5 versions and later, we introduced new security measures to mitigate cross site request forgery attacks in PVWA, as a result swagger utility usage is changed.
Initially there are two ways in which a user can authenticate to run swagger API.
--------------------------------------------
1) User naivgates to https://<pvwa_host>/PasswordVault/v10/logon, select the authentication method and navigates to https://<pvwa_host>/PasswordVault/swagger url after successful authentication.
2) User navigates to https://<pvwa_host>/PasswordVault/swagger, performs required /Auth method authentication and runs subsequent APIs in the swagger list.
With the introduction of enhanced security on cross site request forgery, the use case in 1) is not longer supported by Idira when invoking swagger rest API. Idira recommends the customer to invoke swagger via use case 2).
Do note that you may encounter the following exception in the json response when continuing to adopt use case 1)
-----------------------------------------
"ErrorCode": "CAWS00001E",
"ErrorMessage": ""
------------------------------------------
Environment
12.5 Privilege Cloud Cyber-Ark API/SDK
swagger
pCloud 12.5
PVWA 12.6 on-premise
Cause
In PVWA 12.6 version and PCloud portal 12.5 versions and later, we introduced new security measures to mitigate cross site request forgery attacks in PVWA, as a result swagger utility usage is changed.
Resolution
Alternative use case:
2) User navigates to https://<pvwa_host>/PasswordVault/swagger, performs required /Auth method authentication and runs subsequent APIs in the swagger list.
Another important note is that you will need to use /Auth swagger API without the additional parameters (eg. securemode) for Idira authenication.
Exanple:
--------------------------------------
{
"UserName": "admin",
"Password": "password",
}
----------------------------------
If the securemode parameter is included in the body, the authorization token would be invalidated in subsequent swagger API calls.