|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Copyright 2026 SURFnet B.V. |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +declare(strict_types=1); |
| 20 | + |
| 21 | +namespace OpenConext\EngineBlock\Doctrine\Migrations; |
| 22 | + |
| 23 | +use Doctrine\DBAL\Schema\Schema; |
| 24 | + |
| 25 | +/** |
| 26 | + * Corrects the column comment on saml_persistent_id.persistent_id. |
| 27 | + * |
| 28 | + * The original comment read "SHA1 of service_provider_uuid + user_uuid", which was |
| 29 | + * inaccurate in two ways: the operand order was wrong, and the COIN: salt was omitted. |
| 30 | + * The actual value stored is sha1('COIN:' + user_uuid + service_provider_uuid), as |
| 31 | + * defined in EngineBlock_Saml2_NameIdResolver::PERSISTENT_NAMEID_SALT. |
| 32 | + * |
| 33 | + * NOTE: This migration is NOT mandatory. It only updates a database-level column comment |
| 34 | + * and has no effect on data integrity or application behaviour. It is safe to skip on |
| 35 | + * existing installations where updating the comment is not considered necessary. |
| 36 | + */ |
| 37 | +final class Version20260331000000 extends AbstractEngineBlockMigration |
| 38 | +{ |
| 39 | + public function getDescription(): string |
| 40 | + { |
| 41 | + return 'Corrects the column comment on saml_persistent_id.persistent_id to accurately reflect the SHA1 formula.'; |
| 42 | + } |
| 43 | + |
| 44 | + public function up(Schema $schema): void |
| 45 | + { |
| 46 | + $this->addSql( |
| 47 | + "ALTER TABLE `saml_persistent_id` MODIFY COLUMN `persistent_id` CHAR(40) NOT NULL COMMENT 'SHA1 of COIN: + user_uuid + service_provider_uuid'" |
| 48 | + ); |
| 49 | + } |
| 50 | + |
| 51 | + public function down(Schema $schema): void |
| 52 | + { |
| 53 | + $this->addSql( |
| 54 | + "ALTER TABLE `saml_persistent_id` MODIFY COLUMN `persistent_id` CHAR(40) NOT NULL COMMENT 'SHA1 of service_provider_uuid + user_uuid'" |
| 55 | + ); |
| 56 | + } |
| 57 | +} |
0 commit comments