infamousjoeg / cybr-cli

A "Swiss Army Knife" command-line interface (CLI) for easy human and non-human interaction with @CyberArk suite of products.
Apache License 2.0
71 stars 15 forks source link

Improve logon with 2FA (#114) #115

Closed infamousjoeg closed 10 months ago

infamousjoeg commented 3 years ago

Co-authored-by: Quincy Cheng quincy.cheng@gmail.com Co-authored-by: Joe Garcia infamousjoeg@users.noreply.github.com

Currenly when trying to autenticate against a CyberArk with 2FA enabled the request request fails with the following error:

Failed to Logon to the PVWA. Failed to authenticate to the PAS REST API.
Received non-200 status code '500'

In function httpjson.SendRequestRay the response body isn't returned, so the caller function never finds the correct error code.

After the previous fix, the second call, the one with the otp code still fails with 403. Debugging it seems that we need to store the cookies between the two logon calls. So a go context is added to the functions.

This commit fixes the go lint error related to key type in context and it adds a missing file from previous commit not uploaded by error.

Added missing comment

Try to catch nil response body on httpjson.SendRequestRaw function

Co-authored-by: Andrew Copeland 50109276+AndrewCopeland@users.noreply.github.com Co-authored-by: Quincy Cheng quincy.cheng@gmail.com Co-authored-by: Joe Garcia infamousjoeg@users.noreply.github.com

sonarcloud[bot] commented 3 years ago

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Infraded commented 10 months ago

Hi @infamousjoeg, I was trying to get cybr-cli working with an MFA/RADIUS protected instance and found this and #114 while troubleshooting. The issues fixed in the original PR seem to still be present and prompts for MFA challenges just get 403s. It's been a while, and I'm not sure why this didn't make the original merge, but any chance on getting this actually merged in?

infamousjoeg commented 10 months ago

@Infraded, extremely interesting. It seems like it was staged for release in an early beta version, somehow got untracked from the project and orphaned, then 2 years later when I was cleaning branches, it was deleted. Let me reopen this, restore the branch, and re-investigate.

Once I get the branch synchronized with main, I'll ask for a quick test to ensure the fixes on the branch are still good to go.

sonarcloud[bot] commented 10 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

infamousjoeg commented 10 months ago

@Infraded,

Let's continue this over on #214 where I added this code into the current code base. I am hoping you can help test the build.