You are here

public function SamlService::login in SAML Authentication 8.3

Same name and namespace in other branches
  1. 8 src/SamlService.php \Drupal\samlauth\SamlService::login()
  2. 8.2 src/SamlService.php \Drupal\samlauth\SamlService::login()
  3. 4.x src/SamlService.php \Drupal\samlauth\SamlService::login()

Initiates a SAML2 authentication flow and redirects to the IdP.

Parameters

string $return_to: (optional) The path to return the user to after successful processing by the IdP.

array $parameters: (optional) Extra query parameters to add to the returned redirect URL.

Return value

string The URL of the single sign-on service to redirect to, including query parameters.

File

src/SamlService.php, line 251

Class

SamlService
Governs communication between the SAML toolkit and the IdP / login behavior.

Namespace

Drupal\samlauth

Code

public function login($return_to = NULL, array $parameters = []) {
  $config = $this->configFactory
    ->get('samlauth.authentication');
  $url = $this
    ->getSamlAuth('login')
    ->login($return_to, $parameters, FALSE, FALSE, TRUE, $config
    ->get('request_set_name_id_policy') ?? TRUE);
  if ($config
    ->get('debug_log_saml_out')) {
    $this->logger
      ->debug('Sending SAML authentication request: <pre>@message</pre>', [
      '@message' => $this
        ->getSamlAuth('login')
        ->getLastRequestXML(),
    ]);
  }
  return $url;
}