-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prior to this change, there were cases where it wasn't clear which IdP end users should use. In these scenario's the users needed an IdP which was not recognisable for them. This change adds support for discovery IdP entries. Which are additional names / ways of finding an IdP in the WAYF. These can be configured in Manage. A discovery requires at least an english name, but can also include keywords or a custom logo, which is used on the consent page as well. Resolves #1338
- Loading branch information
Showing
41 changed files
with
1,340 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
cd $(dirname $0)/../../ | ||
|
||
echo -e "\nPHP CodeSniffer\n" | ||
./vendor/bin/phpcbf --standard=ci/qa-config/phpcs.xml src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace OpenConext\EngineBlock\Doctrine\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20250206095609 extends AbstractMigration | ||
{ | ||
public function up(Schema $schema) : void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); | ||
|
||
$this->addSql('ALTER TABLE sso_provider_roles_eb5 ADD idp_discoveries LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\''); | ||
} | ||
|
||
public function down(Schema $schema) : void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); | ||
|
||
$this->addSql('ALTER TABLE sso_provider_roles_eb5 DROP idp_discoveries'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/OpenConext/EngineBlock/Exception/InvalidDiscoveryException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2025 SURFnet 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. | ||
*/ | ||
|
||
namespace OpenConext\EngineBlock\Exception; | ||
|
||
final class InvalidDiscoveryException extends RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* Copyright 2025 SURFnet 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. | ||
*/ | ||
|
||
namespace OpenConext\EngineBlock\Metadata; | ||
|
||
use JsonSerializable; | ||
use OpenConext\EngineBlock\Assert\Assertion; | ||
use OpenConext\EngineBlock\Exception\InvalidDiscoveryException; | ||
|
||
/** | ||
* Value object representing the cosmetic override data when a 'sub-idp' is present | ||
*/ | ||
class Discovery implements JsonSerializable | ||
{ | ||
/** | ||
* @var string[] | ||
*/ | ||
private $names; | ||
|
||
/** | ||
* @var string[] | ||
*/ | ||
private $keywords; | ||
|
||
/** | ||
* @var ?Logo | ||
*/ | ||
private $logo; | ||
|
||
/** | ||
* @param array<string,string> $names | ||
* @param array<string,string> $keywords | ||
*/ | ||
public static function create(array $names, array $keywords, ?Logo $logo): Discovery | ||
{ | ||
$discovery = new self; | ||
$discovery->logo = $logo; | ||
|
||
$discovery->names = array_filter($names); | ||
$discovery->keywords = array_filter($keywords); | ||
|
||
if (!$discovery->isValid()) { | ||
throw new InvalidDiscoveryException('The Discovery does not have a required english name.'); | ||
} | ||
|
||
return $discovery; | ||
} | ||
|
||
public function jsonSerialize() | ||
{ | ||
return [ | ||
'names' => $this->names, | ||
'keywords' => $this->keywords, | ||
'logo' => $this->logo, | ||
]; | ||
} | ||
|
||
public function hasLogo(): bool | ||
{ | ||
return $this->logo !== null && $this->logo->url !== null; | ||
} | ||
|
||
public function getLogo(): ?Logo | ||
{ | ||
return $this->logo; | ||
} | ||
|
||
public function getLanguage(): string | ||
{ | ||
return $this->language; | ||
} | ||
|
||
public function getName(string $locale): string | ||
{ | ||
if ($locale !== '' && isset($this->names[$locale])) { | ||
return $this->names[$locale]; | ||
} | ||
|
||
return $this->names['en'] ?? ''; | ||
} | ||
|
||
public function getKeywords(string $locale): string | ||
{ | ||
if ($locale !== '' && isset($this->keywords[$locale])) { | ||
return $this->keywords[$locale]; | ||
} | ||
|
||
return $this->keywords['en'] ?? ''; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getKeywordsArray(string $locale): array | ||
{ | ||
return explode(' ', $this->getKeywords($locale)); | ||
} | ||
|
||
public function isValid(): bool | ||
{ | ||
return $this->getName('en') !== ''; | ||
} | ||
} |
Oops, something went wrong.