You are here

public function ProxyCallbackController::callback in CAS 8

Same name and namespace in other branches
  1. 2.x src/Controller/ProxyCallbackController.php \Drupal\cas\Controller\ProxyCallbackController::callback()

Route callback for the ProxyGrantingTicket information.

This function stores the incoming PGTIOU and pgtId parameters so that the incoming response from the CAS Server can be looked up.

1 string reference to 'ProxyCallbackController::callback'
cas.routing.yml in ./cas.routing.yml
cas.routing.yml

File

src/Controller/ProxyCallbackController.php, line 68

Class

ProxyCallbackController
Class ProxyCallbackController.

Namespace

Drupal\cas\Controller

Code

public function callback() {
  $this->casHelper
    ->log(LogLevel::DEBUG, 'Proxy callback processing started.');

  // @TODO: Check that request is coming from configured CAS server to avoid
  // filling up the table with bogus pgt values.
  $request = $this->requestStack
    ->getCurrentRequest();

  // Check for both a pgtIou and pgtId parameter. If either is not present,
  // inform CAS Server of an error.
  if (!($request->query
    ->get('pgtId') && $request->query
    ->get('pgtIou'))) {
    $this->casHelper
      ->log(LogLevel::ERROR, "Either pgtId or pgtIou parameters are missing from the request.");
    return Response::create('Missing necessary parameters', 400);
  }
  else {

    // Store the pgtIou and pgtId in the database for later use.
    $pgt_id = $request->query
      ->get('pgtId');
    $pgt_iou = $request->query
      ->get('pgtIou');
    $this
      ->storePgtMapping($pgt_iou, $pgt_id);
    $this->casHelper
      ->log(LogLevel::DEBUG, "Storing pgtId %pgt_id with pgtIou %pgt_iou", [
      '%pgt_id' => $pgt_id,
      '%pgt_iou' => $pgt_iou,
    ]);

    // PGT stored properly, tell CAS Server to proceed.
    return Response::create('OK', 200);
  }
}