|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* ***************************************************************************** |
|
4
|
|
|
* Contributions to this work were made on behalf of the GÉANT project, a |
|
5
|
|
|
* project that has received funding from the European Union’s Framework |
|
6
|
|
|
* Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus), |
|
7
|
|
|
* Horizon 2020 research and innovation programme under Grant Agreements No. |
|
8
|
|
|
* 691567 (GN4-1) and No. 731122 (GN4-2). |
|
9
|
|
|
* On behalf of the aforementioned projects, GEANT Association is the sole owner |
|
10
|
|
|
* of the copyright in all material which was developed by a member of the GÉANT |
|
11
|
|
|
* project. GÉANT Vereniging (Association) is registered with the Chamber of |
|
12
|
|
|
* Commerce in Amsterdam with registration number 40535155 and operates in the |
|
13
|
|
|
* UK as a branch of GÉANT Vereniging. |
|
14
|
|
|
* |
|
15
|
|
|
* Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. |
|
16
|
|
|
* UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK |
|
17
|
|
|
* |
|
18
|
|
|
* License: see the web/copyright.inc.php file in the file structure or |
|
19
|
|
|
* <base_url>/copyright.php after deploying the software |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* This page edits a federation. |
|
24
|
|
|
* |
|
25
|
|
|
* @author Stefan Winter <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
?> |
|
28
|
|
|
<?php |
|
29
|
|
|
require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php"; |
|
30
|
|
|
|
|
31
|
|
|
$auth = new \web\lib\admin\Authentication(); |
|
32
|
|
|
$deco = new \web\lib\admin\PageDecoration(); |
|
33
|
|
|
$validator = new \web\lib\common\InputValidation(); |
|
34
|
|
|
$uiElements = new web\lib\admin\UIElements(); |
|
35
|
|
|
$cat = new core\CAT(); |
|
36
|
|
|
|
|
37
|
|
|
$auth->authenticate(); |
|
38
|
|
|
$eduroamDb = new \core\ExternalEduroamDBData(); |
|
39
|
|
|
|
|
40
|
|
|
/// product name (eduroam CAT), then term used for "federation", then actual name of federation. |
|
41
|
|
|
echo $deco->defaultPagePrelude(sprintf(_("%s: RADIUS/TLS certificate management for %s"), \config\Master::APPEARANCE['productname'], $uiElements->nomenclatureFed)); |
|
42
|
|
|
$langObject = new \core\common\Language(); |
|
43
|
|
|
$fedId = $_GET['fed_id']; |
|
44
|
|
|
?> |
|
45
|
|
|
<script src="js/XHR.js" type="text/javascript"></script> |
|
46
|
|
|
<script src="js/option_expand.js" type="text/javascript"></script> |
|
47
|
|
|
<script type="text/javascript" src="../external/jquery/jquery.js"></script> |
|
48
|
|
|
<script type="text/javascript" src="../external/jquery/jquery-migrate.js"></script> |
|
49
|
|
|
</head> |
|
50
|
|
|
<body> |
|
51
|
|
|
|
|
52
|
|
|
<?php echo $deco->productheader("FEDERATION"); ?> |
|
53
|
|
|
|
|
54
|
|
|
<h1> |
|
55
|
|
|
<?php |
|
56
|
|
|
/// nomenclature for federation, then actual federation name |
|
57
|
|
|
printf(_("RADIUS/TLS certificate management for %s"), $uiElements->nomenclatureFed); |
|
58
|
|
|
?> |
|
59
|
|
|
</h1> |
|
60
|
|
|
<?php |
|
61
|
|
|
$user = new \core\User($_SESSION['user']); |
|
62
|
|
|
$mgmt = new \core\UserManagement(); |
|
63
|
|
|
$isFedAdmin = $user->isFederationAdmin(); |
|
64
|
|
|
|
|
65
|
|
|
// if not, send the user away |
|
66
|
|
|
if (!$isFedAdmin) { |
|
67
|
|
|
echo _("You do not have the necessary privileges to request server certificates."); |
|
68
|
|
|
exit(1); |
|
69
|
|
|
} |
|
70
|
|
|
// okay... we are indeed entitled to "do stuff" |
|
71
|
|
|
$feds = $user->getAttributes("user:fedadmin"); |
|
72
|
|
|
foreach ($feds as $oneFed) { |
|
73
|
|
|
if ($oneFed['value'] != $fedId) { |
|
74
|
|
|
continue; |
|
75
|
|
|
} |
|
76
|
|
|
$theFed = new \core\Federation($oneFed['value']); |
|
77
|
|
|
printf("<h2>" . _("Certificate Information for %s %s")."</h2>", $uiElements->nomenclatureFed, $theFed->name); |
|
78
|
|
|
foreach ($theFed->listTlsCertificates() as $oneCert) { |
|
79
|
|
|
if ($oneCert['STATUS'] == "REQUESTED") { |
|
80
|
|
|
$theFed->updateCertificateStatus($oneCert['REQSERIAL']); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
echo "<table>"; |
|
84
|
|
|
echo "<tr><th>"._("Request Serial")."</th><th>"._("Distinguished Name")."</th><th>Status</th><th>"._("Expiry")."</th><th>"._("Download")."</th></tr>"; |
|
85
|
|
|
foreach ($theFed->listTlsCertificates() as $oneCert) { // fetch list a second time, in case we got a cert |
|
86
|
|
|
$status = $oneCert['STATUS']; |
|
87
|
|
|
echo "<tr>"; |
|
88
|
|
|
echo "<td>" . $oneCert['REQSERIAL'] . "</td><td>" . $oneCert['DN'] . "</td><td>" . $status . "</td><td>" . $oneCert['EXPIRY'] . "</td>"; |
|
89
|
|
|
if ($status == "ISSUED") { |
|
90
|
|
|
?> |
|
91
|
|
|
<td> |
|
92
|
|
|
<form action='inc/showCert.inc.php' onsubmit='popupRedirectWindow(this); return false;' accept-charset='UTF-8' method="POST"> |
|
93
|
|
|
<input type="hidden" name="certdata" value="<?php echo $oneCert['CERT'];?>"/> |
|
94
|
|
|
<button type="submit"><?php echo _("Display");?></button> |
|
95
|
|
|
</form> |
|
96
|
|
|
<td> |
|
97
|
|
|
<?php |
|
98
|
|
|
} |
|
99
|
|
|
echo "</tr>"; |
|
100
|
|
|
} |
|
101
|
|
|
echo "</table>"; |
|
102
|
|
|
|
|
103
|
|
|
if (count($eduroamDb->listExternalTlsServersFederation($theFed->tld)) > 0) { |
|
104
|
|
|
?> |
|
105
|
|
|
<form action="action_req_certificate.php" method="POST"> |
|
106
|
|
|
<input type="hidden" name='fed_id' value='<?php echo $fedId; ?>'/> |
|
|
|
|
|
|
107
|
|
|
<button type="submit" name="newreq" id="newreq" value="<?php echo \web\lib\common\FormElements::BUTTON_CONTINUE ?>"><?php echo _("Request new Certificate"); ?></button> |
|
108
|
|
|
</form> |
|
109
|
|
|
<?php |
|
110
|
|
|
} else { |
|
111
|
|
|
?> |
|
112
|
|
|
<span style="color: red"><?php echo sprintf(_("You can not request certificates because there is no server information for %s in the eduroam DB."), $theFed->tld); ?></span> |
|
113
|
|
|
<?php |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
echo $deco->footer(); |
|
117
|
|
|
|
$fedIdcan contain request data and is used in html attribute with double-quotes context(s) leading to a potential security vulnerability.1 path for user data to reach this point
$_GET,and$_GET['fed_id']is assigned to$fedIdin web/admin/overview_certificates.php on line 43
Preventing Cross-Site-Scripting Attacks
Cross-Site-Scripting allows an attacker to inject malicious code into your website - in particular Javascript code, and have that code executed with the privileges of a visiting user. This can be used to obtain data, or perform actions on behalf of that visiting user.
In order to prevent this, make sure to escape all user-provided data:
General Strategies to prevent injection
In general, it is advisable to prevent any user-data to reach this point. This can be done by white-listing certain values:
if ( ! in_array($value, array('this-is-allowed', 'and-this-too'), true)) { throw new \InvalidArgumentException('This input is not allowed.'); }For numeric data, we recommend to explicitly cast the data: