-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShibboleth.sso.php
More file actions
62 lines (58 loc) · 2.24 KB
/
Shibboleth.sso.php
File metadata and controls
62 lines (58 loc) · 2.24 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
<?php
namespace ShibPoseur;
/**
* This file serves as the primary controller to which all Shibboleth actions are routed
*
* For PHP applications running on Apache, it is recommended to use the auto_prepend_file directive
* in .htaccess or httpd.conf to force the file to be included
*
* File inclusion is necessary for the cookie parameters to be read and set
* on occasions when a Shibboleth.sso session action is not performed. This mimics
* the behavior of the Shibboleth Native SP, automatically populating the $_SERVER
* environment.
*
* To route Shibboleth action requests to this script, configure Apache mod_rewrite accordingly:
*
* # If used in .htaccess at the site document root:
* RewriteEngine On
* RewriteRule ^Shibboleth\.sso(?:/(.*)) path/to/shibposeur/Shibboleth.sso.php?shibaction=$1 [L,QSA]
*
* # If used in VirtualHost or Server context:
* RewriteEngine On
* RewriteRule ^/Shibboleth.sso(?:(.*)) /path/to/shibposeur/Shibboleth.sso.php?shibaction=$1 [L,QSA]
*/
require_once __DIR__ . '/ShibPoseur.php';
require_once __DIR__ . '/Exception/ConfigurationException.php';
require_once __DIR__ . '/Exception/ViewNotFoundException.php';
$poseur = new ShibPoseur();
// Empty shibaction parameter indicates a basic file include
// which populates the existing faux-shib session
if (empty($_GET['shibaction'])) {
// If this script was not requested via http and is a file include
// then just load up the existing session
if (realpath($_SERVER['SCRIPT_FILENAME']) !== realpath(__FILE__)) {
// Load the session from the cookie
if ($poseur->hasSessionCookie()) {
$poseur->loadCookie();
}
}
// This was an HTTP request but with no requested action, which would be an
// error state in a real shib SP:
else {
throw new Exception\ConfigurationException();
}
return;
}
else {
// If forcing auth, do a silent logout first
if (!empty($_GET['forceAuthn']) && !$poseur->hasLoginScreenCookie()) {
$poseur->Logout('', false);
}
$url = !empty($_GET['target']) ? trim($_GET['target']) : (!empty($_GET['return']) ? trim($_GET['return']) : '/');
if (in_array($_GET['shibaction'], ShibPoseur::getPublicActions())) {
$poseur->{$_GET['shibaction']}($url);
}
else {
throw new Exception\ConfigurationException();
}
}