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

Commit 9799a40

Browse files
author
Dominik František Bučík
authored
Merge pull request #250 from dBucik/dev2
feat: New Authproc filters
2 parents d508332 + 77729ea commit 9799a40

26 files changed

+1831
-30
lines changed

config-templates/processFilterConfigurations-example.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,152 @@ Example how to enable filter AttributeMap:
160160
// 'interface' => 'rpc', # optional, rpc/ldap, default rpc
161161
],
162162
```
163+
164+
## ExtractRequestAttribute
165+
166+
Filter is intended to extract an attribute specified by set of keys forming the chain of keys in the `$request` variable into the configured destination attribute.
167+
168+
Configuration options:
169+
* `attr_name`: specifies attribute name, into which the extracted value will be stored
170+
* `request_keys`: string, which contains a semicolon (`;`) separated chain of keys that are examined in the state. Numeric keys are automatically treated as array indexes. For instance, value `'saml:AuthenticatingAuthority;0'` will be treated as code `$request['saml:AuthenticatingAuthority'][0]`. In case of this value being empty, exception is thrown. Otherwise, extracted value is stored into the configured destination attribute.
171+
* `fail_on_nonexisting_keys`: `true` or `false`, specifies if in case of missing key in the request variable the filter should terminate with an exception or not
172+
* `default_value`: array, which will be set as default value, if the configured keys did not lead to value
173+
174+
```php
175+
// EXTRACT AUTHENTICATING ENTITY INTO authenticating_idp attribute
176+
1 => [
177+
'class' => 'perun:ExtractRequestAttribute',
178+
'attr_name' => 'authenticating_idp',
179+
'request_keys' => 'saml:AuthenticatingAuthority;0',
180+
'fail_on_nonexisting_keys' => 'true',
181+
'default_value' => null,
182+
],
183+
```
184+
185+
## PerunUser
186+
187+
Filter tries to identify the Perun user. It uses the combination of user identifier and IdP identifier to find the user (or to be more precise, the user identity and associated user account). If it can, the user object is set to `$request` parameter into `$request[PerunConstants::PERUN][PerunConstants::USER]`. Otherwise, user is forwarded to configured registration.
188+
189+
Configuration options:
190+
* `interface`: specifies what interface of Perun should be used to fetch data. See class `SimpleSAML\Module\perun\PerunAdapter` for more details.
191+
* `uid_attrs`: list of attributes that contain user identifiers to be used for identification. The order of the items in the list represents the priority.
192+
* `idp_id_attr`: name of the attribute (from `$request['Attributes']` array), which holds EntityID of the identity provider that has performed the authentication.
193+
* `register_url`: URL to which the user will be forwarded for registration. Leave empty to use the Perun registrar.
194+
* `callback_parameter_name`: name of the parameter wich will hold callback URL, where the user should be redirected after the registration on URL configured in the `register_url` property.
195+
* `perun_register_url`: the complete URL (including vo and group) to which user will be redirected, if `register_url` has not been configured. Parameters targetnew, targetexisting and targetextended will be set to callback URL to continue after the registration is completed.
196+
197+
```php
198+
2 => [
199+
'class' => 'perun:PerunUser',
200+
'interface' => 'LDAP',
201+
'uid_attrs' => ['eduPersonUniqueId', 'eduPersonPrincipalName'],
202+
'idp_id_attr' => 'authenticating_idp',
203+
'register_url' => 'https://signup.cesnet.cz/',
204+
'callback_parameter_name' => 'callback',
205+
'perun_register_url' => 'https://signup.perun.cesnet.cz/fed/registrar/?vo=cesnet'
206+
],
207+
```
208+
209+
## PerunAup
210+
211+
Filter fetches the given attribute holding approved AUP and checks, if expected value is set in the attribute or not. If not, it redirects the user to specified registration component, where user will be asked to approve the AUP.
212+
213+
Configuration options:
214+
* `interface`: specifies what interface of Perun should be used to fetch data. See class `SimpleSAML\Module\perun\PerunAdapter` for more details.
215+
* `attribute`: name of the attribute, which will be fetched from Perun and holds the value of approved AUP.
216+
* `value`: value that is expected in the attribute as mark of approved AUP. Expected is a string.
217+
* `approval_url`: URL to which the user will be forwarded for registration. Leave empty to use the Perun registrar.
218+
* `callback_parameter_name`: name of the parameter wich will hold callback URL, where the user should be redirected after the AUP approval on URL configured in the `approval_url` property.
219+
* `perun_register_url`: the complete URL (including vo and group) to which user will be redirected, if `approval_url` has not been configured. Parameters targetnew, targetexisting and targetextended will be set to callback URL to continue after the AUP approval is completed.
220+
221+
```php
222+
3 => [
223+
'class' => 'perun:PerunAup',
224+
'interface' => 'LDAP',
225+
'value' => 'aup_2020_01_01',
226+
'attribute' => 'approved_aup',
227+
'approval_url' => 'https://signup.cesnet.cz/aup/',
228+
'callback_parameter_name' => 'callback',
229+
'perun_approval_url' => 'https://signup.perun.cesnet.cz/fed/registrar/?vo=cesnet&group=aup'
230+
],
231+
```
232+
233+
## DropUserAttributes
234+
235+
Drops specified user attributes from the `$request['Attributes']` variable.
236+
237+
Configuration options:
238+
* `attribute_names`: list of attribute names which will be dropped.
239+
240+
```php
241+
10 => [
242+
'class' => 'perun:DropUserAttributes',
243+
'attribute_names' => ['aup', 'eppn', 'eduPersonTargetedID']
244+
],
245+
```
246+
247+
## QualifyNameID
248+
249+
Adds qualifiers into NameID based on the configuration
250+
251+
Configuration options:
252+
* `name_id_attribute`: Attribute (NameID) which should be qualified
253+
* `name_qualifier_attribute`: User attribute with value, which will be set as the NameQualifier part of the NameID. Leave empty to use static value configured via option `name_qualifier`.
254+
* `name_qualifier`: Static value which will be set as the NameQualifier part of the NameID.
255+
* `sp_name_qualifier_attribute`: User attribute with value, which will be set as the SPNameQualifier part of the NameID. Leave empty to use static value configured via option `sp_name_qualifier`.
256+
* `sp_name_qualifier`: Static value which will be set as the SPNameQualifier part of the NameID.
257+
258+
```php
259+
11 => [
260+
'class' => 'perun:QualifyNameID',
261+
'name_id_attribute' => 'eduPersonTargetedID',
262+
'name_qualifier_attribute' => 'SourceIdPEntityID',
263+
'name_qualifier' => 'https://login.cesnet.cz/idp/',
264+
'sp_name_qualifier_attribute' => 'ProxyEntityID',
265+
'sp_name_qualifier' => 'https://login.cesnet.cz/proxy/',
266+
],
267+
```
268+
269+
## GenerateIdPAttributes
270+
271+
Gets metadata of the IdP specified by `idp_identifier_attribute` value and tries to set the specified keys from IdP metadata into attributes.
272+
273+
Configuration options:
274+
* `idp_identifier_attribute`: Attribute holding the identifier of the Authenticating IdP
275+
* `attribute_map`: Map of IdP metadata attributes, where keys are the colon separated keys that will be searched in IdP metadata and values are the destination attribute names.
276+
277+
```php
278+
20 => [
279+
'class' => 'perun:GenerateIdPAttributes',
280+
'idp_identifier_attribute' => 'sourceIdPEntityID',
281+
'attribute_map' => [
282+
'name:en' => 'sourceIdPName',
283+
'OrganizationName:en' => 'sourceIdPOrganizationName',
284+
'OrganizationURL:en' => 'sourceIdPOrganizationURL',
285+
],
286+
],
287+
```
288+
## SpAuthorization
289+
290+
Performs authorization check define dby the SP based on group membership in Perun. User has to be valid member of at least one of the groups assigned to resources of the facility representing the service. If not satisfied, the filter check if registration is enabled. In case of enabled registration, user is forwarded to custom registration link (if configured), or to a dynamic form, where user will select the combination of VO and group to which he/she applies for access. Form then forwards user to Perun registration component. In all other cases, user is forwarded to access denied page.
291+
NOTE: for correct functionality, RPC adapter must be available, as other adapters cannot fetch info about what groups allow registration (have registration forms) and similar data.
292+
293+
Configuration options:
294+
* `interface`: specifies what interface of Perun should be used to fetch data. See class `SimpleSAML\Module\perun\PerunAdapter` for more details.
295+
* `registrar_url`: URL where Perun registration component is located. Expected URL is the base, without any parameters.
296+
* `check_group_membership_attr`: mapping to the attribute containing flag, if membership check should be performed.
297+
* `vo_short_names_attr`: mapping to the attribute containing shortnames of the VOs for which the service has resources (gives access to the groups).
298+
* `registration_link_attr`: mapping to the attribute containing custom service registration link. Filter adds the callback URL, to which to redirect user after the registration, as query string in form of 'callback=URL'.
299+
* `allow_registration_attr`: mapping to the attribute containing flag, if registration in case of denied access is enabled
300+
301+
```php
302+
25 => [
303+
'class' => 'perun:SpAuthorization',
304+
'interface' => 'LDAP',
305+
'registrar_url' => 'https://signup.perun.cesnet.cz/fed/registrar/',
306+
'check_group_membership_attr' => 'check_group_membership',
307+
'vo_short_names_attr' => 'vo_short_names',
308+
'registration_link_attr' => 'registration_link',
309+
'allow_registration_attr' => 'allow_registration',
310+
],
311+
```

dictionaries/perun.definition.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,66 @@
9494
"unauthorized-access_redirect_to_registration": {
9595
"en": "Now you will be redirected to registration to Perun system.",
9696
"cs": "Nyní budete přesměrování na registraci do systému Perun."
97+
},
98+
"register_text": {
99+
"en": "Oops! It seems you have tried to access service via Perun AAI, but yo do not have an account. Let's fix that!",
100+
"cs": "Ups! Zdá se, že jste se pokusil(a) přihlásit ke službě skrz Perun AAI, no nemáte uživatelský účet. Pojďme to napravit!"
101+
},
102+
"register_button": {
103+
"en": "Proceed to register for an account",
104+
"cs": "Pokračovat na registraci ůčtu"
105+
},
106+
"aup_text": {
107+
"en": "Oops! It seems you have tried to access service via Perun AAI, but you have not approved the Acceptable Use Policy (AUP). Let's fix that!",
108+
"cs": "Ups! Vyzerá to, že jste se pokousil(a) přihlásit ke službě skrze Perun AAI, no neschválili jste Podmínky užití služby (AUP). Pojďme to napravit!"
109+
},
110+
"aup_button": {
111+
"en": "Proceed to approval of the AUP",
112+
"cs": "Pokračovat na potvrzení souhlasu s AUP"
113+
},
114+
,
115+
"sp_authorize_403_header": {
116+
"en": "Unauthorized",
117+
"cs": "Přístup zamítnut"
118+
},
119+
"sp_authorize_403_text": {
120+
"en": "You are not authorized to access the service ",
121+
"cs": "Nesplňujete autorizační pravidla pro přístup ke službě "
122+
},
123+
"sp_authorize_403_information_page": {
124+
"en": "For more information about the service, visit ",
125+
"cs": "Pro více informací o službě, navštivte "
126+
},
127+
"sp_authorize_403_information_page_link_text": {
128+
"en": "this page",
129+
"cs": "tuhle stránku"
130+
},
131+
"sp_authorize_403_contact_support": {
132+
"en": "If you think you should have access to the service, please contact the service administrator at ",
133+
"cs": "Jestli máte mít přístup ke službě, kontaktujte správce služby na "
134+
},
135+
"sp_authorize_403_subject": {
136+
"en": "Unauthorized access",
137+
"cs": "Přístup zamítnut"
138+
},
139+
"sp_authorize_notify_text": {
140+
"en": "You are not authorized to access the service ",
141+
"cs": "Nesplňujete autorizační pravidla pro přístup ke službě"
142+
},
143+
"sp_authorize_notify_information_page": {
144+
"en": "For more information about the service, visit ",
145+
"cs": "Pro více informací o službě, navštivte "
146+
},
147+
"sp_authorize_notify_information_page_link_text": {
148+
"en": "this page",
149+
"cs": "tuhle stránku"
150+
},
151+
"sp_authorize_notify_text2": {
152+
"en": "We will now redirect you to a registration page, where you will apply for the access.",
153+
"cs": "Budete přesmerován(a) na stránku, kde můžete o p%rístup na službu zažádat."
154+
},
155+
"sp_authorize_notify_button": {
156+
"en": "Proceed to registration",
157+
"cs": "Pokračovat na registrační stránku"
97158
}
98159
}

lib/Adapter.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static function getInstance($interface)
4848

4949
/**
5050
* @param string $idpEntityId entity id of hosted idp used as extSourceName
51-
* @param string $uids list of user identifiers received from remote idp used as userExtSourceLogin
51+
* @param array $uids list of user identifiers received from remote idp used as userExtSourceLogin
5252
*
5353
* @return User or null if not exists
5454
*/
@@ -90,7 +90,15 @@ abstract public function getMemberGroups($user, $vo);
9090
* @return Group[] from vo which are assigned to all facilities with spEntityId.
9191
* registering to those groups should should allow access to the service
9292
*/
93-
abstract public function getSpGroups($spEntityId);
93+
abstract public function getSpGroups(string $spEntityId): array;
94+
95+
/**
96+
* @param Facility $facility representing the SP
97+
*
98+
* @return Group[] from vo which are assigned to all facilities with spEntityId.
99+
* registering to those groups should allow access to the service
100+
*/
101+
abstract public function getSpGroupsByFacility(Facility $facility): array;
94102

95103
/**
96104
* @param User $user

lib/AdapterLdap.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,15 @@ public function getMemberGroups($user, $vo)
152152
return $groups;
153153
}
154154

155-
public function getSpGroups($spEntityId)
155+
public function getSpGroups(string $spEntityId): array
156156
{
157157
$facility = $this->getFacilityByEntityId($spEntityId);
158158

159-
if (null === $facility) {
160-
return [];
161-
}
159+
return $this->getSpGroupsByFacility($facility);
160+
}
162161

162+
public function getSpGroupsByFacility(Facility $facility): array
163+
{
163164
$id = $facility->getId();
164165

165166
$resources = $this->connector->searchForEntities(
@@ -177,16 +178,13 @@ public function getSpGroups($spEntityId)
177178
'(objectClass=perunGroup)',
178179
['perunGroupId', 'cn', 'perunUniqueGroupName', 'perunVoId', 'uuid', 'description']
179180
);
180-
array_push(
181-
$groups,
182-
new Group(
183-
$group['perunGroupId'][0],
184-
$group['perunVoId'][0],
185-
$group['uuid'][0],
186-
$group['cn'],
187-
$group['perunUniqueGroupName'][0],
188-
$group['description'][0] ?? ''
189-
)
181+
$groups[] = new Group(
182+
$group['perunGroupId'][0],
183+
$group['perunVoId'][0],
184+
$group['uuid'][0],
185+
$group['cn'],
186+
$group['perunUniqueGroupName'][0],
187+
$group['description'][0] ?? ''
190188
);
191189
}
192190
}

lib/AdapterRpc.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,23 +154,30 @@ public function getMemberGroups($user, $vo)
154154
return $convertedGroups;
155155
}
156156

157-
public function getSpGroups($spEntityId)
157+
public function getSpGroups(string $spEntityId): array
158158
{
159159
$facility = $this->getFacilityByEntityId($spEntityId);
160160

161161
if (null === $facility) {
162162
return [];
163163
}
164164

165+
return $this->getSpGroupsByFacility($facility);
166+
}
167+
168+
public function getSpGroupsByFacility(Facility $facility): array
169+
{
165170
$perunAttrs = $this->connector->get('facilitiesManager', 'getAssignedResources', [
166171
'facility' => $facility->getId(),
167172
]);
168173

169174
$resources = [];
170175
foreach ($perunAttrs as $perunAttr) {
171-
array_push(
172-
$resources,
173-
new Resource($perunAttr['id'], $perunAttr['voId'], $perunAttr['facilityId'], $perunAttr['name'])
176+
$resources[] = new Resource(
177+
$perunAttr['id'],
178+
$perunAttr['voId'],
179+
$perunAttr['facilityId'],
180+
$perunAttr['name']
174181
);
175182
}
176183

@@ -186,16 +193,13 @@ public function getSpGroups($spEntityId)
186193
'attributeName' => 'urn:perun:group:attribute-def:virt:voShortName',
187194
]);
188195
$uniqueName = $attr['value'] . ':' . $group['name'];
189-
array_push(
190-
$spGroups,
191-
new Group(
192-
$group['id'],
193-
$group['voId'],
194-
$group['uuid'],
195-
$group['name'],
196-
$uniqueName,
197-
$group['description']
198-
)
196+
$spGroups[] = new Group(
197+
$group['id'],
198+
$group['voId'],
199+
$group['uuid'],
200+
$group['name'],
201+
$uniqueName,
202+
$group['description']
199203
);
200204
}
201205
}

0 commit comments

Comments
 (0)