author | durandn |
Wed, 27 May 2015 15:34:06 +0200 | |
changeset 8 | 5a0cbbe0922a |
parent 0 | 1afc9d2ab94d |
child 9 | 3166a35f5f0d |
permissions | -rw-r--r-- |
0 | 1 |
<?php namespace TestCAS\Http\Controllers; |
2 |
||
3 |
use Cas; |
|
8
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
0
diff
changeset
|
4 |
use phpCAS; |
0 | 5 |
|
6 |
class HomeController extends Controller { |
|
7 |
||
8 |
/* |
|
9 |
|-------------------------------------------------------------------------- |
|
10 |
| Home Controller |
|
11 |
|-------------------------------------------------------------------------- |
|
12 |
| |
|
13 |
| This controller renders your application's "dashboard" for users that |
|
14 |
| are authenticated. Of course, you are free to change or remove the |
|
15 |
| controller as you wish. It is just here to get your app started! |
|
16 |
| |
|
17 |
*/ |
|
18 |
||
19 |
/** |
|
20 |
* Create a new controller instance. |
|
21 |
* |
|
22 |
* @return void |
|
23 |
*/ |
|
24 |
public function __construct() |
|
25 |
{ |
|
26 |
$this->middleware('auth.cas'); |
|
27 |
} |
|
28 |
||
29 |
/** |
|
30 |
* Show the application dashboard to the user. |
|
31 |
* |
|
32 |
* @return Response |
|
33 |
*/ |
|
34 |
public function index() |
|
35 |
{ |
|
8
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
0
diff
changeset
|
36 |
$pt="Error getting PT"; |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
0
diff
changeset
|
37 |
$pt=phpCAS::retrievePT(env("LDT_URL")."/api/ldt/1.0/projects/".env("TEST_PROJECT_ID")."/?format=json", $err_code, $err_msg); |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
0
diff
changeset
|
38 |
$ch=curl_init(env("LDT_URL")."/api/ldt/1.0/projects/".env("TEST_PROJECT_ID")."/?format=json&casticket=".$pt); |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
0
diff
changeset
|
39 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
0
diff
changeset
|
40 |
$proxiedRequestResponse=curl_exec($ch); |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
0
diff
changeset
|
41 |
curl_close($ch); |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
0
diff
changeset
|
42 |
|
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
0
diff
changeset
|
43 |
$loginUrl=env("LDT_URL")."/accounts/caslogin"; |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
0
diff
changeset
|
44 |
|
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
0
diff
changeset
|
45 |
return view('home')->with( |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
0
diff
changeset
|
46 |
array("pt" => $pt, "err_code" => $err_code, "err_msg" => $err_msg, "proxiedRequestResponse" => $proxiedRequestResponse, 'loginUrl' => $loginUrl) |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
0
diff
changeset
|
47 |
); |
0 | 48 |
} |
49 |
||
50 |
/** |
|
51 |
* logout |
|
52 |
* |
|
53 |
* @return Response |
|
54 |
*/ |
|
55 |
public function logout() |
|
56 |
{ |
|
57 |
cas::logout(['service'=>url('/')]); |
|
58 |
return redirect()->route('index'); |
|
59 |
} |
|
60 |
||
61 |
} |