-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcas.php
More file actions
82 lines (70 loc) · 2.48 KB
/
Copy pathcas.php
File metadata and controls
82 lines (70 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
session_start();
$currentURL = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
// create a new curl resource
$ch = curl_init();
//Script #2 in process
//This code works running the following:
//Apache/1.3.33 (Unix) PHP/4.3.10 mod_ssl/2.8.22 OpenSSL/0.9.7e
?>
<html>
<head>
<script language="javascript">
function redirect(){
window.document.location = 'https://cas.iu.edu/cas/login?cassvc=ANY&casurl=<?php echo $currentURL;?>';
}
</script>
<title>Publications</title>
</head>
<?php
if (isset($_GET["casticket"])) {
//set up validation URL to ask CAS if ticket is good
$_url = 'https://cas.iu.edu/cas/validate';
$cassvc = 'ANY'; //search kb.indiana.edu for "cas application code" to determine code to use here in place of "appCode"//Allow any type of account to login
$casurl = $currentURL; //same base URL sent in authentication request in homePage.php//Send back to the login page
$params = "cassvc=$cassvc&casticket=$_GET[casticket]&casurl=$casurl";
$urlNew = "$_url?$params";
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $urlNew);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
//curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt ($ch, CURLOPT_CAINFO, "/etc/certificates/cacert.pem");
// grab URL and pass it to the browser
$handle = curl_exec($ch);
// close curl resource, and free up system resources
curl_close($ch);
//CAS sending response on 2 lines. First line contains "yes" or "no". If "yes", second line contains username (otherwise, it is empty).
$retArray = explode("\n", $handle);
$access = trim($retArray[0]);
$user = trim($retArray[1]);
//send user back to homePage.php with validated username
if ($access == "yes")
{
$_SESSION['username'] = $user;
if ((isset($_GET['owner'])) && (isset($_GET['currentCollection'])))
{
$_SESSION['owner'] = $_GET['owner'];
$_SESSION['currentCollection'] = $_GET['currentCollection'];
}
?>
<body>
<form action="<?php echo substr($currentURL,0,strripos($currentURL,"/"))."/index.php";?>" method="post" name="the_form">
<input type=hidden name=user VALUE=<?php echo $_SESSION['owner']; ?>>
</form>
<script>
the_form.submit();
</script>
</body>
<?php
}
}
else {
?>
<body onLoad="redirect();">
</body>
<?php
}
?>
</html>