File: user.php

package info (click to toggle)
simplesamlphp 1.13.1-2%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 11,304 kB
  • sloc: php: 65,124; xml: 629; python: 376; sh: 193; perl: 185; makefile: 43
file content (72 lines) | stat: -rw-r--r-- 1,865 bytes parent folder | download | duplicates (2)
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
<?php

if (isset($_SERVER['PATH_INFO'])) {
	$userId = substr($_SERVER['PATH_INFO'], 1);
} else {
	$userId = FALSE;
}

$globalConfig = SimpleSAML_Configuration::getInstance();
$server = sspmod_openidProvider_Server::getInstance();
$identity = $server->getIdentity();

if (!$userId && $identity) {
	/*
	 * We are accessing the front-page, but are logged in.
	 * Redirect to the correct page.
	 */
	SimpleSAML_Utilities::redirectTrustedURL($identity);
}

/* Determine whether we are at the users own page. */
if ($userId && $userId === $server->getUserId()) {
	$ownPage = TRUE;
} else {
	$ownPage = FALSE;
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
	if ($ownPage) {
		foreach ($_POST as $k => $v) {
			$op = explode('_', $k, 2);
			if (count($op) == 1 || $op[0] !== 'remove') {
				continue;
			}

			$site = $op[1];
			$site = pack("H*" , $site);
			$server->removeTrustRoot($identity, $site);
		}
	}

	SimpleSAML_Utilities::redirectTrustedURL($identity);
}

if ($ownPage) {
	$trustedSites = $server->getTrustRoots($identity);
} else {
	$trustedSites = array();
}

$userBase = SimpleSAML_Module::getModuleURL('openidProvider/user.php');

$xrds = SimpleSAML_Module::getModuleURL('openidProvider/xrds.php');
if ($userId !== FALSE) {
	$xrds = SimpleSAML_Utilities::addURLparameter($xrds, array('user' => $userId));
}

$as = $server->getAuthSource();
$t = new SimpleSAML_XHTML_Template($globalConfig, 'openidProvider:user.tpl.php');
$t->data['identity'] = $identity;
$t->data['loggedInAs'] = $server->getUserId();
$t->data['loginURL'] = $as->getLoginURL($userBase);
$t->data['logoutURL'] = $as->getLogoutURL();
$t->data['ownPage'] = $ownPage;
$t->data['serverURL'] = $server->getServerURL();
$t->data['trustedSites'] = $trustedSites;
$t->data['userId'] = $userId;
$t->data['userIdURL'] = $userBase . '/' . $userId;
$t->data['xrdsURL'] = $xrds;

$t->show();
exit(0);