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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php namespace TestCAS\Http\Controllers;
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
8
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
     3
use Log;
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
     4
use phpCAS;
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
     5
0
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
class WelcomeController extends Controller
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
{
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
    /*
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
    |--------------------------------------------------------------------------
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
    | Welcome Controller
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
    |--------------------------------------------------------------------------
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
    |
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
    | This controller renders the "marketing page" for the application and
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
    | is configured to only allow guests. Like most of the other sample
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
    | controllers, you are free to modify or remove it as you desire.
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
    |
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
    */
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
    /**
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
     * Create a new controller instance.
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
     *
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
     * @return void
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
     */
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
    public function __construct()
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
    {
8
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    26
        //$this->middleware('auth.cas');
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    27
    }
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    28
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    29
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    30
    public function storePGT()
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    31
    {
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    32
        Log::info("Connecting to callback page");
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    33
        Log::info($_GET);
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    34
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    35
        if (!empty($_GET['pgtIou'])&&!empty($_GET['pgtId'])) {
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    36
          phpCAS::traceBegin();
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    37
          $pgt_iou=$_GET["pgtIou"];
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    38
          $pgt=$_GET["pgtId"];
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    39
          $fname="/home/vagrant/Code/storage/PGT/".$pgt_iou.'.plain';
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    40
          if (!file_exists($fname)) {
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    41
              touch($fname);
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    42
              // Chmod will fail on windows
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    43
              @chmod($fname, 0600);
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    44
              if ($f=fopen($fname, "w")) {
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    45
                  if (fputs($f, $pgt) === false) {
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    46
                      phpCAS::error('could not write PGT to `'.$fname.'\'');
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    47
                  }
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    48
                  phpCAS::trace('Successful write of PGT to `'.$fname.'\'');
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    49
                  fclose($f);
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    50
              } else {
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    51
                  phpCAS::error('could not open `'.$fname.'\'');
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    52
              }
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    53
          } else {
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    54
              phpCAS::error('File exists: `'.$fname.'\'');
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    55
          }
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    56
          phpCAS::traceEnd();
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    57
        }
0
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
    }
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
    /**
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
     * Show the application welcome screen to the user.
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
     *
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
     * @return Response
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
     */
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
    public function index()
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
    {
8
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    67
        Log::info("Connecting to index page");
0
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
        return view('welcome');
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
    }
8
5a0cbbe0922a CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents: 0
diff changeset
    70
0
1afc9d2ab94d first commit of cas auth env
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
}