-
Notifications
You must be signed in to change notification settings - Fork 2
Add configurable sso registration bypass #540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pablothedude
merged 1 commit into
main
from
feature/add-configurable-sso-registration-bypass
May 27, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,62 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Copyright 2025 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. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Surfnet\Migrations; | ||
|
|
||
| use Doctrine\DBAL\Schema\Schema; | ||
| use Doctrine\Migrations\AbstractMigration; | ||
| use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationInterface; | ||
| use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationTrait; | ||
|
|
||
| final class Version20250501121457 extends AbstractMigration implements ConfigurationAwareMigrationInterface | ||
| { | ||
| use ConfigurationAwareMigrationTrait; | ||
|
|
||
| public function up(Schema $schema): void | ||
| { | ||
| $this->abortIf( | ||
| $this->connection->getDatabasePlatform()->getName() !== 'mysql', | ||
| 'Migration can only be executed safely on \'mysql\'.', | ||
| ); | ||
| // Create the new sso_on_2fa option, note the name conversion 'error' made by doctrine. | ||
| $this->addSql('ALTER TABLE institution_configuration_options ADD sso_registration_bypass_option INT DEFAULT \'0\' NOT NULL'); | ||
| // Create the institution_configuration gateway schema | ||
| $gatewaySchema = $this->getGatewaySchema(); | ||
| $this->addSql( | ||
| sprintf( | ||
| 'ALTER TABLE %s.institution_configuration ADD sso_registration_bypass TINYINT(1) NOT NULL', | ||
| $gatewaySchema, | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| public function down(Schema $schema): void | ||
| { | ||
| $this->abortIf( | ||
| $this->connection->getDatabasePlatform()->getName() !== 'mysql', | ||
| 'Migration can only be executed safely on \'mysql\'.', | ||
| ); | ||
| // Down the Middleware schema change | ||
| $this->addSql('ALTER TABLE institution_configuration_options DROP sso_registration_bypass_option'); | ||
| // Gateway schema change (remove the institution_configuration) | ||
| $gatewaySchema = $this->getGatewaySchema(); | ||
| $this->addSql(sprintf('ALTER TABLE %s.institution_configuration DROP sso_registration_bypass', $gatewaySchema)); | ||
| } | ||
| } |
This file contains hidden or 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
54 changes: 54 additions & 0 deletions
54
src/Surfnet/Stepup/Configuration/Event/SsoRegistrationBypassOptionChangedEvent.php
This file contains hidden or 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,54 @@ | ||
| <?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 Surfnet\Stepup\Configuration\Event; | ||
|
|
||
| use Broadway\Serializer\Serializable as SerializableInterface; | ||
| use Surfnet\Stepup\Configuration\Value\Institution; | ||
| use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId; | ||
| use Surfnet\Stepup\Configuration\Value\SsoRegistrationBypassOption; | ||
|
|
||
| final class SsoRegistrationBypassOptionChangedEvent implements SerializableInterface | ||
| { | ||
| public function __construct( | ||
| public InstitutionConfigurationId $institutionConfigurationId, | ||
| public Institution $institution, | ||
| public SsoRegistrationBypassOption $ssoRegistrationBypassOption, | ||
| ) { | ||
| } | ||
|
|
||
| public static function deserialize(array $data): self | ||
| { | ||
| return new self( | ||
| new InstitutionConfigurationId($data['institution_configuration_id']), | ||
| new Institution($data['institution']), | ||
| new SsoRegistrationBypassOption($data['sso_registration_bypass_option']), | ||
| ); | ||
| } | ||
|
|
||
| public function serialize(): array | ||
| { | ||
| return [ | ||
| 'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(), | ||
| 'institution' => $this->institution->getInstitution(), | ||
| 'sso_registration_bypass_option' => $this->ssoRegistrationBypassOption->isEnabled(), | ||
| ]; | ||
| } | ||
| } |
This file contains hidden or 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
51 changes: 51 additions & 0 deletions
51
src/Surfnet/Stepup/Configuration/Value/SsoRegistrationBypassOption.php
This file contains hidden or 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,51 @@ | ||
| <?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 Surfnet\Stepup\Configuration\Value; | ||
|
|
||
| use JsonSerializable; | ||
|
|
||
| final readonly class SsoRegistrationBypassOption implements JsonSerializable | ||
| { | ||
| public static function getDefault(): self | ||
| { | ||
| return new self(false); | ||
| } | ||
|
|
||
| public function __construct( | ||
| private bool $ssoRegistrationBypass | ||
| ) { | ||
| } | ||
|
|
||
| public function equals(SsoRegistrationBypassOption $other): bool | ||
| { | ||
| return $this->ssoRegistrationBypass === $other->isEnabled(); | ||
| } | ||
|
|
||
| public function isEnabled(): bool | ||
| { | ||
| return $this->ssoRegistrationBypass; | ||
| } | ||
|
|
||
| public function jsonSerialize(): bool | ||
| { | ||
| return $this->ssoRegistrationBypass; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.