Is anyone succesful in using API access with SAML authentication?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Welcome Idira to LIVEcommunity!

Our community just got stronger! Explore new identity security resources, connect with experts, and discover more ways to learn and collaborate.

Meet Idira

Is anyone succesful in using API access with SAML authentication?

L0 Member

We user the SaaS version of cyberark EPM; I found discussion https://community.cyberark.com/s/question/0D52J000097AzDWSA0/how-can-we-use-saml-authentication-to-m...  and other saying more or less the same thing, but we're unable to get it working.

  • I extract the token (either with the New-SAMLInteractive powershell module or by sniffing the session on an F12 panel on my browser)
  • I verify the token: it is a base64-encoded XML that contains all the details from my ID Provider (Okta)
  • I try to use it in:

$url="https://it.epm.cyberark.com/SAML/Logon";

$ch=curl_init($url);

curl_setopt($ch,CURLOPT_POSTFIELDS,"SAMLResponse=" . urlencode($token1));

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_VERBOSE, true);

$result = curl_exec($ch);

curl_close($ch);

print_r($result);

 

but I always get

{"StatusCode":401,"Error":"Authentication is required and has failed or has not yet been provided"}

 

1 accepted solution

Accepted Solutions

L2 Linker

I guess to get the IDP token you should use the URL that point to your IDP server. You can find it from EPM console Administration > SAML Integration page.

 

Field_Content_versions_oct20__068Ht00000Ve5VIIAZ.png

View solution in original post

2 REPLIES 2

L2 Linker

I guess to get the IDP token you should use the URL that point to your IDP server. You can find it from EPM console Administration > SAML Integration page.

 

Field_Content_versions_oct20__068Ht00000Ve5VIIAZ.png

L0 Member

It worked!

 

I was missing the fact that I need to use the URL provided by Cyberark, and I was using the LoginURL provided by the IdP for Idp-Initiated sessions .

I repeated everything starting from the url found on the SAML integration, and I used the sample script that I found in powershell:

 

Import-Module -name .\PS-SAML-Interactive.psm1

$LoginURL = 'https://eu.epm.cyberark.com/SAML/XXXXX'

$SAMLResponse = New-SAMLInteractive -LoginIDP $loginURL

$DispatcherURL = "https://eu.epm.cyberark.com/SAML/Logon"

$Method = "POST"

$Headers = @{"Content-Type" = "application/x-www-form-urlencoded"}

$SAMLAuthBody = @{SAMLResponse= "$SAMLResponse"}

$SAMLAuthResponse = Invoke-RestMethod -Uri $DispatcherURL -Method $Method -Headers $Headers -Body $SAMLAuthBody

$SAMLAuthResponse

 

now I'll revert to my PHP Scripts. thank you

  • 1 accepted solution
  • 307 Views
  • 2 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!