Skip to content
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

Rejuvinate the Stepup Middleware #416

Draft
wants to merge 83 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
593e7d3
Smoketest env: Set database name to be used in tests
quartje Dec 12, 2023
bc0c1d5
Update test-integration.yml
MKodde Jan 17, 2024
2a45242
Remove security checks from qa checks
MKodde Jan 17, 2024
20c1515
Reenable phpcpd
MKodde Feb 22, 2024
4f96b1a
Upgrade composer dependencies
MKodde Feb 22, 2024
8c92a6e
Repair unit tests after SF6 upgrade
MKodde Feb 26, 2024
7b23511
Refrain from using deprecated config options
MKodde Feb 26, 2024
ebee370
Upgrade Treebuilder creation
MKodde Feb 26, 2024
9f1c36c
Update *Repository classes
MKodde Feb 26, 2024
836d10c
Update *Controller, extend AbstractController
MKodde Feb 26, 2024
749685f
Update Session framework settings
MKodde Feb 26, 2024
5a64ad2
Convert Annotations to Attributes
MKodde Feb 27, 2024
7a2bc4c
Improve type safety of Middleware
MKodde Feb 27, 2024
c256522
Improve code quality
MKodde Feb 27, 2024
aec34cc
Apply Symfony 6 code changes
MKodde Feb 27, 2024
ce33d58
Implement PHP 8 conde constructs
MKodde Feb 27, 2024
c3aa947
Repair the ManagerRegistry reference
MKodde Feb 27, 2024
30b5c70
Enable autoc onfigure/wire/public:false defaults
MKodde Feb 27, 2024
2094154
Add doctrine/annotations for jms translations
MKodde Feb 27, 2024
849b832
Change renamed contracts
MKodde Feb 27, 2024
8554c4e
Upgrade Doctrine Types
MKodde Feb 27, 2024
552da21
Adhere to the vetting type loa determination
MKodde Feb 27, 2024
b8873c7
Set $possessedSelfAssertedToken with correct type
MKodde Feb 27, 2024
6012715
Improve tyep definitions for deserialize methods
MKodde Feb 27, 2024
73a50f2
Repair AuthorizationServiceTest and typehint entities
MKodde Feb 27, 2024
cc2fe6e
Update test-integration to use the php82 container
MKodde Feb 28, 2024
95f0706
Repair IdentityCommandHandlerTest.php
MKodde Feb 28, 2024
b05b471
Configure the Mockery TestListener
MKodde Feb 29, 2024
73c95f0
Work on MW authorizations
MKodde Feb 29, 2024
4d5c91e
Remove .env from Middleware
MKodde Feb 29, 2024
86cea19
Rename namespace of Kernel
MKodde Mar 14, 2024
316f0b9
Install PHPStan with SF support
MKodde Mar 14, 2024
a438e3b
Update EventDisplatcher interface contracts
MKodde Mar 14, 2024
39f4cd9
Annotate event replay might throw an exception
MKodde Mar 14, 2024
6b9b0e7
Stop using AnonymousToken
MKodde Mar 14, 2024
60b2d0d
Address PHPStan level 1 issues
MKodde Mar 14, 2024
f4fb72c
Improve PHPStan Mockery integration
MKodde Mar 18, 2024
04b156a
Remove dead method from VettingTypeHintController
MKodde Mar 18, 2024
6305abc
Address remaining PHPStan level 2 issues
MKodde Mar 19, 2024
3dc4490
Address level 3 PHPStan issues
MKodde Mar 20, 2024
6e97aad
Address level 4 PHPStan issues
MKodde Mar 20, 2024
d146101
Address level 5 PHPStan issues
MKodde Mar 21, 2024
807ca93
Address PHPStan 6 findings
MKodde Mar 25, 2024
efa0cdc
Configure level 9, addding warnings to baseline
MKodde Apr 2, 2024
a6adafc
Address PHP MD issues that were introduced
MKodde Apr 2, 2024
4798367
Address PHP CS issues that were introduced
MKodde Apr 2, 2024
357a694
Install and repair document headers
MKodde Apr 2, 2024
df0ccca
Track ci/qa/phpstan.neon
MKodde Apr 2, 2024
8651776
Also the /internal/{info,health} paths must be publically available
thijskh Apr 17, 2024
8c21259
Make expiration date in mail match the one displayed in selfservice.
thijskh Mar 4, 2024
7a61750
Sync new monolog docker logging setup
pablothedude Nov 7, 2024
62f3042
Sync framework config setup
pablothedude Nov 7, 2024
02989b0
Force phpunit in test mode by setting env
pablothedude Nov 7, 2024
7a9725f
Fix update configuration command
pablothedude Nov 7, 2024
f434df0
Fix NameId VO
pablothedude Nov 7, 2024
358394a
Fix routes extension
pablothedude Nov 7, 2024
082b0bd
Remove duplicate composer dependencies
pablothedude Nov 7, 2024
c840078
Add missing migration doc headers
pablothedude Nov 11, 2024
185f34d
Fix broken tests
pablothedude Nov 11, 2024
cacf2a8
Fix deprecations while fixing broken tests
pablothedude Nov 11, 2024
42abdef
Fix role authentication deprecated or logic
pablothedude Nov 11, 2024
b9ff9de
Fix remaining configuration tests
pablothedude Nov 11, 2024
01e7842
Refactor all ParamConverters to ValueResolvers
pablothedude Nov 12, 2024
b989615
Fix the event replay
pablothedude Nov 15, 2024
9206181
Update config
pablothedude Nov 15, 2024
626ac37
Update Twig
pablothedude Nov 15, 2024
641281f
Fix the entitymanager state while replaying
pablothedude Nov 19, 2024
d4b8d6c
Fix route controllers
pablothedude Nov 19, 2024
563c627
Fix mail date format
pablothedude Nov 20, 2024
6954f7d
Fix deprecations
pablothedude Nov 20, 2024
b5071f9
Refactor remaining Symfony config to when@env
pablothedude Nov 21, 2024
ec393ad
Fix translations and extract script
pablothedude Nov 21, 2024
8a0f7c0
Update Doctrine migration scripts
pablothedude Nov 21, 2024
f5d08f7
Fix deprecated container injection in migrations
pablothedude Nov 26, 2024
29bc0bb
Fix replay errors test2 replay
pablothedude Nov 26, 2024
911f385
Lower dev log level
pablothedude Nov 26, 2024
9d834af
Fix production database diff
pablothedude Nov 28, 2024
d10ad3c
Bump saml2, xmlseclibs
thijskh Dec 6, 2024
f0a1b14
Add BC localizeddate twig filter
pablothedude Dec 9, 2024
83ef80e
Fix typo in doc block
pablothedude Dec 9, 2024
a274cc5
Support deprecated u2f support in projection
pablothedude Dec 9, 2024
756032a
Fixes after manual testing
pablothedude Dec 10, 2024
894632a
Bump test image
pablothedude Dec 10, 2024
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
5 changes: 0 additions & 5 deletions ci/qa/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2450,11 +2450,6 @@ parameters:
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NameIdType.php

