This repository has been archived by the owner on Sep 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
executable file
·300 lines (250 loc) · 9.2 KB
/
index.php
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<?php
require_once('config.php');
require_once('functions.php');
///////////////// model preparation ///////////////
// Omit php warnings in logs
$_SERVER += defineOnArray($_SERVER, array('eppn', 'persistent-id', 'affiliation', 'unscoped-affiliation', 'schacHomeOrganization', 'mail', 'displayName','o','sourceIdPEntityID'));
$eppn = $_SERVER['eppn'];
$persistentId = $_SERVER['persistent-id'];
$affiliation = $_SERVER['affiliation'];
$unscopedAffiliation = $_SERVER['unscoped-affiliation'];
$schacHomeOrganization = $_SERVER['schacHomeOrganization'];
$mail = $_SERVER['mail'];
$displayName = $_SERVER['displayName'];
$sourceIdPEntityID = $_SERVER['sourceIdPEntityID'];
$o = $_SERVER['o'];
$hasUid = false;
$hasAffiliation = false;
$hasOrganization = false;
if (isset($eppn) or isset($persistentId)) {
$hasUid = true;
}
if (isset($affiliation) or isset($unscopedAffiliation)) {
$hasAffiliation = true;
}
if (isset($schacHomeOrganization)) {
$hasOrganization = true;
}
$isOk = $hasUid && $hasOrganization && $hasAffiliation;
$idpEntityId = $sourceIdPEntityID;
$idpDisplayName;
if (!empty($o)) {
$idpDisplayName = $o;
} else if (!empty($schacHomeOrganization)) {
$idpDisplayName = $schacHomeOrganization;
} else if (!empty($idpEntityId)) {
$entityIdUrl = parse_url($idpEntityId);
if (!$entityIdUrl) {
$idpDisplayName = $entityIdUrl['host'];
} else {
$idpDisplayName = $idpEntityId;
}
} else {
$idpDisplayName = 'unknown';
}
# Store information about the session, format: date - IdP - result
$resultInFile = file_put_contents($ai_results_file, date("Y-m-d H:i:s") . ' - ' . $sourceIdPEntityID . ' - ' . ($isOk ? 1 : 0) . "\n", FILE_APPEND);
$resultInFile = ($resultInFile === false) ? false : true;
$resultOnProxy = 'NOT_TRIED';
# Send information to Proxy IdP if its OK. So it can be added
if ($isOk) {
$resultOnProxy = 'ERROR';
$response = post($ai_whitelist_idp,
array(
'entityId' => $sourceIdPEntityID,
'reason' => "Attributes checked by user"
)
);
if (!empty($response) && isJson($response)) {
$json = json_decode($response, true);
$resultOnProxy = $json['result'];
if ($resultOnProxy === 'ERROR') {
$resultOnProxy .= ", error msg: ".$json['msg'];
}
}
}
# set whole model into one var to easier manipulation
$model = array(
'isOk' => $isOk,
'hasUid' => $hasUid,
'hasAffiliation' => $hasAffiliation,
'hasOrganization' => $hasOrganization,
'idpDisplayName' => $idpDisplayName,
'resultInFile' => $resultInFile,
'resultOnProxy' => $resultOnProxy,
'idpEntityId' => $idpEntityId,
);
///////////////// view //////////////////
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $ai_instance_name;?> Attribute Release Test</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="shortcut icon" href="<?php echo $ai_shortcut_icon;?>" type="image/x-icon">
<link rel="apple-touch-icon" href="<?php echo $ai_shortcut_icon;?>" type="image/x-icon">
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.logo {
display: block;
width: 170px;
margin: 24px auto;
}
.result {
margin: 28px 0;
}
.result hr {
margin-top: 8px;
margin-bottom: 8px;
border-color: #ddd;
}
.result h1:first-child,
.result h2:first-child,
.result h3:first-child,
.result h4:first-child {
margin-top: 0;
}
.result h1:last-child,
.result h2:last-child,
.result h3:last-child,
.result h4:last-child {
margin-bottom: 0;
}
.panel-more {
margin: -11px 11px 11px -11px;
padding: 0 4px;
background: white;
}
.report-box .form-horizontal .control-label {
text-align: left;
}
</style>
</head>
<body>
<div class="container">
<img class="logo" src="<?php echo $ai_logo;?>">
<p>This application tests the compatibility of your identity provider with the <?php echo $ai_instance_name;?> AAI (Authentication and Authorisation Infrastructure). The results are automatically stored and used to determine if identity providers are ready to join the <?php echo $ai_instance_name;?> AAI.</p>
<div class="result panel panel-default">
<?php
if ($isOk and $resultOnProxy === 'ALREADY_THERE') {
// is OK and has been added
echo <<<EOD
<div class="panel-body">
<h2>Your institution <i>$idpDisplayName</i> is <span class="label label-success">already in the $ai_instance_name AAI</span></h2>
<h4>You can access your service with it</h4>
</div>
EOD;
} else if ($isOk and $resultOnProxy === 'ADDED') {
// is OK and has been added
echo <<<EOD
<div class="panel-body">
<h2>Your institution <i>$idpDisplayName</i> has been <span class="label label-success">successfully added</span> to the $ai_instance_name AAI</h2>
<h4>Please try to <b>access your service again</b></h4>
</div>
EOD;
} else if ($isOk) {
// is OK but not added
echo <<<EOD
<div class="panel-body">
<h2>Your institution <i>$idpDisplayName</i> <span class="text-success">is compatible</span> with the $ai_instance_name AAI but we had <span class="label label-warning">problem to add it automatically</span></h2>
</div>
EOD;
echo reportBox('Please try to <b>refresh this page</b> or report it so we can add it manually', $ai_report_idp, $model, !empty($_GET['mailSended']));
} else {
// is NOT OK
echo <<<EOD
<div class="panel-body">
<h2>Your institution <i>$idpDisplayName</i> can not be added because it is <span class="label label-danger">not compatible</span> with the $ai_instance_name AAI</h2>
</div>
<hr>
EOD;
echo reportBox('Please <b>report</b> it so that we can add your institution to the ' . $ai_instance_name . ' AAI', $ai_report_idp, $model, !empty($_GET['mailSended']));
}
?>
<div id="moreInfo" class="collapse">
<hr>
<div class="panel-body">
<h4><?php echo $ai_instance_name;?> AAI requires following attributes</h4>
<ul>
<li>
eduPersonPrincipalName <small><span class="label label-default">urn:oid:1.3.6.1.4.1.5923.1.1.1.6</span></small>
<i>- or -</i>
eduPersonTargetedId/persistentID <small><span class="label label-default">urn:oid:1.3.6.1.4.1.5923.1.1.1.10</span></small>
</li>
<li>
eduPersonAffiliation <small><span class="label label-default">urn:oid:1.3.6.1.4.1.5923.1.1.1.1</span></small>
<i>- or -</i>
eduPersonScopedAffiliation <small><span class="label label-default">urn:oid:1.3.6.1.4.1.5923.1.1.1.9</span></small>
</li>
<li>
schacHomeOrganization <small><span class="label label-default">urn:oid:1.3.6.1.4.1.25178.1.2.9</span></small>
</li>
</ul>
<?php
echo <<<EOD
<h4>Your IdP sends</h4>
<ul>
<li>
eduPersonPrincipalName: <b>{$eppn}</b>
<i>- or -</i>
eduPersonTargetedId/persistentID: <b>{$persistentId} </b>
EOD;
echo '<span class="glyphicon glyphicon-' . ($hasUid?'ok':'remove') . '" style="color: ' . ($hasUid?'green':'red') . ';"></span>';
echo <<<EOD
</li>
<li>
eduPersonAffiliation: <b>{$unscopedAffiliation}</b>
<i>- or -</i>
eduPersonScopedAffiliation: <b>{$affiliation} </b>
EOD;
echo '<span class="glyphicon glyphicon-' . ($hasAffiliation?'ok':'remove') . '" style="color: ' . ($hasAffiliation?'green':'red') . ';"></span>';
echo <<<EOD
</li>
<li>
schacHomeOrganization: <b>{$schacHomeOrganization} </b>
EOD;
echo '<span class="glyphicon glyphicon-' . ($hasOrganization?'ok':'remove') . '" style="color: ' . ($hasOrganization?'green':'red') . ';"></span>';
echo <<<EOD
</li>
</ul>
EOD;
?>
<h4><?php echo $ai_instance_name;?> AAI optionally consumes following attributes</h4>
<ul>
<li>
displayName <small><span class="label label-default">urn:oid:2.16.840.1.113730.3.1.241</span></small>
</li>
<li>
mail <small><span class="label label-default">urn:oid:0.9.2342.19200300.100.1.3</span></small>
</li>
</ul>
<?php
echo <<<EOD
<h4>Your IdP sends</h4>
<ul>
<li>
displayName: <b>{$displayName} </b>
</li>
<li>
mail: <b>{$mail} </b>
</li>
</ul>
EOD;
?>
</div>
</div>
<a class="pull-right panel-more" data-toggle="collapse" href="#moreInfo">technical info</a>
</div>
</div>
<hr>
<div class="container">
<p>This application doesn't store any personal data. We record just name of the identity provider and the aggregated result of the test.</p>
<p>support: <a href="mailto:<?php echo $ai_contact;?>"><?php echo $ai_contact;?></a></p>
</div>
</body>
</html>