authserver/testCAS/app/Http/Controllers/WelcomeController.php
author durandn
Wed, 27 May 2015 15:34:06 +0200
changeset 8 5a0cbbe0922a
parent 0 1afc9d2ab94d
permissions -rw-r--r--
CAS Authentication (normal and proxy) + local Homestead vm

<?php namespace TestCAS\Http\Controllers;

use Log;
use phpCAS;

class WelcomeController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Welcome Controller
    |--------------------------------------------------------------------------
    |
    | This controller renders the "marketing page" for the application and
    | is configured to only allow guests. Like most of the other sample
    | controllers, you are free to modify or remove it as you desire.
    |
    */

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        //$this->middleware('auth.cas');
    }


    public function storePGT()
    {
        Log::info("Connecting to callback page");
        Log::info($_GET);

        if (!empty($_GET['pgtIou'])&&!empty($_GET['pgtId'])) {
          phpCAS::traceBegin();
          $pgt_iou=$_GET["pgtIou"];
          $pgt=$_GET["pgtId"];
          $fname="/home/vagrant/Code/storage/PGT/".$pgt_iou.'.plain';
          if (!file_exists($fname)) {
              touch($fname);
              // Chmod will fail on windows
              @chmod($fname, 0600);
              if ($f=fopen($fname, "w")) {
                  if (fputs($f, $pgt) === false) {
                      phpCAS::error('could not write PGT to `'.$fname.'\'');
                  }
                  phpCAS::trace('Successful write of PGT to `'.$fname.'\'');
                  fclose($f);
              } else {
                  phpCAS::error('could not open `'.$fname.'\'');
              }
          } else {
              phpCAS::error('File exists: `'.$fname.'\'');
          }
          phpCAS::traceEnd();
        }
    }

    /**
     * Show the application welcome screen to the user.
     *
     * @return Response
     */
    public function index()
    {
        Log::info("Connecting to index page");
        return view('welcome');
    }

}