-
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NumberOfTokensPerIdentityType.php

-
message: "#^Parameter \\#1 \\$raLocationName of class Surfnet\\\\Stepup\\\\Configuration\\\\Value\\\\RaLocationName constructor expects string, mixed given\\.$#"
count: 1
Expand Down
2 changes: 2 additions & 0 deletions config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ doctrine:
dir: "%kernel.project_dir%/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration"
prefix: Surfnet\StepupMiddleware\ManagementBundle\Configuration
is_bundle: false
schema_ignore_classes:
- Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaCandidate
gateway:
connection: gateway
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
Expand Down
55 changes: 55 additions & 0 deletions src/Surfnet/Migrations/Version20241128131107.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/**
* Copyright 2024 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;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241128131107 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE institution_with_ra_locations');
$this->addSql('ALTER TABLE institution_configuration_options CHANGE number_of_tokens_per_identity_option number_of_tokens_per_identity_option INT DEFAULT 0 NOT NULL');
$this->addSql('ALTER TABLE vetted_second_factor CHANGE vetting_type vetting_type VARCHAR(255) DEFAULT NULL');
$this->addSql('CREATE INDEX idx_vetted_second_factor_vetting_type ON vetted_second_factor (vetting_type)');
$this->addSql('ALTER TABLE vetting_type_hint CHANGE hints hints JSON NOT NULL COMMENT \'(DC2Type:stepup_vetting_type_hints)\'');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE institution_with_ra_locations (institution VARCHAR(255) CHARACTER SET utf8mb3 NOT NULL COLLATE `utf8mb3_unicode_ci`, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8mb3 COLLATE `utf8mb3_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE institution_configuration_options CHANGE number_of_tokens_per_identity_option number_of_tokens_per_identity_option TINYINT(1) DEFAULT 0 NOT NULL');
$this->addSql('DROP INDEX idx_vetted_second_factor_vetting_type ON vetted_second_factor');
$this->addSql('ALTER TABLE vetted_second_factor CHANGE vetting_type vetting_type VARCHAR(255) DEFAULT \'unknown\'');
$this->addSql('ALTER TABLE vetting_type_hint CHANGE hints hints LONGTEXT NOT NULL');
}
}
55 changes: 55 additions & 0 deletions src/Surfnet/Migrations/Version20241128131108.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/**
* Copyright 2024 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;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241128122650 extends AbstractMigration implements ConfigurationAwareMigrationInterface
{
use ConfigurationAwareMigrationTrait;

public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
$gatewaySchema = $this->getGatewaySchema();

// this up() migration is auto-generated, please modify it to your needs
$this->addSql(sprintf('ALTER TABLE %s.second_factor CHANGE identity_vetted identity_vetted TINYINT(1) DEFAULT 1 NOT NULL', $gatewaySchema));
}

public function down(Schema $schema): void
{
$gatewaySchema = $this->getGatewaySchema();

// this down() migration is auto-generated, please modify it to your needs
$this->addSql(sprintf('ALTER TABLE %s.second_factor CHANGE identity_vetted identity_vetted TINYINT(1) DEFAULT 1', $gatewaySchema));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Configuration\Value\NumberOfTokensPerIdentityOption;
use Surfnet\Stepup\Exception\InvalidArgumentException;

/**
* Custom Type for the NumberOfTokensPerIdentityOption Value Object
*/
class NumberOfTokensPerIdentityType extends Type
class NumberOfTokensPerIdentityType extends IntegerType
{
public const NAME = 'stepup_number_of_tokens_per_identity_option';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
use phpseclib3\Math\PrimeField\Integer;
use Surfnet\Stepup\Configuration\Value\SelfAssertedTokensOption;
use TypeError;

/**
* Custom Type for the SelfAssertedTokens options Value Object
*/
class SelfAssertedTokensOptionType extends Type
class SelfAssertedTokensOptionType extends IntegerType
{
public const NAME = 'stepup_self_asserted_tokens_option';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Configuration\Value\SelfVetOption;
use TypeError;

/**
* Custom Type for the SelfVetOption Value Object
*/
class SelfVetOptionType extends Type
class SelfVetOptionType extends IntegerType
pablothedude marked this conversation as resolved.
Show resolved Hide resolved
{
public const NAME = 'stepup_self_vet_option';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Configuration\Value\SsoOn2faOption;
use TypeError;

/**
* Custom Type for the SsoOn2faOption Value Object
*/
class SsoOn2faOptionType extends Type
class SsoOn2faOptionType extends IntegerType
{
public const NAME = 'stepup_sso_on_2fa_option';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\BooleanType;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Configuration\Value\VerifyEmailOption;
Expand All @@ -27,7 +28,7 @@
/**
* Custom Type for the VerifyEmailOption Value Object
*/
class VerifyEmailOptionType extends Type
class VerifyEmailOptionType extends BooleanType
{
public const NAME = 'stepup_verify_email_option';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\JsonType;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Exception\InvalidArgumentException;
use Surfnet\Stepup\Identity\Collection\VettingTypeHintCollection;

/**
* Custom Type for the vetting type hints Value Object
*/
class VettingTypeHintsType extends Type
class VettingTypeHintsType extends JsonType
{
public const NAME = 'stepup_vetting_type_hints';

Expand All @@ -36,11 +37,6 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st
return $platform->getJsonTypeDeclarationSQL($column);
}

public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
return $value;
}

public function convertToPHPValue($value, AbstractPlatform $platform): ?VettingTypeHintCollection
{
if (is_null($value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@
/**
* Be aware that this entity is used for the RA Candidate presentation only. This entity shouldn't be used to store any RA candidates.
*/
#[ORM\Table]
#[ORM\Entity(repositoryClass: RaCandidateRepository::class, readOnly: true)]
#[ORM\Index(name: "idx_ra_candidate_institution", columns: ["institution"])]
#[ORM\Index(name: "idx_ra_candidate_name_id", columns: ["name_id"])]
#[ORM\Index(name: "idxft_ra_candidate_email", columns: ["email"], flags: ['FULLTEXT'])]
#[ORM\Index(name: "idxft_ra_candidate_commonname", columns: ["common_name"], flags: ['FULLTEXT'])]
#[ORM\Index(name: "idx_ra_institution", columns: ["ra_institution"])]
#[ORM\UniqueConstraint(name: "idx_ra_candidate_unique_identity_institution", columns: ["identity_id", "ra_institution"])]
class RaCandidate implements JsonSerializable
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function setUp(): void

$this->databaseTool->setObjectManagerName('middleware');
// Initialises schema.
$this->databaseTool->setExcludedDoctrineTables(['ra_candidate']);
$this->databaseTool->loadFixtures();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function setUp(): void
$this->databaseTool = $databaseTool->get();

// Initialises schema.
$this->databaseTool->setExcludedDoctrineTables(['ra_candidate']);
$this->databaseTool->loadFixtures([]);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class InstitutionConfiguration
{
public function __construct(
#[ORM\Id]
#[ORM\Column(length: 200)]
#[ORM\Column(length: 255)]
pablothedude marked this conversation as resolved.
Show resolved Hide resolved
public string $institution,
/**
* @var bool is the SSO on 2FA feature enabled?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function setUp(): void
}
$this->databaseTool = $databaseTool->get();
// Initialises schema.
$this->databaseTool->setExcludedDoctrineTables(['ra_candidate']);
$this->databaseTool->loadFixtures([]);

$managementPassword = $this->client->getKernel()->getContainer()->getParameter('management_password');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function setUp(): void
}
$this->databaseTool = $databaseTool->get();
// Initialises schema.
$this->databaseTool->setExcludedDoctrineTables(['ra_candidate']);
$this->databaseTool->loadFixtures([]);

$managementPassword = $this->client->getKernel()->getContainer()->getParameter('management_password');
Expand Down