Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 2fc87bb

Browse files
authored
Merge pull request #22 from pajavyskocil/ForceAup
New version of ForceAup module
2 parents 9e12729 + ac68e2d commit 2fc87bb

File tree

10 files changed

+465
-77
lines changed

10 files changed

+465
-77
lines changed

ForceAup-configuration.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Configuration of ForceAup
2+
-
3+
1.Create these attributes in Perun:
4+
- urn:perun:entityless:attribute-def:def:orgAups
5+
- Type: LinkedHashMap
6+
- Unique: no
7+
- Read:
8+
- Write:
9+
10+
11+
- urn:perun:user:attribute-def:def:aups
12+
- Type: LinkedHashMap
13+
- Unique: no
14+
- Read: SELF, FACILITY, VO
15+
- Write:
16+
17+
18+
- urn:perun:vo:attribute-def:def:aup
19+
- Type: LargeString
20+
- Unique: no
21+
- Read: VO
22+
- Write: VO
23+
24+
25+
- urn:perun:facility:attribute-def:def:reqAups
26+
- Type: ArrayList
27+
- Unique: no
28+
- Read: FACILITY
29+
- Write: FACILITY
30+
31+
32+
- urn:perun:facility:attribute-def:virt:voShortNames
33+
- Type: ArrayList
34+
- Unique: no
35+
- Read: FACILITY
36+
- Write: FACILITY
37+
38+
2.Configure SimpleSAMLphp to use ForceAup:
39+
40+
- Add this configuration into metadata file saml20-idp-hosted.php
41+
42+
```
43+
40 => array(
44+
'class' => 'perun:ProxyFilter',
45+
'filterSPs' => $perunEntityIds,
46+
'config' => array(
47+
'class' => 'perun:ForceAup',
48+
'uidAttr' => 'uid',
49+
'interface' => 'rpc',
50+
'perunAupsAttr' => 'urn:perun:entityless:attribute-def:def:orgAups',
51+
'perunUserAupAttr' => 'urn:perun:user:attribute-def:def:aups',
52+
'perunVoAupAttr' => 'urn:perun:vo:attribute-def:def:aup',
53+
'perunFacilityReqAupsAttr' => 'urn:perun:facility:attribute-def:def:reqAups',
54+
'facilityVoShortNames' => 'urn:perun:facility:attribute-def:virt:voShortNames'
55+
),
56+
),
57+
```
58+
59+
3.Fill the attributes and set list of required Aups (attr reqAups) and voShortNames (optional) for each facility

dictionaries/perun.definition.json

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,23 @@
2020
"cs": "nebo"
2121
},
2222
"force-aup-tpl_aup": {
23-
"en": "Acceptable Usage Policy",
24-
"cs": "Podmíny užití"
23+
"en": "Acceptable usage policy",
24+
"cs": "Podmínky užití"
25+
},
26+
"force-aup-tpl_aup_organization": {
27+
"en": "Acceptable usage policy for organization ",
28+
"cs": "Podmínky užití služeb v organizaci "
29+
},
30+
"force-aup-tpl_aup_redirect": {
31+
"en": "See the acceptable usage policy in version ",
32+
"cs": "Podmínky užití ve verzi "
33+
},
34+
"force-aup-tpl_aup_accept": {
35+
"en": "You must agree to the following acceptable usage policies: ",
36+
"cs": "Musíte souhlasit s následujícími podmínkami užití: "
2537
},
2638
"force-aup-tpl_agree": {
27-
"en": "I agree with the Acceptable Usage Policy",
39+
"en": "I agree with the acceptable usage policy",
2840
"cs": "Souhlasím s podmínkami užití"
2941
},
3042
"warning-test-sp-tpl_text": {
@@ -34,5 +46,13 @@
3446
"continue": {
3547
"en": "Continue",
3648
"cs": "Pokračovat"
49+
},
50+
"here": {
51+
"en": "here.",
52+
"cs": "zde."
53+
},
54+
"organization": {
55+
"en": "Organization / Virtual Organization ",
56+
"cs": "Organizace / Virtuální organizace "
3757
}
3858
}

lib/Adapter.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,41 @@ public abstract function getSpGroups($spEntityId, $vo);
6969
*/
7070
public abstract function getUserAttributes($user, $attrNames);
7171

