Skip to content
Open
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
"require-dev": {
"doctrine/data-fixtures": "^2.2",
"doctrine/doctrine-fixtures-bundle": "^4.3",
"irstea/phpcpd-shim": "^6.0",
"liip/test-fixtures-bundle": "^3.6",
"malukenho/docheader": "^1.1",
"mockery/mockery": "^1.6.12",
"overtrue/phplint": ">=9.5.6",
"phpcpd-next/phpcpd": "^1.1",
"phpmd/phpmd": "^2.15",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-doctrine": "^2.0",
Expand Down
118 changes: 75 additions & 43 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,20 @@ public function validPushWithOnlyGatewayIsAccepted(): void
]);
}

#[Test]
#[Group('management')]
public function validPushWithServiceNameIsAccepted(): void
{
$this->pushConfiguration([
'gateway' => [
'identity_providers' => [],
'service_providers' => [
array_merge(self::minimalServiceProvider(), ['service_name' => 'My Service']),
],
],
]);
}

#[Test]
#[Group('management')]
public function pushWithSraaAndEmailTemplatesIsSilentlyAccepted(): void
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/**
* Copyright 2014 SURFnet bv
*
* 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.
*/

return [
'expectedPropertyPath' => 'gateway.service_providers[0].service_name',
'configuration' => [
'gateway' => [
'identity_providers' => [],
'service_providers' => [
[
"entity_id" => "https://entity.tld/id",
"public_key" => "MIIE...",
"acs" => ["https://entity.tld/consume-assertion"],
"loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
"assertion_encryption_enabled" => false,
"blacklisted_encryption_algorithms" => [],
"service_name" => ['not', 'a', 'string'],
],
],
],
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function validate(array $configuration, string $propertyPath): void
'use_pdp',
'allow_sso_on_2fa',
'set_sso_cookie_on_2fa',
'service_name',
];

if (empty($configuration['use_pdp'])) {
Expand All @@ -54,6 +55,10 @@ public function validate(array $configuration, string $propertyPath): void
$configuration['set_sso_cookie_on_2fa'] = false;
}

if (!array_key_exists('service_name', $configuration)) {
$configuration['service_name'] = null;
}

StepupAssert::keysMatch(
$configuration,
$requiredProperties,
Expand Down Expand Up @@ -91,13 +96,22 @@ public function validate(array $configuration, string $propertyPath): void
$this->validateBooleanValue($configuration, 'use_pdp', $propertyPath);
$this->validateBooleanValue($configuration, 'allow_sso_on_2fa', $propertyPath);
$this->validateBooleanValue($configuration, 'set_sso_cookie_on_2fa', $propertyPath);
$this->validateNullableStringValue($configuration, 'service_name', $propertyPath);
}

private function validateStringValue(array $configuration, string $name, string $propertyPath): void
{
Assertion::string($configuration[$name], 'value must be a string', $propertyPath . '.' . $name);
}

/**
* @param array<string, mixed> $configuration
*/
private function validateNullableStringValue(array $configuration, string $name, string $propertyPath): void
{
Assertion::nullOrString($configuration[$name], 'value must be a string or null', $propertyPath . '.' . $name);
}

private function validateStringValues(array $configuration, string $name, string $propertyPath): void
{
Assertion::isArray($configuration[$name], 'value must be an array', $propertyPath . '.' . $name);
Expand Down
Loading