-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter.php
57 lines (46 loc) · 1.71 KB
/
filter.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
<?php
10 => array(
'class' => 'saml:NameIDAttribute',
'attribute' => 'uid',
'format' => '%V',
),
50 => array(
'class' => 'core:PHP',
'code' => '
$uid = $attributes["uid"][0];
$uid = substr($uid, 4);
$url = "http://localhost:8080";
$request = "/people/".$uid."?properties[givenName]&properties[familyName]&properties[additionalName]&properties[email]&properties[roles][]=roleName";
$api_secret = "****";
$api_passwd = "****";
$url = $url.$request;
$options = array(
"http" => array(
"header" => "Content-type: application/json\r\n".
"Authorization: Basic " .base64_encode($api_secret.":".$api_passwd),
"method" => $method,
"content" => json_encode($data, JSON_UNESCAPED_SLASHES, JSON_NUMERIC_CHECK)
),
"ssl" => array(
"verify_peer" => false,
"verify_peer_name" => false,
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$persondata = json_decode($result, true);
$roles = array();
$rolesMap = $persondata["roles"];
foreach ($rolesMap as $key => $value) {
$tmpRole =$value["roleName"];
$tmpRole = strtolower($tmpRole);
$roles[] = $tmpRole;
}
$attributes["givenName"] = array($persondata["givenName"]);
$attributes["sn"] = array($persondata["familyName"]);
$attributes["displayName"] = array($persondata["familyName"].", ".$persondata["givenName"]." ".$persondata["additionalName"]);
$attributes["mail"] = array($persondata["email"]);
$attributes["memberOf"] = $roles;
',
),
?>