onelogin / drupal-saml

MIT License
14 stars 17 forks source link

SAML login url should accept a return path parameter #10

Closed cagedartist closed 10 years ago

cagedartist commented 10 years ago

Related to #9 - The Drupal app needs to be able to pass a return path to the login url. We use the "destination" parameter for this. E.g. "/onelogin_saml/sso?destination=campus-services" The following change makes the SP-initiated login process work correctly for us, from start to finish:

function onelogin_saml_sso() {
  $auth = initialize_saml();  
  if (isset($_GET['destination'])) {
    $auth->login($_GET['destination']);
  } else {
    $auth->login();
  }
  exit();
}

The "destination" parameter eventually returns in the RelayState parameter and is used in a drupal_goto function (thanks to fix #9).

Note that "destination" is the parameter name that Drupal customarily uses for this purpose. I have seen others use the name "returnTo" or just "r". It's okay to support other options but please default to "destination."