无法理解SimpleSAMLphp的ReturnTo重定向

Trying to set up a redirect in simplesamlphp to take the user back to the page they were trying to access before being sent to authentication.

I'm using the ReturnTo option:

$as->requireAuth(array("ReturnTo" => $returnURL, 'KeepPost' => FALSE));

With metadata for remote-idp set up like this (stripped for example):

$metadata['sample'] = array(
  'name' => 'sample',
  'entityid' => 'https://sample.com/saml/module.php/saml/sp/metadata.php/sample',
  'metadata-set' => 'saml20-idp-remote',
  'SingleSignOnService' => 
      array (
        0 => 
            array (
              'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
              'Location' => 'https://sample:port/idp/startSSO.ping?PartnerSpId=https://sample.com/saml/module.php/saml/sp/metadata.php/sample'
            )
      ),
  'keys' => array(...)
);

I need to pass a parameter "TARGET" into the idp startSSO in the above metadata, but haven't been able to find how to translate the "ReturnTo" option to be added onto this SSO url. I've also captured/examined the SAML redirect xml, and the ReturnTo is not in there at all. Anyone know how to do this?

Trying to set up a redirect in simplesamlphp to take the user back to the page they were trying to access before being sent to authentication.

Using the ReturnTo method without any option defaults to redirect to the page the user tried to access.

From documentation

ReturnTo (string)
The URL the user should be returned to after authentication. The default is to return the user to the current page.

Just include this code in the pages requiring authentication.

require_once 'path/to/simplesamlphp/lib/_autoload.php';

$as = new SimpleSAML_Auth_Simple('default-sp');
$as->requireAuth();