Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions application/configs/attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@
"DisplayOrder" : 9,
"DisplayConsent" : true,
"Conditions": {
"error": {
"scope": true
},
"warning": {
"min": "1",
"max": "1",
Expand All @@ -188,6 +191,9 @@
"DisplayOrder" : 10,
"DisplayConsent" : true,
"Conditions": {
"error": {
"scope": true
},
"warning": {
"max": "1",
"regex": "#^([a-z0-9][a-z0-9=-]{3,}|[A-Z0-9][A-Z0-9=-]{3,})@[a-z0-9][a-z0-9.-]+\\.[a-z]{2,}$#"
Expand Down Expand Up @@ -362,6 +368,7 @@
"error": {
"min": "1",
"max": "1",
"scope": true,
"type": "HostName"
},
"warning": {
Expand Down
8 changes: 4 additions & 4 deletions languages/messages.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@
'error_generic_desc_no_sp_name' => 'Logging in has failed and we don\'t know exactly why. Please try again first by going back to the service and logging in again. If this doesn\'t work, please contact the service desk of %idpName%.',
'error_generic_desc_no_idp_name' => 'Logging in has failed and we don\'t know exactly why. Please try again first by going back to %spName% and logging in again. If this doesn\'t work, please contact the service desk of your %organisationNoun%.',
'error_generic_desc_no_names' => 'Logging in has failed and we don\'t know exactly why. Please try again first by going back to the service and logging in again. If this doesn\'t work, please contact the service desk of your %organisationNoun%.',
'error_missing_required_fields' => 'Error - Missing required fields',
'error_missing_required_fields' => 'Error - Error validating attribute values',
'error_missing_required_fields_desc'=> '%idpName% does not provide the mandatory information or it has an invalid format. Therefore, you can not use %spName%. Please contact the service desk of %idpName% and tell them one or more of the the following required attributes are not being set correctly for %suiteName%:',
'error_missing_required_fields_desc_no_idp_name'=> 'Your %organisationNoun% does not provide the mandatory information. Therefore, you can not use %spName%. Please contact your %organisationNoun% and tell them one or more of the the following required attribute(s) are missing within %suiteName%:',
'error_missing_required_fields_desc_no_sp_name'=> '%idpName% does not provide the mandatory information. Therefore, you can not use this service. Please contact the service desk of %idpName% and tell them one or more of the the following required attribute(s) are missing within %suiteName%:',
'error_missing_required_fields_desc_no_idp_name'=> 'Your %organisationNoun% does not provide the mandatory information. Therefore, you can not use %spName%. Please contact your %organisationNoun% and tell them one or more of the the following attributes have problems within %suiteName%:',
'error_missing_required_fields_desc_no_sp_name'=> '%idpName% does not provide the mandatory information. Therefore, you can not use this service. Please contact the service desk of %idpName% and tell them one or more of the the following required attribute(s) have problems within %suiteName%:',
'error_missing_required_fields_desc_no_name'=> '
Your %organisationNoun% does not provide the mandatory information. Therefore, you can not use this service. Please contact your %organisationNoun% and tell them one or more of the the following required attribute(s) are missing within %suiteName%:',
Your %organisationNoun% does not provide the mandatory information. Therefore, you can not use this service. Please contact your %organisationNoun% and tell them one or more of the the following required attribute(s) have problems within %suiteName%:',
'error_invalid_attribute_value' => 'Error - Attribute value not allowed',
'error_invalid_attribute_value_desc' => '%idpName% sends a value for attribute %attributeName% ("%attributeValue%") which is not allowed for this %organisationNoun%. Therefore you cannot log in. Only %idpName% can resolve this. Please contact the service desk of %idpName% to fix this problem.',
'error_invalid_attribute_value_desc_no_idp_name' => 'Your %organisationNoun% sends a value for attribute %attributeName% ("%attributeValue%") which is not allowed for this %organisationNoun%. Therefore you cannot log in. Only your %organisationNoun% can resolve this. Please contact the service desk of your own %organisationNoun% to fix this problem.',
Expand Down
16 changes: 8 additions & 8 deletions languages/messages.nl.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@
'error_generic_desc_no_sp_name' => 'Inloggen is niet gelukt en we weten niet precies waarom. Probeer het eerst eens opnieuw door terug te gaan naar de dienst en opnieuw in te loggen. Lukt dit niet, neem dan contact op met de helpdesk van %idpName%.',
'error_generic_desc_no_idp_name' => 'Inloggen is niet gelukt en we weten niet precies waarom. Probeer het eerst eens opnieuw door terug te gaan naar %spName% en opnieuw in te loggen. Lukt dit niet, neem dan contact op met de helpdesk van je %organisationNoun%.',
'error_generic_desc_no_names' => 'Inloggen is niet gelukt en we weten niet precies waarom. Probeer het eerst eens opnieuw door terug te gaan naar de dienst en opnieuw in te loggen. Lukt dit niet, neem dan contact op met de helpdesk van je %organisationNoun%.',
'error_missing_required_fields' => 'Error - Verplichte velden ontbreken',
'error_missing_required_fields_desc'=> '%idpName% geeft niet de benodigde informatie vrij. Daarom kun je %spName% niet gebruiken. Neem alstublieft contact op met de helpdesk van %idpName%. Geef hierbij de onderstaande informatie door. Omdat %idpName% niet de juiste attributen aan %suiteName% doorgeeft, of in het onjuiste formaat, is het inloggen mislukt. De volgende attributen zijn vereist om succesvol in te loggen op het %suiteName% platform:',
'error_missing_required_fields_desc_no_idp_name'=> 'Jouw %organisationNoun% geeft niet de benodigde informatie vrij. Daarom kun je %spName% niet gebruiken. Neem alstublieft contact op met de helpdesk van jouw %organisationNoun%. Geef hierbij de onderstaande informatie door. Omdat je %organisationNoun% niet de juiste attributen aan %suiteName% doorgeeft is het inloggen mislukt. De volgende attributen zijn vereist om succesvol in te loggen op het %suiteName% platform:',
'error_missing_required_fields_desc_no_sp_name'=> '%idpName% geeft niet de benodigde informatie vrij. Daarom kun je deze applicatie niet gebruiken. Neem alstublieft contact op met de helpdesk van %idpName%. Geef hierbij de onderstaande informatie door. Omdat %idpName% niet de juiste attributen aan %suiteName% doorgeeft is het inloggen mislukt. De volgende attributen zijn vereist om succesvol in te loggen op het %suiteName% platform:',
'error_missing_required_fields_desc_no_name'=> 'Jouw %organisationNoun% geeft niet de benodigde informatie vrij. Daarom kun je deze applicatie niet gebruiken. Neem alstublieft contact op met jouw %organisationNoun%. Geef hierbij de onderstaande informatie door. Omdat je %organisationNoun% niet de juiste attributen aan %suiteName% doorgeeft is het inloggen mislukt. De volgende attributen zijn vereist om succesvol in te loggen op het %suiteName% platform:',
'error_invalid_attribute_value' => 'Fout - Attribuutwaarde niet toegestaan',
'error_invalid_attribute_value_desc' => '%idpName% geeft een waarde door in het attribuut %attributeName% ("%attributeValue%") die niet is toegestaan voor deze %organisationNoun%. Inloggen is daarom niet mogelijk. Alleen %idpName% kan dit oplossen. Neem dus contact op met de helpdesk van %idpName%.',
'error_invalid_attribute_value_desc_no_idp_name' => 'Je %organisationNoun% geeft een waarde door in het attribuut %attributeName% ("%attributeValue%") die niet is toegestaan voor deze %organisationNoun%. Inloggen is daarom niet mogelijk. Alleen jouw %organisationNoun% kan dit oplossen. Neem dus contact op met de helpdesk van je eigen %organisationNoun%.',
'error_missing_required_fields' => 'Error - Probleem met attribuutwaarden',
'error_missing_required_fields_desc'=> '%idpName% geeft niet de juiste informatie vrij. Daarom kun je %spName% niet gebruiken. Neem alstublieft contact op met de helpdesk van %idpName%. Geef hierbij de onderstaande informatie door. Omdat %idpName% niet de juiste attributen aan %suiteName% doorgeeft, of in het onjuiste formaat, is het inloggen mislukt. De volgende problemen zijn gevonden door het %suiteName% platform:',
'error_missing_required_fields_desc_no_idp_name'=> 'Jouw %organisationNoun% geeft niet de juiste informatie vrij. Daarom kun je %spName% niet gebruiken. Neem alstublieft contact op met de helpdesk van jouw %organisationNoun%. Geef hierbij de onderstaande informatie door. Omdat je %organisationNoun% niet de juiste attributen aan %suiteName% doorgeeft is het inloggen mislukt. De volgende problemen zijn gevonden door het %suiteName% platform:',
'error_missing_required_fields_desc_no_sp_name'=> '%idpName% geeft niet de juiste informatie vrij. Daarom kun je deze applicatie niet gebruiken. Neem alstublieft contact op met de helpdesk van %idpName%. Geef hierbij de onderstaande informatie door. Omdat %idpName% niet de juiste attributen aan %suiteName% doorgeeft is het inloggen mislukt. De volgende problemen zijn gevonden door het %suiteName% platform:',
'error_missing_required_fields_desc_no_name'=> 'Jouw %organisationNoun% geeft niet de juiste informatie vrij. Daarom kun je deze applicatie niet gebruiken. Neem alstublieft contact op met jouw %organisationNoun%. Geef hierbij de onderstaande informatie door. Omdat je %organisationNoun% niet de juiste attributen aan %suiteName% doorgeeft is het inloggen mislukt. De volgende problemen zijn gevonden door het %suiteName% platform:',
# 'error_invalid_attribute_value' => 'Fout - Attribuutwaarde niet toegestaan',
# 'error_invalid_attribute_value_desc' => '%idpName% geeft een waarde door in het attribuut %attributeName% ("%attributeValue%") die niet is toegestaan voor deze %organisationNoun%. Inloggen is daarom niet mogelijk. Alleen %idpName% kan dit oplossen. Neem dus contact op met de helpdesk van %idpName%.',
# 'error_invalid_attribute_value_desc_no_idp_name' => 'Je %organisationNoun% geeft een waarde door in het attribuut %attributeName% ("%attributeValue%") die niet is toegestaan voor deze %organisationNoun%. Inloggen is daarom niet mogelijk. Alleen jouw %organisationNoun% kan dit oplossen. Neem dus contact op met de helpdesk van je eigen %organisationNoun%.',
'error_received_error_status_code' => 'Error - Fout bij Identity Provider',
'error_received_error_status_code_desc'=> 'Je %organisationNoun% heeft je de toegang geweigerd tot deze dienst. Je zult dus contact moeten opnemen met de (IT-)helpdesk van je eigen %organisationNoun% om te kijken of dit verholpen kan worden.',
'error_received_invalid_response' => 'Fout - Ongeldig SAML-bericht van %idpName%',
Expand Down
7 changes: 6 additions & 1 deletion library/EngineBlock/Attributes/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,18 @@ class EngineBlock_Attributes_Validator
*/
private $errors;

private $identityProvider;

public function __construct(array $definitions, EngineBlock_Attributes_Validator_Factory $validatorFactory)
{
$this->definitions = $definitions;
$this->validatorFactory = $validatorFactory;
}

public function validate(array $attributes, $excluded = array())
public function validate(array $attributes, $excluded = array(), $identityProvider = null)
{
$this->attributes = $attributes;
$this->identityProvider = $identityProvider;
$this->validAttributes = array();
$this->warnings = array();
$this->errors = array();
Expand Down Expand Up @@ -158,6 +161,7 @@ private function validateAttributeWarnings($attributeName, $definition)
if (isset($definition['__original__'])) {
$validator->setAttributeAlias($definition['__original__']);
}
$validator->setIdentityProvider($this->identityProvider);

$validationResult = $validator->validate($this->attributes);

Expand Down Expand Up @@ -193,6 +197,7 @@ private function validateAttributeErrors($attributeName, $definition)
if (isset($definition['__original__'])) {
$validator->setAttributeAlias($definition['__original__']);
}
$validator->setIdentityProvider($this->identityProvider);

$validationResult = $validator->validate($this->attributes);

Expand Down
9 changes: 9 additions & 0 deletions library/EngineBlock/Attributes/Validator/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,21 @@ abstract class EngineBlock_Attributes_Validator_Abstract implements EngineBlock_
*/
protected $_messages = array();

protected $_identityProvider;

public function __construct($attributeName, $options)
{
$this->_attributeName = $attributeName;
$this->_options = $options;
}

public function setIdentityProvider($identityProvider)
{
$this->_identityProvider = $identityProvider;
return $this;
}


public function setAttributeAlias($aliasName)
{
$this->_attributeAlias = $aliasName;
Expand Down
1 change: 1 addition & 0 deletions library/EngineBlock/Attributes/Validator/Interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ interface EngineBlock_Attributes_Validator_Interface
public function __construct($attributeName, $options);
public function validate(array $attributes);
public function setAttributeAlias($alias);
public function setIdentityProvider($identityProvider);
public function getMessages();
}
87 changes: 87 additions & 0 deletions library/EngineBlock/Attributes/Validator/Scope.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

/**
* Copyright 2024 SURF B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

use OpenConext\EngineBlock\Metadata\ShibMdScope;
use OpenConext\Value\Saml\Metadata\ShibbolethMetadataScope;
use OpenConext\Value\Saml\Metadata\ShibbolethMetadataScopeList;

class EngineBlock_Attributes_Validator_Scope extends EngineBlock_Attributes_Validator_Abstract
{
const ERROR_ATTRIBUTE_VALIDATOR_SCOPE = 'error_attribute_validator_scope';

public function validate(array $attributes)
{
if (empty($attributes[$this->_attributeName])) {
return true;
}

$logger = EngineBlock_ApplicationSingleton::getLog();

$scopes = $this->_identityProvider->shibMdScopes;
if (empty($scopes)) {
$logger->notice('No shibmd:scope found in the IdP metadata, not verifying ' . $this->_attributeName);
return true;
}
$scopeList = $this->buildScopeList($scopes);

foreach ($attributes[$this->_attributeName] as $attributeValue) {
if($scopeList->inScope($attributeValue)) {
continue;
}
// consider moving this to inScope()
list(,$suffix) = explode('@', $attributeValue, 2);
if(empty($suffix) || $scopeList->inScope($suffix)) {
continue;
}
$logger->warning(sprintf(
'%s attribute value "%s" is not allowed by configured ShibMdScopes for IdP "%s"',
$this->_attributeName,
$attributeValue,
$this->_identityProvider->entityId
));
$this->_messages[] = [
self::ERROR_ATTRIBUTE_VALIDATOR_SCOPE,
$this->_attributeName,
$this->_options,
$attributeValue
];
return false;
}
return true;
}

/**
* @param ShibMdScope[] $scopes
* @return ShibbolethMetadataScopeList
*/
private function buildScopeList(array $scopes)
{
$scopes = array_map(
function (ShibMdScope $scope) {
if (!$scope->regexp) {
return ShibbolethMetadataScope::literal($scope->allowed);
}

return ShibbolethMetadataScope::regexp($scope->allowed);
},
$scopes
);

return new ShibbolethMetadataScopeList($scopes);
}
}
18 changes: 16 additions & 2 deletions library/EngineBlock/Corto/Exception/MissingRequiredFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,24 @@
* limitations under the License.
*/

class EngineBlock_Corto_Exception_MissingRequiredFields extends EngineBlock_Exception
class EngineBlock_Corto_Exception_MissingRequiredFields extends EngineBlock_Exception implements EngineBlock_Corto_Exception_HasFeedbackInfoInterface
{
public function __construct($message, $severity = self::CODE_NOTICE, Exception $previous = null)
/**
* @var array
*/
private $feedback;

public function __construct($message, $errors, $severity = self::CODE_NOTICE, Exception $previous = null)
{
$this->feedback = $errors;
parent::__construct($message, $severity, $previous);
}

/**
* @return array
*/
public function getFeedbackInfo()
{
return $this->feedback;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,27 @@ public function execute()
$validationResult = EngineBlock_ApplicationSingleton::getInstance()
->getDiContainer()
->getAttributeValidator()
->validate($this->_responseAttributes, $excluded);
->validate($this->_responseAttributes, $excluded, $this->_identityProvider);

if ($validationResult->hasErrors()) {
$errors = $validationResult->getErrors();

$messages = "";
foreach($errors as $attribute => $violations) {
$messages .= "$attribute: ";
foreach($violations as $violation) {
$messages .= $violation[0].' "' .$violation[3].'"';
}
$messages .= "\n";
}

throw new EngineBlock_Corto_Exception_MissingRequiredFields(
sprintf(
'Errors validating attributes errors: "%s" attributes: "%s"',
print_r($validationResult->getErrors(), true),
print_r($errors, true),
print_r($this->_responseAttributes, true)
)
),
['validationMessages' => $messages]
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions library/EngineBlock/Corto/Filter/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ public function getCommands()
EngineBlock_Corto_Filter_Command_RunAttributeManipulations::TYPE_IDP
),

new EngineBlock_Corto_Filter_Command_VerifyShibMdScopingAllowsSchacHomeOrganisation($logger, $blockUsersOnViolation),
// new EngineBlock_Corto_Filter_Command_VerifyShibMdScopingAllowsSchacHomeOrganisation($logger, $blockUsersOnViolation),

new EngineBlock_Corto_Filter_Command_VerifyShibMdScopingAllowsEduPersonPrincipalName($logger, $blockUsersOnViolation),
// new EngineBlock_Corto_Filter_Command_VerifyShibMdScopingAllowsEduPersonPrincipalName($logger, $blockUsersOnViolation),

new EngineBlock_Corto_Filter_Command_VerifyShibMdScopingAllowsSubjectId($logger, $blockUsersOnViolation),
// new EngineBlock_Corto_Filter_Command_VerifyShibMdScopingAllowsSubjectId($logger, $blockUsersOnViolation),

// Check whether this IdP is allowed to send a response to the destination SP
new EngineBlock_Corto_Filter_Command_ValidateAllowedConnection(),

// Require valid UID and SchacHomeOrganization
// Validate attributes that are required and check scopes
new EngineBlock_Corto_Filter_Command_ValidateRequiredAttributes(),

// Add guest status (isMemberOf)
Expand Down
Loading