72+
/**
73+
* @param string $attrName
74+
* @return array of all entityless attributes with attrName (for all namespaces of same attribute).
75+
*/
76+
public abstract function getEntitylessAttribute($attrName);
77+
78+
/**
79+
* @param sspmod_perun_model_Vo $vo
80+
* @param array $attrNames
81+
* @return array associative of attributes. Keys are attribute names
82+
* and values are attr values (can be null, string, array, associative array)* @return
83+
*/
84+
public abstract function getVoAttributes($vo, $attrNames);
85+
86+
/**
87+
* @param sspmod_perun_model_Facility $facility
88+
* @param string $attrName
89+
* @return array with attribute value
90+
*/
91+
public abstract function getFacilityAttribute($facility, $attrName);
92+
93+
/**
94+
* @param string $spEntityId
95+
* @return sspmod_perun_model_Facility entities[]
96+
*/
97+
public abstract function getFacilitiesByEntityId($spEntityId);
98+
7299
/**
73100
* @param string $spEntityId entity id of the sp
74101
* @param int $userId
75102
* @return sspmod_perun_model_Group[] from vo which are assigned to all facilities with spEntityId for this userId
76103
*/
77104
public abstract function getUsersGroupsOnFacility($spEntityId, $userId);
78105

106+
79107
/**
80108
* @param sspmod_perun_model_HasId[] $entities
81109
* @return sspmod_perun_model_HasId[] without duplicates

lib/AdapterLdap.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,29 @@ public function getUserAttributes($user, $attrNames)
139139
return $attributes;
140140
}
141141

142+
public function getFacilitiesByEntityId($spEntityId)
143+
{
144+
// TODO: Implement getEntityByEntityId() method.
145+
}
146+
147+
public function getEntitylessAttribute($attrName)
148+
{
149+
throw new BadMethodCallException("NotImplementedException");
150+
// TODO: Implement getEntitylessAttribute() method.
151+
}
152+
153+
public function getVoAttributes($vo, $attrNames)
154+
{
155+
throw new BadMethodCallException("NotImplementedException");
156+
// TODO: Implement getVoAttribute() method.
157+
}
158+
159+
public function getFacilityAttribute($facility, $attrName)
160+
{
161+
throw new BadMethodCallException("NotImplementedException");
162+
// TODO: Implement getFacilityAttribute() method.
163+
}
164+
142165

143166
public function getUsersGroupsOnFacility($spEntityId, $userId)
144167
{
@@ -172,4 +195,5 @@ public function getUsersGroupsOnFacility($spEntityId, $userId)
172195
return $resultGroups;
173196
}
174197

198+
175199
}

lib/AdapterRpc.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,49 @@ public function getUserAttributes($user, $attrNames)
153153
return $attributes;
154154
}
155155

156+
public function getEntitylessAttribute($attrName)
157+
{
158+
$perunAttrs = sspmod_perun_RpcConnector::get('attributesManager', 'getEntitylessAttributes', array(
159+
'attrName' => $attrName,
160+
));
161+
162+
$attributes = array();
163+
foreach ($perunAttrs as $perunAttr) {
164+
$attributes[key($perunAttr['value'])] = $perunAttr['value'][key($perunAttr['value'])];
165+
}
166+
167+
return $attributes;
168+
169+
}
170+
171+
public function getVoAttributes($vo, $attrNames)
172+
{
173+
$perunAttrs = sspmod_perun_RpcConnector::get('attributesManager', 'getAttributes', array(
174+
'vo' => $vo->getId(),
175+
'attrNames' => $attrNames,
176+
));
177+
178+
$attributes = array();
179+
foreach ($perunAttrs as $perunAttr) {
180+
181+
$perunAttrName = $perunAttr['namespace'] . ":" . $perunAttr['friendlyName'];
182+
183+
$attributes[$perunAttrName] = $perunAttr['value'];
184+
}
185+
186+
return $attributes;
187+
}
188+
189+
public function getFacilityAttribute($facility, $attrName)
190+
{
191+
$perunAttr = sspmod_perun_RpcConnector::get('attributesManager', 'getAttribute', array(
192+
'facility' => $facility->getId(),
193+
'attributeName' => $attrName,
194+
));
195+
196+
return $perunAttr['value'];
197+
}
198+
156199

157200
public function getUsersGroupsOnFacility($spEntityId, $userId)
158201
{
@@ -197,4 +240,17 @@ public function getUsersGroupsOnFacility($spEntityId, $userId)
197240
return $allGroups;
198241
}
199242

243+
public function getFacilitiesByEntityId($spEntityId)
244+
{
245+
$perunAttrs = sspmod_perun_RpcConnector::get('facilitiesManager', 'getFacilitiesByAttribute', array(
246+
'attributeName' => 'urn:perun:facility:attribute-def:def:entityID',
247+
'attributeValue' => $spEntityId,
248+
));
249+
$facilities = array();
250+
foreach ($perunAttrs as $perunAttr) {
251+
array_push($facilities, new sspmod_perun_model_Facility($perunAttr['id'], $perunAttr['name'], $spEntityId));
252+
}
253+
return $facilities;
254+
}
255+
200256
}

0 commit comments

Comments
 (0)