diff --git a/bin/migrations.php b/bin/migrations.php index cef980d9..ad1cd720 100755 --- a/bin/migrations.php +++ b/bin/migrations.php @@ -12,7 +12,7 @@ use Doctrine\Migrations\Tools\Console\Command; use Symfony\Component\Console\Application; -$env = getenv('APP_ENV') ?: ''; +$env = getenv('APP_ENV') ?? 'global'; $dbParams = (require realpath(__DIR__) . sprintf('/../config/autoload/database.%s.php', $env))['database']; $dbParams['driver'] = 'pdo_' . $dbParams['driver']; @@ -25,10 +25,10 @@ $configuration->setCustomTemplate(__DIR__ . '/../config/migrations.template.tpl'); -$configuration->addMigrationsDirectory('Migrations', $config['migrations_paths']['Migrations']); -if (array_key_exists('TestDataMigrations', $config['migrations_paths'])) { - $configuration->addMigrationsDirectory('TestDataMigrations', $config['migrations_paths']['TestDataMigrations']); +foreach ($config['migrations_paths'] as $key => $path) { + $configuration->addMigrationsDirectory($key, $path); } + $configuration->setAllOrNothing($config['all_or_nothing']); $configuration->setCheckDatabasePlatform($config['check_database_platform']); $configuration->setTransactional($config['transactional']); diff --git a/composer.json b/composer.json index 4f1a864f..218140b8 100644 --- a/composer.json +++ b/composer.json @@ -41,26 +41,8 @@ "ext-json": "*", "ext-openssl": "*", "ext-pdo": "*", - "envms/fluentpdo": "^2.2", - "firebase/php-jwt": "^6.0", - "laminas/laminas-config-aggregator": "^1.6", - "laminas/laminas-diactoros": "^3.8.0", - "laminas/laminas-inputfilter": "^2.30", - "laminas/laminas-servicemanager": "^3.4", - "laminas/laminas-stdlib": "^3.6", - "laminas/laminas-validator": "^2.64", - "laminas/laminas-component-installer": "^2.6 || ^3.0", - "laminas/laminas-development-mode": "^3.3.0", - "mezzio/mezzio-tooling": "^2.12", - "mezzio/mezzio": "^3", - "mezzio/mezzio-cors": "^1.13", - "mezzio/mezzio-fastroute": "^3.0.3", - "mezzio/mezzio-helpers": "^5.7", - "monolog/monolog": "^3.9.0", - "ramsey/uuid": "^4.7", - "symfony/mailer": "^6.4", - "zircote/swagger-php": "^6", - "jetbrains/phpstorm-attributes": "^1.0" + "exdrals/core": "^0.1.0", + "exdrals/identity": "^0.1.0" }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^1.2", @@ -82,13 +64,10 @@ }, "autoload": { "psr-4": { - "ownHackathon\\" : "src/App/", - "ownHackathon\\Shared\\" : "src/App/Shared/src/", - "ownHackathon\\Account\\" : "src/App/Account/", - "ownHackathon\\Workspace\\" : "src/App/Workspace/src/", - "Exdrals\\Shared\\": "src/Shared/src", - "Exdrals\\Identity\\" : "src/App/Account/Identity/src/", - "Exdrals\\Mailing\\" : "src/App/Mailing/src/" + "ownHackathon\\": "src/App/", + "ownHackathon\\Shared\\": "src/App/Shared/src/", + "ownHackathon\\Account\\": "src/App/Account/", + "ownHackathon\\Workspace\\": "src/App/Workspace/src/" } }, "autoload-dev": { diff --git a/composer.lock b/composer.lock index a0ad606f..56c185d7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b5d9ef0b441a66ec0eb67bdb20fba3b6", + "content-hash": "497bea8a3045e06d048ba8897d7f5f9b", "packages": [ { "name": "brick/math", - "version": "0.14.5", + "version": "0.14.6", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "618a8077b3c326045e10d5788ed713b341fcfe40" + "reference": "32498d5e1897e7642c0b961ace2df6d7dc9a3bc3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/618a8077b3c326045e10d5788ed713b341fcfe40", - "reference": "618a8077b3c326045e10d5788ed713b341fcfe40", + "url": "https://api.github.com/repos/brick/math/zipball/32498d5e1897e7642c0b961ace2df6d7dc9a3bc3", + "reference": "32498d5e1897e7642c0b961ace2df6d7dc9a3bc3", "shasum": "" }, "require": { @@ -56,7 +56,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.14.5" + "source": "https://github.com/brick/math/tree/0.14.6" }, "funding": [ { @@ -64,7 +64,7 @@ "type": "github" } ], - "time": "2026-02-03T18:06:51+00:00" + "time": "2026-02-05T07:59:58+00:00" }, { "name": "brick/varexporter", @@ -317,6 +317,155 @@ }, "time": "2022-01-27T21:49:44+00:00" }, + { + "name": "exdrals/core", + "version": "v0.1.4", + "source": { + "type": "git", + "url": "https://github.com/Exdrals/core.git", + "reference": "14f6b2ad9811aba648be442bf3971cf7e7afbd36" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Exdrals/core/zipball/14f6b2ad9811aba648be442bf3971cf7e7afbd36", + "reference": "14f6b2ad9811aba648be442bf3971cf7e7afbd36", + "shasum": "" + }, + "require": { + "envms/fluentpdo": "^2.2", + "ext-json": "*", + "ext-openssl": "*", + "ext-pdo": "*", + "firebase/php-jwt": "^6.0", + "jetbrains/phpstorm-attributes": "^1.0", + "laminas/laminas-component-installer": "^2.6 || ^3.0", + "laminas/laminas-config-aggregator": "^1.6", + "laminas/laminas-development-mode": "^3.3.0", + "laminas/laminas-diactoros": "^3.8.0", + "laminas/laminas-inputfilter": "^2.30", + "laminas/laminas-servicemanager": "^3.4", + "laminas/laminas-stdlib": "^3.6", + "laminas/laminas-validator": "^2.64", + "mezzio/mezzio": "^3", + "mezzio/mezzio-cors": "^1.13", + "mezzio/mezzio-fastroute": "^3.0.3", + "mezzio/mezzio-helpers": "^5.7", + "mezzio/mezzio-tooling": "^2.12", + "monolog/monolog": "^3.9.0", + "php": "^8.4.0", + "ramsey/uuid": "^4.7", + "symfony/mailer": "^6.4", + "zircote/swagger-php": "^6" + }, + "type": "library", + "extra": { + "laminas": { + "component-auto-installs": [ + "mezzio/mezzio", + "mezzio/mezzio-helpers", + "mezzio/mezzio-router", + "laminas/laminas-httphandlerrunner", + "mezzio/mezzio-fastroute" + ] + } + }, + "autoload": { + "psr-4": { + "Exdrals\\Core\\": "src/", + "Exdrals\\Token\\": "src/Token/src/", + "Exdrals\\Shared\\": "src/Shared/src", + "Exdrals\\Mailing\\": "src/Mailing/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "core library for personal projects", + "homepage": "https://github.com/exdrals", + "keywords": [ + "opensource" + ], + "support": { + "docs": "https://github.com/exdrals/core", + "issues": "https://github.com/exdrals/core/issues", + "source": "https://github.com/exdrals/core" + }, + "time": "2026-02-05T22:49:44+00:00" + }, + { + "name": "exdrals/identity", + "version": "v0.1.5", + "source": { + "type": "git", + "url": "https://github.com/Exdrals/identity.git", + "reference": "e33be562269cc5bc76dbfdd6a9c0b75ebe551737" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Exdrals/identity/zipball/e33be562269cc5bc76dbfdd6a9c0b75ebe551737", + "reference": "e33be562269cc5bc76dbfdd6a9c0b75ebe551737", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-openssl": "*", + "ext-pdo": "*", + "php": "~8.4.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.2", + "doctrine/migrations": "^3.6", + "exdrals/core": "^0", + "fakerphp/faker": "^1.24", + "filp/whoops": "^2.7.1", + "helmich/phpunit-json-assert": "^3.5", + "helmich/phpunit-psr7-assert": "^4.4", + "mockery/mockery": "^1.6", + "overtrue/phplint": "^9.0", + "pestphp/pest": "^v3.7", + "phpstan/phpstan": "^2.1.33", + "phpstan/phpstan-deprecation-rules": "^2.0.3", + "phpunit/php-code-coverage": "^11.0.0", + "phpunit/phpunit": "^11.5.0", + "roave/security-advisories": "dev-master", + "slevomat/coding-standard": "^8.15", + "squizlabs/php_codesniffer": "^4.0" + }, + "type": "library", + "extra": { + "laminas": { + "component-auto-installs": [ + "mezzio/mezzio", + "mezzio/mezzio-helpers", + "mezzio/mezzio-router", + "laminas/laminas-httphandlerrunner", + "mezzio/mezzio-fastroute" + ] + } + }, + "autoload": { + "psr-4": { + "Exdrals\\Identity\\": "src/Identity/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "offers authentication for personal projects", + "homepage": "https://github.com/exdrals", + "keywords": [ + "hackathon", + "opensource" + ], + "support": { + "docs": "https://github.com/exdrals/identity", + "issues": "https://github.com/exdrals/identity/issues", + "source": "https://github.com/exdrals/identity" + }, + "time": "2026-02-05T23:39:43+00:00" + }, { "name": "fig/http-message-util", "version": "1.1.5", @@ -7301,12 +7450,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "258cd5fdcb59c29f421927b2cf77f48de9458a98" + "reference": "7ea2d110787f6807213e27a1255c6b858ad99d89" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/258cd5fdcb59c29f421927b2cf77f48de9458a98", - "reference": "258cd5fdcb59c29f421927b2cf77f48de9458a98", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/7ea2d110787f6807213e27a1255c6b858ad99d89", + "reference": "7ea2d110787f6807213e27a1255c6b858ad99d89", "shasum": "" }, "conflict": { @@ -7786,7 +7935,7 @@ "microsoft/microsoft-graph": ">=1.16,<1.109.1|>=2,<2.0.1", "microsoft/microsoft-graph-beta": "<2.0.1", "microsoft/microsoft-graph-core": "<2.0.2", - "microweber/microweber": "<=2.0.19", + "microweber/microweber": "<2.0.20", "mikehaertl/php-shellcommand": "<1.6.1", "mineadmin/mineadmin": "<=3.0.9", "miniorange/miniorange-saml": "<1.4.3", @@ -8311,7 +8460,7 @@ "type": "tidelift" } ], - "time": "2026-02-04T22:06:32+00:00" + "time": "2026-02-05T22:08:29+00:00" }, { "name": "sebastian/cli-parser", diff --git a/config/autoload/migrations.action.php b/config/autoload/migrations.action.php index 0626d103..156310ad 100644 --- a/config/autoload/migrations.action.php +++ b/config/autoload/migrations.action.php @@ -11,7 +11,8 @@ ], 'migrations_paths' => [ - 'Migrations' => __DIR__ . '/../../database/migrations', + 'Exdrals\\Identity\\Migrations' => 'vendor/exdrals/identity/database/migrations', + 'ownHackathon\\Migrations' => 'database/migrations', ], 'all_or_nothing' => true, diff --git a/config/autoload/migrations.develope.php b/config/autoload/migrations.develope.php index 0626d103..156310ad 100644 --- a/config/autoload/migrations.develope.php +++ b/config/autoload/migrations.develope.php @@ -11,7 +11,8 @@ ], 'migrations_paths' => [ - 'Migrations' => __DIR__ . '/../../database/migrations', + 'Exdrals\\Identity\\Migrations' => 'vendor/exdrals/identity/database/migrations', + 'ownHackathon\\Migrations' => 'database/migrations', ], 'all_or_nothing' => true, diff --git a/config/autoload/migrations.global.php b/config/autoload/migrations.global.php index 0626d103..156310ad 100644 --- a/config/autoload/migrations.global.php +++ b/config/autoload/migrations.global.php @@ -11,7 +11,8 @@ ], 'migrations_paths' => [ - 'Migrations' => __DIR__ . '/../../database/migrations', + 'Exdrals\\Identity\\Migrations' => 'vendor/exdrals/identity/database/migrations', + 'ownHackathon\\Migrations' => 'database/migrations', ], 'all_or_nothing' => true, diff --git a/config/autoload/migrations.testing.php b/config/autoload/migrations.testing.php index 0626d103..156310ad 100644 --- a/config/autoload/migrations.testing.php +++ b/config/autoload/migrations.testing.php @@ -11,7 +11,8 @@ ], 'migrations_paths' => [ - 'Migrations' => __DIR__ . '/../../database/migrations', + 'Exdrals\\Identity\\Migrations' => 'vendor/exdrals/identity/database/migrations', + 'ownHackathon\\Migrations' => 'database/migrations', ], 'all_or_nothing' => true, diff --git a/config/config.php b/config/config.php index d3216a54..0e7a0589 100644 --- a/config/config.php +++ b/config/config.php @@ -34,7 +34,8 @@ class_exists(\Mezzio\Swoole\ConfigProvider::class) }, // Default App module config \ownHackathon\ConfigProvider::class, - \Exdrals\Shared\ConfigProvider::class, + \Exdrals\Core\ConfigProvider::class, + \Exdrals\Identity\ConfigProvider::class, // Load application config in a pre-defined order in such a way that local settings // overwrite global settings. (Loaded as first to last): diff --git a/config/routes.php b/config/routes.php index 65808264..4f1363e1 100644 --- a/config/routes.php +++ b/config/routes.php @@ -3,9 +3,9 @@ use Exdrals\Shared\Domain\Enum\Router\RouteIdent; use Mezzio\Application; use Mezzio\MiddlewareFactory; +use ownHackathon\Shared\Handler\PingHandler; +use ownHackathon\Shared\Handler\SwaggerUIHandler; use Psr\Container\ContainerInterface; -use Exdrals\Shared\Handler\PingHandler; -use Exdrals\Shared\Handler\SwaggerUIHandler; return static function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void { $app->get( diff --git a/database/migrations/Version20231103223745_CreateAccountTable.php b/database/migrations/Version20231103223745_CreateAccountTable.php deleted file mode 100644 index 9f509566..00000000 --- a/database/migrations/Version20231103223745_CreateAccountTable.php +++ /dev/null @@ -1,38 +0,0 @@ -createTable('Account'); - - $table->addColumn('id', Types::INTEGER, ['autoincrement' => true, 'unsigned' => true,]); - $table->addColumn('uuid', Types::GUID, ); - $table->addColumn('name', Types::STRING, ['length' => 64, 'notnull' => false,]); - $table->addColumn('password', Types::STRING, ['length' => 255, 'notnull' => false,]); - $table->addColumn('email', Types::STRING, ['length' => 512,]); - $table->addColumn('registeredAt', Types::DATETIME_IMMUTABLE, ['default' => 'CURRENT_TIMESTAMP',]); - $table->addColumn('lastActionAt', Types::DATETIME_IMMUTABLE, ['default' => 'CURRENT_TIMESTAMP',]); - - $table->addPrimaryKeyConstraint( - PrimaryKeyConstraint::editor() - ->setUnquotedColumnNames('id') - ->create() - ); - $table->addUniqueIndex(['uuid'], 'account_uuid_UNIQUE'); - $table->addUniqueIndex(['name'], 'account_name_UNIQUE'); - $table->addUniqueIndex(['email'], 'account_email_UNIQUE'); - } - - public function down(Schema $schema): void - { - $schema->dropTable('Account'); - } -} diff --git a/database/migrations/Version20231103224045_CreateAccountAccessAuthTable.php b/database/migrations/Version20231103224045_CreateAccountAccessAuthTable.php deleted file mode 100644 index 89012faa..00000000 --- a/database/migrations/Version20231103224045_CreateAccountAccessAuthTable.php +++ /dev/null @@ -1,37 +0,0 @@ -createTable('AccountAccessAuth'); - - $table->addColumn('id', Types::INTEGER, ['autoincrement' => true, 'unsigned' => true,]); - $table->addColumn('accountId', Types::INTEGER, ['unsigned' => true,]); - $table->addColumn('label', Types::STRING, ['length' => 64, 'default' => 'default']); - $table->addColumn('refreshToken', Types::STRING, ['length' => 512,]); - $table->addColumn('userAgent', Types::STRING, ['length' => 255, 'default' => 'unknown']); - $table->addColumn('clientIdentHash', Types::STRING, ['length' => 128,]); - $table->addColumn('createdAt', Types::DATETIME_IMMUTABLE, ['default' => 'CURRENT_TIMESTAMP',]); - - $table->addPrimaryKeyConstraint( - PrimaryKeyConstraint::editor() - ->setUnquotedColumnNames('id') - ->create() - ); - $table->addUniqueIndex(['refreshToken'], 'account_access_auth_refresh_token_UNIQUE'); - $table->addUniqueIndex(['clientIdentHash'], 'account_access_auth_client_ident_hash_UNIQUE'); - } - - public function down(Schema $schema): void - { - $schema->dropTable('AccountAccessAuth'); - } -} diff --git a/database/migrations/Version20231103224046_CreateAccountActivationTable.php b/database/migrations/Version20231103224046_CreateAccountActivationTable.php deleted file mode 100644 index c8d05e06..00000000 --- a/database/migrations/Version20231103224046_CreateAccountActivationTable.php +++ /dev/null @@ -1,33 +0,0 @@ -createTable('AccountActivation'); - - $table->addColumn('id', Types::INTEGER, ['autoincrement' => true, 'unsigned' => true,]); - $table->addColumn('email', Types::STRING, ['length' => 512,]); - $table->addColumn('token', Types::GUID, ); - $table->addColumn('createdAt', Types::DATETIME_IMMUTABLE, ['default' => 'CURRENT_TIMESTAMP',]); - - $table->addPrimaryKeyConstraint( - PrimaryKeyConstraint::editor() - ->setUnquotedColumnNames('id') - ->create() - ); - $table->addUniqueIndex(['token'], 'account_activation_token_UNIQUE'); - } - - public function down(Schema $schema): void - { - $schema->dropTable('AccountActivation'); - } -} diff --git a/database/migrations/Version20231103224047_CreateTokenTable.php b/database/migrations/Version20231103224047_CreateTokenTable.php deleted file mode 100644 index f282552d..00000000 --- a/database/migrations/Version20231103224047_CreateTokenTable.php +++ /dev/null @@ -1,34 +0,0 @@ -createTable('Token'); - - $table->addColumn('id', Types::INTEGER, ['autoincrement' => true, 'unsigned' => true,]); - $table->addColumn('accountId', Types::INTEGER, ['unsigned' => true,]); - $table->addColumn('token', Types::GUID, ); - $table->addColumn('tokenType', Types::SMALLINT, ['unsigned' => true, 'length' => 2,]); - $table->addColumn('createdAt', Types::DATETIME_IMMUTABLE, ['default' => 'CURRENT_TIMESTAMP',]); - - $table->addPrimaryKeyConstraint( - PrimaryKeyConstraint::editor() - ->setUnquotedColumnNames('id') - ->create() - ); - $table->addUniqueIndex(['token'], 'token_token_UNIQUE'); - } - - public function down(Schema $schema): void - { - $schema->dropTable('Token'); - } -} diff --git a/database/migrations/Version20260121203207_CreateWorkspaceTable.php b/database/migrations/Version20260121203207_CreateWorkspaceTable.php index ef32825e..2cd84c4e 100644 --- a/database/migrations/Version20260121203207_CreateWorkspaceTable.php +++ b/database/migrations/Version20260121203207_CreateWorkspaceTable.php @@ -1,6 +1,6 @@ getMergedConfig(); - } -} diff --git a/src/App/Account/Identity/config/autoload/token.global.php.dist b/src/App/Account/Identity/config/autoload/token.global.php.dist deleted file mode 100644 index ac8d71d3..00000000 --- a/src/App/Account/Identity/config/autoload/token.global.php.dist +++ /dev/null @@ -1,20 +0,0 @@ - [ - 'refresh' => [ - 'key' => 'token secret', - 'algorithmus' => 'HS512', - 'duration' => 60 * 60 * 24 * 7 * 12, - 'iss' => 'Issuer of the token', - 'aud' => 'recipients of the token', - ], - 'access' => [ - 'key' =>'token secret', - 'algorithmus' => 'HS512', - 'duration' => 60 * 5, - 'iss' => 'Issuer of the token', - 'aud' => 'recipients of the token', - ], - ], -]; diff --git a/src/App/Account/Identity/src/ConfigProvider.php b/src/App/Account/Identity/src/ConfigProvider.php deleted file mode 100644 index 0e8d67d9..00000000 --- a/src/App/Account/Identity/src/ConfigProvider.php +++ /dev/null @@ -1,387 +0,0 @@ - $this->getRoutes(), - 'dependencies' => $this->getDependencies(), - ConfigAbstractFactory::class => $this->getAbstractFactoryConfig(), - ]; - } - - public function getRoutes(): array - { - return [ - [ - 'path' => '/api/account[/]', - 'allowed_methods' => ['POST'], - 'middleware' => [ - Middleware\IdentityExceptionMappingMiddleware::class, - Middleware\Account\Validation\EmailInputValidatorMiddleware::class, - Handler\AccountRegisterHandler::class, - ], - 'name' => 'api_identity_register', - ], - [ - 'path' => '/api/account/activation/[{token}[/]]', - 'allowed_methods' => ['POST'], - 'middleware' => [ - Middleware\IdentityExceptionMappingMiddleware::class, - Middleware\Account\Validation\ActivationInputValidatorMiddleware::class, - FluentTransactionMiddleware::class, - Handler\AccountActivationHandler::class, - ], - 'name' => 'api_identity_activation', - ], - - [ - 'path' => '/api/account/authentication[/]', - 'allowed_methods' => ['POST'], - 'middleware' => [ - Middleware\IdentityExceptionMappingMiddleware::class, - Middleware\Account\Authentication\AuthenticationConditionsMiddleware::class, - Middleware\Account\Authentication\AuthenticationValidationMiddleware::class, - Handler\AuthenticationHandler::class, - ], - 'name' => 'api_identity_authentication', - ], - [ - 'path' => '/api/token/refresh[/]', - 'allowed_methods' => ['GET'], - 'middleware' => [ - Middleware\IdentityExceptionMappingMiddleware::class, - Middleware\Token\RefreshTokenValidationMiddleware::class, - Handler\AccessTokenHandler::class, - ], - 'name' => 'api_identity_token_refresh', - ], - - [ - 'path' => '/api/account/password/forgotten[/]', - 'allowed_methods' => ['POST'], - 'middleware' => [ - Middleware\IdentityExceptionMappingMiddleware::class, - Middleware\Account\Validation\EmailInputValidatorMiddleware::class, - Handler\AccountPasswordForgottenHandler::class, - ], - 'name' => 'api_identity_password_forgotten', - ], - [ - 'path' => '/api/account/password/[{token}[/]]', - 'allowed_methods' => ['PATCH'], - 'middleware' => [ - Middleware\IdentityExceptionMappingMiddleware::class, - Middleware\Account\Validation\PasswordInputValidatorMiddleware::class, - Handler\AccountPasswordHandler::class, - ], - 'name' => 'api_identity_password_change', - ], - - [ - 'path' => '/api/account/logout[/]', - 'allowed_methods' => ['POST'], - 'middleware' => [ - Middleware\IdentityExceptionMappingMiddleware::class, - RequireLoginMiddleware::class, - Middleware\Token\AccessTokenValidationMiddleware::class, - Middleware\Token\RefreshTokenViaBodyValidationMiddleware::class, - Handler\LogoutHandler::class, - ], - 'name' => 'api_identity_logout', - ], - [ - 'path' => '/api/account/[{accountUuid:[0-9a-fA-F\-]+}[/]]', - 'allowed_methods' => ['GET'], - 'middleware' => [ - Middleware\IdentityExceptionMappingMiddleware::class, - RequireLoginMiddleware::class, - ], - 'name' => 'api_account_detail', - ], - ]; - } - - public function getDependencies(): array - { - return [ - 'aliases' => [ - AccountAccessAuthHydratorInterface::class => Infrastructure\Hydrator\Account\AccountAccessAuthHydrator::class, - AccountActivationHydratorInterface::class => Infrastructure\Hydrator\Account\AccountActivationHydrator::class, - AccountHydratorInterface::class => Infrastructure\Hydrator\Account\AccountHydrator::class, - TokenHydratorInterface::class => Infrastructure\Hydrator\Token\TokenHydrator::class, - - AccountRepositoryInterface::class => Infrastructure\Persistence\Repository\Account\AccountRepository::class, - AccountActivationRepositoryInterface::class => Infrastructure\Persistence\Repository\Account\AccountActivationRepository::class, - AccountAccessAuthRepositoryInterface::class => Infrastructure\Persistence\Repository\Account\AccountAccessAuthRepository::class, - TokenRepositoryInterface::class => Infrastructure\Persistence\Repository\Token\TokenRepository::class, - AccountStoreInterface::class => Infrastructure\Persistence\Table\Account\AccountTable::class, - AccountAccessAuthStoreInterface::class => Infrastructure\Persistence\Table\Account\AccountAccessAuthTable::class, - AccountActivationStoreInterface::class => Infrastructure\Persistence\Table\Account\AccountActivationTable::class, - TokenStoreInterface::class => Infrastructure\Persistence\Table\Token\TokenTable::class, - ], - 'invokables' => [ - ], - 'factories' => [ - Infrastructure\Hydrator\Account\AccountAccessAuthHydrator::class => InvokableFactory::class, - Infrastructure\Hydrator\Account\AccountActivationHydrator::class => ConfigAbstractFactory::class, - Infrastructure\Hydrator\Account\AccountHydrator::class => ConfigAbstractFactory::class, - Infrastructure\Hydrator\Token\TokenHydrator::class => ConfigAbstractFactory::class, - Middleware\Account\Authentication\AuthenticationConditionsMiddleware::class => InvokableFactory::class, - Middleware\Account\Authentication\AuthenticationValidationMiddleware::class => ConfigAbstractFactory::class, - Middleware\Account\Validation\ActivationInputValidatorMiddleware::class => ConfigAbstractFactory::class, - Middleware\Account\Validation\EmailInputValidatorMiddleware::class => ConfigAbstractFactory::class, - Middleware\Account\Validation\PasswordInputValidatorMiddleware::class => ConfigAbstractFactory::class, - Middleware\Account\LastActivityUpdaterMiddleware::class => ConfigAbstractFactory::class, - Infrastructure\Service\Account\PasswordChangeService::class => ConfigAbstractFactory::class, - Middleware\Account\RequestAuthenticationMiddleware::class => ConfigAbstractFactory::class, - Middleware\ClientIdentification\ClientIdentificationMiddleware::class => ConfigAbstractFactory::class, - Middleware\Token\AccessTokenValidationMiddleware::class => ConfigAbstractFactory::class, - Middleware\Token\RefreshTokenAccountMiddleware::class => ConfigAbstractFactory::class, - Middleware\Token\RefreshTokenDatabaseExistenceMiddleware::class => ConfigAbstractFactory::class, - Middleware\Token\RefreshTokenMatchClientIdentificationMiddleware::class => InvokableFactory::class, - Middleware\Token\RefreshTokenValidationMiddleware::class => ConfigAbstractFactory::class, - Middleware\Token\RefreshTokenViaBodyValidationMiddleware::class => ConfigAbstractFactory::class, - Infrastructure\Persistence\Repository\Account\AccountAccessAuthRepository::class => ConfigAbstractFactory::class, - Infrastructure\Persistence\Repository\Account\AccountActivationRepository::class => ConfigAbstractFactory::class, - Infrastructure\Persistence\Repository\Account\AccountRepository::class => ConfigAbstractFactory::class, - Infrastructure\Persistence\Repository\Token\TokenRepository::class => ConfigAbstractFactory::class, - Infrastructure\Service\Account\AccountService::class => ConfigAbstractFactory::class, - Infrastructure\Service\Authentication\AuthenticationService::class => InvokableFactory::class, - Infrastructure\Service\ClientIdentification\ClientIdentificationService::class => InvokableFactory::class, - EmailService::class => EmailServiceFactory::class, - Infrastructure\Service\Token\AccessTokenService::class => Infrastructure\Service\Token\AccessTokenServiceFactory::class, - Infrastructure\Service\Token\ActivationTokenService::class => Infrastructure\Service\Token\ActivationTokenServiceFactory::class, - Infrastructure\Service\Token\PasswordTokenService::class => Infrastructure\Service\Token\PasswordTokenServiceFactory::class, - Infrastructure\Service\Token\RefreshTokenService::class => Infrastructure\Service\Token\RefreshTokenServiceFactory::class, - Infrastructure\Persistence\Table\Account\AccountAccessAuthTable::class => ConfigAbstractFactory::class, - Infrastructure\Persistence\Table\Account\AccountActivationTable::class => ConfigAbstractFactory::class, - Infrastructure\Persistence\Table\Account\AccountTable::class => ConfigAbstractFactory::class, - Infrastructure\Persistence\Table\Token\TokenTable::class => ConfigAbstractFactory::class, - - EmailInput::class => InvokableFactory::class, - PasswordInput::class => InvokableFactory::class, - AccountNameInput::class => InvokableFactory::class, - Infrastructure\Validator\AccountActivationValidator::class => ConfigAbstractFactory::class, - Infrastructure\Validator\AuthenticationValidator::class => ConfigAbstractFactory::class, - EMailValidator::class => ConfigAbstractFactory::class, - Infrastructure\Validator\PasswordValidator::class => ConfigAbstractFactory::class, - AuthenticationHandler::class => ConfigAbstractFactory::class, - AccessTokenHandler::class => ConfigAbstractFactory::class, - AccountAuthenticationService::class => ConfigAbstractFactory::class, - AccountRegisterHandler::class => ConfigAbstractFactory::class, - AccountRegisterService::class => ConfigAbstractFactory::class, - Handler\AccountActivationHandler::class => ConfigAbstractFactory::class, - AccountCreatorService::class => ConfigAbstractFactory::class, - AccountPasswordForgottenHandler::class => ConfigAbstractFactory::class, - PasswordService::class => ConfigAbstractFactory::class, - AccountPasswordHandler::class => ConfigAbstractFactory::class, - LogoutHandler::class => ConfigAbstractFactory::class, - ], - - ]; - } - - public function getAbstractFactoryConfig(): array - { - return [ - Infrastructure\Hydrator\Account\AccountActivationHydrator::class => [ - UuidFactoryInterface::class, - ], - Infrastructure\Hydrator\Account\AccountHydrator::class => [ - UuidFactoryInterface::class, - ], - Infrastructure\Hydrator\Token\TokenHydrator::class => [ - UuidFactoryInterface::class, - ], - Middleware\Account\Authentication\AuthenticationValidationMiddleware::class => [ - AuthenticationValidator::class, - ], - Middleware\Account\Validation\ActivationInputValidatorMiddleware::class => [ - AccountActivationValidator::class, - ], - Middleware\Account\Validation\EmailInputValidatorMiddleware::class => [ - EMailValidator::class, - ], - Middleware\Account\Validation\PasswordInputValidatorMiddleware::class => [ - PasswordValidator::class, - ], - Middleware\Account\LastActivityUpdaterMiddleware::class => [ - AccountRepositoryInterface::class, - ], - Infrastructure\Service\Account\PasswordChangeService::class => [ - AccountRepositoryInterface::class, - TokenRepositoryInterface::class, - AccountService::class, - ], - Middleware\Account\RequestAuthenticationMiddleware::class => [ - AccessTokenService::class, - AccountRepositoryInterface::class, - UuidFactoryInterface::class, - LoggerInterface::class, - ], - Middleware\ClientIdentification\ClientIdentificationMiddleware::class => [ - ClientIdentificationService::class, - ], - Middleware\Token\AccessTokenValidationMiddleware::class => [ - AccessTokenService::class, - ], - Middleware\Token\RefreshTokenAccountMiddleware::class => [ - AccountRepositoryInterface::class, - ], - Middleware\Token\RefreshTokenDatabaseExistenceMiddleware::class => [ - AccountAccessAuthRepositoryInterface::class, - ], - Middleware\Token\RefreshTokenValidationMiddleware::class => [ - RefreshTokenService::class, - ], - Middleware\Token\RefreshTokenViaBodyValidationMiddleware::class => [ - RefreshTokenService::class, - ], - Infrastructure\Persistence\Repository\Account\AccountAccessAuthRepository::class => [ - AccountAccessAuthStoreInterface::class, - ], - Infrastructure\Persistence\Repository\Account\AccountActivationRepository::class => [ - AccountActivationStoreInterface::class, - ], - Infrastructure\Persistence\Repository\Account\AccountRepository::class => [ - AccountStoreInterface::class, - ], - Infrastructure\Persistence\Repository\Token\TokenRepository::class => [ - TokenStoreInterface::class, - ], - Infrastructure\Service\Account\AccountService::class => [ - AccountRepositoryInterface::class, - AccountAccessAuthRepositoryInterface::class, - TokenRepositoryInterface::class, - PasswordTokenService::class, - UuidFactoryInterface::class, - ], - Infrastructure\Persistence\Table\Account\AccountAccessAuthTable::class => [ - Query::class, - AccountAccessAuthHydratorInterface::class, - ], - Infrastructure\Persistence\Table\Account\AccountActivationTable::class => [ - Query::class, - AccountActivationHydratorInterface::class, - ], - Infrastructure\Persistence\Table\Account\AccountTable::class => [ - Query::class, - AccountHydratorInterface::class, - ], - Infrastructure\Persistence\Table\Token\TokenTable::class => [ - Query::class, - TokenHydratorInterface::class, - ], - Infrastructure\Validator\AccountActivationValidator::class => [ - AccountNameInput::class, - PasswordInput::class, - ], - Infrastructure\Validator\AuthenticationValidator::class => [ - EmailInput::class, - PasswordInput::class, - ], - EMailValidator::class => [ - EmailInput::class, - ], - Infrastructure\Validator\PasswordValidator::class => [ - PasswordInput::class, - ], - AuthenticationHandler::class => [ - AccountAuthenticationService::class, - ], - AccessTokenHandler::class => [ - RefreshTokenService::class, - ], - AccountAuthenticationService::class => [ - AccountRepositoryInterface::class, - AccountAccessAuthRepositoryInterface::class, - AuthenticationService::class, - RefreshTokenService::class, - AccessTokenService::class, - AccountService::class, - ], - AccountRegisterHandler::class => [ - AccountRegisterService::class, - ], - AccountRegisterService::class => [ - AccountService::class, - AccountActivationRepositoryInterface::class, - ActivationTokenService::class, - UuidFactoryInterface::class, - ], - Handler\AccountActivationHandler::class => [ - AccountCreatorService::class, - UrlHelper::class, - ], - AccountCreatorService::class => [ - AccountActivationRepositoryInterface::class, - AccountRepositoryInterface::class, - UuidFactoryInterface::class, - ], - AccountPasswordForgottenHandler::class => [ - PasswordService::class, - ], - PasswordService::class => [ - AccountService::class, - ], - AccountPasswordHandler::class => [ - PasswordChangeService::class, - ], - LogoutHandler::class => [ - AccountService::class, - ], - ]; - } -} diff --git a/src/App/Account/Identity/src/DTO/Account/Account.php b/src/App/Account/Identity/src/DTO/Account/Account.php deleted file mode 100644 index 148e3154..00000000 --- a/src/App/Account/Identity/src/DTO/Account/Account.php +++ /dev/null @@ -1,60 +0,0 @@ -value, - format: DateTimeFormat::DEFAULT->value, - example: '2024-01-20 14:30:00' - )] - public string $registeredAt, - #[OA\Property( - description: 'The timestamp of the last activity on this account', - type: DataType::STRING->value, - format: DateTimeFormat::DEFAULT->value, - example: '2024-05-15 10:00:00' - )] - public string $lastActionAt, - ) { - } - - public static function createFromAccount(AccountInterface $account): self - { - return new self( - uuid: $account->uuid->toString(), - name: $account->name, - email: $account->email->toString(), - registeredAt: $account->registeredAt->format(DateTimeFormat::DEFAULT->value), - lastActionAt: $account->lastActionAt->format(DateTimeFormat::DEFAULT->value), - ); - } -} diff --git a/src/App/Account/Identity/src/DTO/Account/AccountPassword.php b/src/App/Account/Identity/src/DTO/Account/AccountPassword.php deleted file mode 100644 index 34473f0e..00000000 --- a/src/App/Account/Identity/src/DTO/Account/AccountPassword.php +++ /dev/null @@ -1,24 +0,0 @@ -value, - )] - public string $password, - ) { - } - - public static function fromString(string $password): self - { - return new self($password); - } -} diff --git a/src/App/Account/Identity/src/DTO/Account/AccountRegistration.php b/src/App/Account/Identity/src/DTO/Account/AccountRegistration.php deleted file mode 100644 index d46d6e1f..00000000 --- a/src/App/Account/Identity/src/DTO/Account/AccountRegistration.php +++ /dev/null @@ -1,29 +0,0 @@ -value, - )] - public string $accountName, - #[OA\Property( - description: 'The Password', - type: DataType::STRING->value, - )] - public string $password, - ) { - } - - public static function fromString(string $accountName, string $password): self - { - return new self($accountName, $password); - } -} diff --git a/src/App/Account/Identity/src/DTO/Account/ApiMe.php b/src/App/Account/Identity/src/DTO/Account/ApiMe.php deleted file mode 100644 index f7b42b05..00000000 --- a/src/App/Account/Identity/src/DTO/Account/ApiMe.php +++ /dev/null @@ -1,16 +0,0 @@ -value, - )] - public string $email, - #[OA\Property( - description: 'The Password from Account', - type: DataType::STRING->value, - )] - public string $password, - ) { - } - - public static function fromArray(array $data): self - { - return new self( - $data['email'] ?? '', - $data['password'] ?? '', - ); - } -} diff --git a/src/App/Account/Identity/src/DTO/Client/ClientIdentification.php b/src/App/Account/Identity/src/DTO/Client/ClientIdentification.php deleted file mode 100644 index 2c4d8d75..00000000 --- a/src/App/Account/Identity/src/DTO/Client/ClientIdentification.php +++ /dev/null @@ -1,17 +0,0 @@ -value, - )] - public string $email, - ) { - } - - public static function fromString(string $email): self - { - return new self($email); - } -} diff --git a/src/App/Account/Identity/src/DTO/Response/AuthenticationResponse.php b/src/App/Account/Identity/src/DTO/Response/AuthenticationResponse.php deleted file mode 100644 index c9a56862..00000000 --- a/src/App/Account/Identity/src/DTO/Response/AuthenticationResponse.php +++ /dev/null @@ -1,31 +0,0 @@ -value, - )] - public string $accessToken, - #[OA\Property( - description: 'The refresh token after a valid log-in', - type: DataType::STRING->value, - )] - public string $refreshToken, - ) { - } - - public static function from(AccessToken $accessToken, RefreshToken $refreshToken): self - { - return new self($accessToken->accessToken, $refreshToken->refreshToken); - } -} diff --git a/src/App/Account/Identity/src/DTO/Response/HttpResponseMessage.php b/src/App/Account/Identity/src/DTO/Response/HttpResponseMessage.php deleted file mode 100644 index e87df571..00000000 --- a/src/App/Account/Identity/src/DTO/Response/HttpResponseMessage.php +++ /dev/null @@ -1,33 +0,0 @@ -value, - example: HTTP::STATUS_BAD_REQUEST - )] - public int $statusCode, - #[OA\Property( - description: 'The Message', - type: DataType::STRING->value, - example: IdentityStatusMessage::BAD_REQUEST - )] - public string $message, - ) { - } - - public static function create(int $statusCode, string $message): self - { - return new self($statusCode, $message); - } -} diff --git a/src/App/Account/Identity/src/DTO/Token/AccessToken.php b/src/App/Account/Identity/src/DTO/Token/AccessToken.php deleted file mode 100644 index b8b6a66a..00000000 --- a/src/App/Account/Identity/src/DTO/Token/AccessToken.php +++ /dev/null @@ -1,24 +0,0 @@ -value, - )] - public string $accessToken, - ) { - } - - public static function fromString(string $token): self - { - return new self($token); - } -} diff --git a/src/App/Account/Identity/src/DTO/Token/AccountPasswordToken.php b/src/App/Account/Identity/src/DTO/Token/AccountPasswordToken.php deleted file mode 100644 index 9f475c65..00000000 --- a/src/App/Account/Identity/src/DTO/Token/AccountPasswordToken.php +++ /dev/null @@ -1,24 +0,0 @@ -value, - )] - public string $accountPasswordToken, - ) { - } - - public static function fromString(string $accountPasswordToken): self - { - return new self($accountPasswordToken); - } -} diff --git a/src/App/Account/Identity/src/DTO/Token/JwtTokenConfig.php b/src/App/Account/Identity/src/DTO/Token/JwtTokenConfig.php deleted file mode 100644 index 0450635e..00000000 --- a/src/App/Account/Identity/src/DTO/Token/JwtTokenConfig.php +++ /dev/null @@ -1,26 +0,0 @@ -value, - )] - public string $refreshToken, - ) { - } - - public static function fromString(string $token): self - { - return new self($token); - } -} diff --git a/src/App/Account/Identity/src/DTO/Token/Token.php b/src/App/Account/Identity/src/DTO/Token/Token.php deleted file mode 100644 index 1270fb90..00000000 --- a/src/App/Account/Identity/src/DTO/Token/Token.php +++ /dev/null @@ -1,24 +0,0 @@ -value, - )] - public ?string $token, - ) { - } - - public static function fromString(?string $token): self - { - return new self($token); - } -} diff --git a/src/App/Account/Identity/src/Domain/Account.php b/src/App/Account/Identity/src/Domain/Account.php deleted file mode 100644 index d846ca47..00000000 --- a/src/App/Account/Identity/src/Domain/Account.php +++ /dev/null @@ -1,26 +0,0 @@ -account, $this->accountId); - } -} diff --git a/src/App/Account/Identity/src/Domain/Exception/DuplicateEMailException.php b/src/App/Account/Identity/src/Domain/Exception/DuplicateEMailException.php deleted file mode 100644 index 5cb84f00..00000000 --- a/src/App/Account/Identity/src/Domain/Exception/DuplicateEMailException.php +++ /dev/null @@ -1,14 +0,0 @@ - []]], - tags: ['Account'] - )] - #[OA\Response( - response: HTTP::STATUS_OK, - description: 'Successfully issued a new access token.', - content: [new OA\JsonContent(ref: AccessToken::class)] - )] - #[OA\Response( - response: HTTP::STATUS_UNAUTHORIZED, - description: 'Authentication failed. This happens if the refresh token is expired, ' . - 'revoked, or invalid. The user must perform a full login again.', - content: [new OA\JsonContent(ref: HttpResponseMessage::class)] - )] - public function handle(ServerRequestInterface $request): ResponseInterface - { - $refreshToken = $request->getAttribute(RefreshToken::class); - $clientIdentification = $request->getAttribute(ClientIdentification::class); - - $refreshedAccessToken = $this->refreshTokenService->refresh($refreshToken, $clientIdentification); - - return new JsonResponse($refreshedAccessToken, HTTP::STATUS_OK); - } -} diff --git a/src/App/Account/Identity/src/Handler/AccountActivationHandler.php b/src/App/Account/Identity/src/Handler/AccountActivationHandler.php deleted file mode 100644 index b27d8871..00000000 --- a/src/App/Account/Identity/src/Handler/AccountActivationHandler.php +++ /dev/null @@ -1,70 +0,0 @@ -getAttribute('token'); - $accountData = $request->getAttribute(AccountRegistration::class); - - $account = $this->accountCreator->create($accountData, $activationToken); - - $location = $this->urlHelper->generate('api_account_detail', ['accountUuid' => $account->uuid]); - - return new JsonResponse($account, HTTP::STATUS_CREATED, ['Location' => $location]); - } -} diff --git a/src/App/Account/Identity/src/Handler/AccountPasswordForgottenHandler.php b/src/App/Account/Identity/src/Handler/AccountPasswordForgottenHandler.php deleted file mode 100644 index 7355e58f..00000000 --- a/src/App/Account/Identity/src/Handler/AccountPasswordForgottenHandler.php +++ /dev/null @@ -1,48 +0,0 @@ -getAttribute(EmailType::class); - $this->passwordService->sendTokenForInitiateResetPassword($email); - - return new JsonResponse([], HTTP::STATUS_OK); - } -} diff --git a/src/App/Account/Identity/src/Handler/AccountPasswordHandler.php b/src/App/Account/Identity/src/Handler/AccountPasswordHandler.php deleted file mode 100644 index f4fe1d0a..00000000 --- a/src/App/Account/Identity/src/Handler/AccountPasswordHandler.php +++ /dev/null @@ -1,66 +0,0 @@ -getAttribute('token')); - $password = $request->getAttribute(AccountPassword::class); - - $this->passwordChangeService->change($token, $password); - - return new JsonResponse([], HTTP::STATUS_OK); - } -} diff --git a/src/App/Account/Identity/src/Handler/AccountRegisterHandler.php b/src/App/Account/Identity/src/Handler/AccountRegisterHandler.php deleted file mode 100644 index f74baec8..00000000 --- a/src/App/Account/Identity/src/Handler/AccountRegisterHandler.php +++ /dev/null @@ -1,50 +0,0 @@ -getAttribute(EmailType::class); - - $this->accountRegisterService->register($email); - - - return new JsonResponse([], HTTP::STATUS_OK); - } -} diff --git a/src/App/Account/Identity/src/Handler/AuthenticationHandler.php b/src/App/Account/Identity/src/Handler/AuthenticationHandler.php deleted file mode 100644 index f2873239..00000000 --- a/src/App/Account/Identity/src/Handler/AuthenticationHandler.php +++ /dev/null @@ -1,63 +0,0 @@ -getAttribute(AuthenticationRequest::class); - $clientId = $request->getAttribute(ClientIdentification::class); - - $response = $this->authService->authenticate($data, $clientId); - - return new JsonResponse($response, HTTP::STATUS_OK); - } -} diff --git a/src/App/Account/Identity/src/Handler/LogoutHandler.php b/src/App/Account/Identity/src/Handler/LogoutHandler.php deleted file mode 100644 index 473718a9..00000000 --- a/src/App/Account/Identity/src/Handler/LogoutHandler.php +++ /dev/null @@ -1,75 +0,0 @@ - []]], - tags: ['Account'] - )] - #[OA\RequestBody( - description: 'The refresh token that should be invalidated.', - required: true, - content: new OA\JsonContent( - properties: [ - new OA\Property( - property: 'refreshToken', - description: 'The full refresh token string', - type: 'string', - example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' - ), - ], - type: 'object' - ) - )] - #[OA\Response( - response: HTTP::STATUS_NO_CONTENT, - description: 'Logout successful. The refresh token has been deleted and the session is invalidated.', - content: [new OA\JsonContent(ref: HttpResponseMessage::class)] - )] - #[OA\Response( - response: HTTP::STATUS_BAD_REQUEST, - description: 'Bad Request. The refresh token is missing in the body or is malformed.', - content: [new OA\JsonContent(ref: HttpResponseMessage::class)] - )] - #[OA\Response( - response: HTTP::STATUS_UNAUTHORIZED, - description: 'Unauthorized. The access token is missing, expired, or the user could not be identified.', - content: [new OA\JsonContent(ref: HttpResponseMessage::class)] - )] - public function handle(ServerRequestInterface $request): ResponseInterface - { - $account = $request->getAttribute(AccountInterface::AUTHENTICATED); - $refreshToken = $request->getAttribute(RefreshToken::class); - - $this->accountService->logout($account, $refreshToken); - - $response = HttpResponseMessage::create(HTTP::STATUS_NO_CONTENT, IdentityStatusMessage::SUCCESS); - - return new JsonResponse($response, $response->statusCode); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Hydrator/Account/AccountAccessAuthHydrator.php b/src/App/Account/Identity/src/Infrastructure/Hydrator/Account/AccountAccessAuthHydrator.php deleted file mode 100644 index 4469bb98..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Hydrator/Account/AccountAccessAuthHydrator.php +++ /dev/null @@ -1,69 +0,0 @@ -hydrate($entity); - } - - return $collection; - } - - public function extract(AccountAccessAuthInterface $object): array - { - return [ - 'id' => $object->id, - 'accountId' => $object->accountId, - 'label' => $object->label, - 'refreshToken' => $object->refreshToken, - 'userAgent' => $object->userAgent, - 'clientIdentHash' => $object->clientIdentHash, - 'createdAt' => $object->createdAt->format(DateTimeFormat::DEFAULT->value), - ]; - } - - public function extractCollection(AccountAccessAuthCollectionInterface $collection): array - { - $data = []; - - foreach ($collection as $entity) { - $data[] = $this->extract($entity); - } - - return $data; - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Hydrator/Account/AccountActivationHydrator.php b/src/App/Account/Identity/src/Infrastructure/Hydrator/Account/AccountActivationHydrator.php deleted file mode 100644 index a6452fba..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Hydrator/Account/AccountActivationHydrator.php +++ /dev/null @@ -1,63 +0,0 @@ -uuid->fromString($data['token']), - createdAt: new DateTimeImmutable($data['createdAt']), - ); - } - - public function hydrateCollection(array $data): AccountActivationCollectionInterface - { - $collection = new AccountActivationCollection(); - - foreach ($data as $entity) { - $collection[] = $this->hydrate($entity); - } - - return $collection; - } - - public function extract(AccountActivationInterface $object): array - { - return [ - 'id' => $object->id, - 'email' => $object->email->toString(), - 'token' => $object->token->toString(), - 'createdAt' => $object->createdAt->format(DateTimeFormat::DEFAULT->value), - ]; - } - - public function extractCollection(AccountActivationCollectionInterface $collection): array - { - $data = []; - - foreach ($collection as $entity) { - $data[] = $this->extract($entity); - } - - return $data; - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Hydrator/Account/AccountHydrator.php b/src/App/Account/Identity/src/Infrastructure/Hydrator/Account/AccountHydrator.php deleted file mode 100644 index f8130288..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Hydrator/Account/AccountHydrator.php +++ /dev/null @@ -1,76 +0,0 @@ -uuid->fromString($data['uuid']), - name: $data['name'], - password: $data['password'], - email: new EmailType($data['email']), - registeredAt: new DateTimeImmutable($data['registeredAt']), - lastActionAt: new DateTimeImmutable($data['lastActionAt']), - ); - } - - /** - * @throws Exception - */ - public function hydrateCollection(array $data): AccountCollectionInterface - { - $collection = new AccountCollection(); - - foreach ($data as $entity) { - $collection[] = $this->hydrate($entity); - } - - return $collection; - } - - public function extract(AccountInterface $object): array - { - return [ - 'id' => $object->id, - 'uuid' => $object->uuid->toString(), - 'name' => $object->name, - 'password' => $object->password, - 'email' => $object->email->toString(), - 'registeredAt' => $object->registeredAt->format(DateTimeFormat::DEFAULT->value), - 'lastActionAt' => $object->lastActionAt->format(DateTimeFormat::DEFAULT->value), - ]; - } - - public function extractCollection(AccountCollectionInterface $collection): array - { - $data = []; - - foreach ($collection as $entity) { - $data[] = $this->extract($entity); - } - - return $data; - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Hydrator/Token/TokenHydrator.php b/src/App/Account/Identity/src/Infrastructure/Hydrator/Token/TokenHydrator.php deleted file mode 100644 index 233b3057..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Hydrator/Token/TokenHydrator.php +++ /dev/null @@ -1,65 +0,0 @@ -uuid->fromString($data['token']), - createdAt: new DateTimeImmutable($data['createdAt']), - ); - } - - public function hydrateCollection(array $data): TokenCollectionInterface - { - $collection = new TokenCollection(); - - foreach ($data as $entity) { - $collection[] = $this->hydrate($entity); - } - - return $collection; - } - - public function extract(TokenInterface $object): array - { - return [ - 'id' => $object->id, - 'accountId' => $object->accountId, - 'tokenType' => $object->tokenType->value, - 'token' => $object->token->toString(), - 'createdAt' => $object->createdAt->format(DateTimeFormat::DEFAULT->value), - ]; - } - - public function extractCollection(TokenCollectionInterface $collection): array - { - $data = []; - - foreach ($collection as $entity) { - $data[] = $this->extract($entity); - } - - return $data; - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Persistence/Repository/Account/AccountAccessAuthRepository.php b/src/App/Account/Identity/src/Infrastructure/Persistence/Repository/Account/AccountAccessAuthRepository.php deleted file mode 100644 index 53959e66..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Persistence/Repository/Account/AccountAccessAuthRepository.php +++ /dev/null @@ -1,71 +0,0 @@ -store->insert($accountAccessAuth); - } - - public function update(AccountAccessAuthInterface $accountAccessAuth): true - { - return $this->store->update($accountAccessAuth); - } - - public function deleteById(int $id): true - { - return $this->store->deleteById($id); - } - - public function findById(int $id): ?AccountAccessAuthInterface - { - return $this->store->findById($id); - } - - public function findByAccountId(int $accountId): AccountAccessAuthCollectionInterface - { - return $this->store->findByAccountId($accountId); - } - - public function findByAccountIdAndClientIdHash(int $accountId, string $clientHash): ?AccountAccessAuthInterface - { - return $this->store->findByAccountIdAndClientIdHash($accountId, $clientHash); - } - - public function findByLabel(string $label): AccountAccessAuthCollectionInterface - { - return $this->store->findByLabel($label); - } - - public function findByRefreshToken(string $refreshToken): ?AccountAccessAuthInterface - { - return $this->store->findByRefreshToken($refreshToken); - } - - public function findByUserAgent(string $userAgent): AccountAccessAuthCollectionInterface - { - return $this->store->findByUserAgent($userAgent); - } - - public function findByClientIdentHash(string $clientIdentHash): ?AccountAccessAuthInterface - { - return $this->store->findByClientIdentHash($clientIdentHash); - } - - public function findAll(): AccountAccessAuthCollectionInterface - { - return $this->store->findAll(); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Persistence/Repository/Account/AccountActivationRepository.php b/src/App/Account/Identity/src/Infrastructure/Persistence/Repository/Account/AccountActivationRepository.php deleted file mode 100644 index bf80c981..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Persistence/Repository/Account/AccountActivationRepository.php +++ /dev/null @@ -1,57 +0,0 @@ -store->insert($data); - } - - public function update(AccountActivationInterface $data): true - { - return $this->store->update($data); - } - - public function findById(int $id): ?AccountActivationInterface - { - return $this->store->findById($id); - } - - public function findEmail(EmailType $email): AccountActivationCollectionInterface - { - return $this->store->findByEmail($email); - } - - public function findByToken(string $token): ?AccountActivationInterface - { - return $this->store->findByToken($token); - } - - public function findAll(): AccountActivationCollectionInterface - { - return $this->store->findAll(); - } - - public function deleteById(int $id): true - { - return $this->store->deleteById($id); - } - - public function deleteByEmail(EmailType $email): true - { - return $this->store->deleteByEmail($email); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Persistence/Repository/Account/AccountRepository.php b/src/App/Account/Identity/src/Infrastructure/Persistence/Repository/Account/AccountRepository.php deleted file mode 100644 index b6597cec..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Persistence/Repository/Account/AccountRepository.php +++ /dev/null @@ -1,58 +0,0 @@ -store->insert($data); - } - - public function update(AccountInterface $data): true - { - return $this->store->update($data); - } - - public function deleteById(int $id): true - { - return $this->store->deleteById($id); - } - - public function findById(int $id): ?AccountInterface - { - return $this->store->findById($id); - } - - public function findByUuid(UuidInterface $uuid): ?AccountInterface - { - return $this->store->findByUuid($uuid); - } - - public function findByName(string $name): ?AccountInterface - { - return $this->store->findByName($name); - } - - public function findByEmail(EmailType $email): ?AccountInterface - { - return $this->store->findByEmail($email); - } - - public function findAll(): AccountCollectionInterface - { - return $this->store->findAll(); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Persistence/Repository/Token/TokenRepository.php b/src/App/Account/Identity/src/Infrastructure/Persistence/Repository/Token/TokenRepository.php deleted file mode 100644 index 4e7286ed..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Persistence/Repository/Token/TokenRepository.php +++ /dev/null @@ -1,56 +0,0 @@ -store->insert($data); - } - - public function update(TokenInterface $data): true - { - return $this->store->update($data); - } - - public function findById(int $id): ?TokenInterface - { - return $this->store->findById($id); - } - - public function findByAccountId(int $accountId): TokenCollectionInterface - { - return $this->store->findByAccountId($accountId); - } - - public function findByToken(string $token): ?TokenInterface - { - return $this->store->findByToken($token); - } - - public function findAll(): TokenCollectionInterface - { - return $this->store->findAll(); - } - - public function deleteById(int $id): true - { - return $this->store->deleteById($id); - } - - public function deleteByAccountId(int $accountId): true - { - return $this->store->deleteByAccountId($accountId); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Persistence/Table/Account/AccountAccessAuthTable.php b/src/App/Account/Identity/src/Infrastructure/Persistence/Table/Account/AccountAccessAuthTable.php deleted file mode 100644 index 95af4066..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Persistence/Table/Account/AccountAccessAuthTable.php +++ /dev/null @@ -1,144 +0,0 @@ -hydrator->extract($data); - - unset($value['id']); - - try { - $lastInsertId = $this->query->insertInto($this->table, $value)->execute(); - } catch (Exception | PDOException $e) { - return throw new DuplicateEntryException($this->getTableName(), $data->id); - } - - return true; - } - - public function update(AccountAccessAuthInterface $data): true - { - $value = $this->hydrator->extract($data); - - $result = $this->query->update($this->table, $value, $data->id)->execute(); - - if ($result === false) { - throw new InvalidArgumentException( - sprintf('Unknown Error while updating %s with id: %s', $this->getTableName(), $data->id) - ); - } - - return true; - } - - public function findById(int $id): ?AccountAccessAuthInterface - { - $result = $this->query->from($this->table) - ->where('id', $id) - ->fetch(); - - return is_array($result) ? $this->hydrator->hydrate($result) : null; - } - - public function findByAccountId(int $accountId): AccountAccessAuthCollectionInterface - { - $result = $this->query->from($this->table) - ->where('userId', $accountId) - ->fetchAll(); - - return is_array($result) - ? $this->hydrator->hydrateCollection($result) - : $this->hydrator->hydrateCollection( - [] - ); - } - - public function findByAccountIdAndClientIdHash(int $accountId, string $clientHash): ?AccountAccessAuthInterface - { - $result = $this->query->from($this->table) - ->where('accountId', $accountId) - ->where('clientIdentHash', $clientHash) - ->fetch(); - - return is_array($result) ? $this->hydrator->hydrate($result) : null; - } - - public function findByLabel(string $label): AccountAccessAuthCollectionInterface - { - $result = $this->query->from($this->table) - ->where('label', $label) - ->fetchAll(); - - return is_array($result) - ? $this->hydrator->hydrateCollection($result) - : $this->hydrator->hydrateCollection( - [] - ); - } - - public function findByRefreshToken(string $refreshToken): ?AccountAccessAuthInterface - { - $result = $this->query->from($this->table) - ->where('refreshToken', $refreshToken) - ->fetch(); - - return is_array($result) ? $this->hydrator->hydrate($result) : null; - } - - public function findByUserAgent(string $userAgent): AccountAccessAuthCollectionInterface - { - $result = $this->query->from($this->table) - ->where('userAgent', $userAgent) - ->fetchAll(); - - return is_array($result) - ? $this->hydrator->hydrateCollection($result) - : $this->hydrator->hydrateCollection( - [] - ); - } - - public function findByClientIdentHash(string $clientIdentHash): ?AccountAccessAuthInterface - { - $result = $this->query->from($this->table) - ->where('clientIdentHash', $clientIdentHash) - ->fetch(); - - return is_array($result) ? $this->hydrator->hydrate($result) : null; - } - - public function findAll(): AccountAccessAuthCollectionInterface - { - $result = $this->query->from($this->table)->fetchAll(); - - return is_array($result) - ? $this->hydrator->hydrateCollection($result) - : $this->hydrator->hydrateCollection( - [] - ); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Persistence/Table/Account/AccountActivationTable.php b/src/App/Account/Identity/src/Infrastructure/Persistence/Table/Account/AccountActivationTable.php deleted file mode 100644 index 389e109e..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Persistence/Table/Account/AccountActivationTable.php +++ /dev/null @@ -1,106 +0,0 @@ -hydrator->extract($data); - - unset($value['id']); - - try { - $this->query->insertInto($this->table, $value)->execute(); - } catch (PDOException $e) { - throw new DuplicateEntryException($this->getTableName(), $data->id); - } - - return true; - } - - public function update(AccountActivationInterface $data): true - { - $value = $this->hydrator->extract($data); - - $result = $this->query->update($this->table, $value, $data->id)->execute(); - - if ($result === false) { - throw new InvalidArgumentException( - sprintf('Unknown Error while updating %s with id: %s', $this->getTableName(), $data->id) - ); - } - - return true; - } - - public function findById(int $id): ?AccountActivationInterface - { - $result = $this->query->from($this->table) - ->where('id', $id) - ->fetch(); - - return is_array($result) ? $this->hydrator->hydrate($result) : null; - } - - public function findByEmail(EmailType $email): AccountActivationCollectionInterface - { - $result = $this->query->from($this->table) - ->where('email', $email->toString()) - ->fetchAll(); - - return is_array($result) ? $this->hydrator->hydrateCollection($result) : $this->hydrator->hydrateCollection([]); - } - - public function findByToken(string $token): ?AccountActivationInterface - { - $result = $this->query->from($this->table) - ->where('token', $token) - ->fetch(); - - return is_array($result) ? $this->hydrator->hydrate($result) : null; - } - - public function findAll(): AccountActivationCollectionInterface - { - $result = $this->query->from($this->table)->fetchAll(); - - return is_array($result) ? $this->hydrator->hydrateCollection($result) : $this->hydrator->hydrateCollection([]); - } - - public function deleteByEmail(EmailType $email): true - { - $result = $this->query->delete($this->table) - ->where('email', $email->toString()) - ->execute(); - - if ($result === false) { - throw new InvalidArgumentException( - sprintf('Failed to delete %s table with email: `%s`', $this->getTableName(), $email->toString()) - ); - } - - return true; - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Persistence/Table/Account/AccountTable.php b/src/App/Account/Identity/src/Infrastructure/Persistence/Table/Account/AccountTable.php deleted file mode 100644 index 44ef29d4..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Persistence/Table/Account/AccountTable.php +++ /dev/null @@ -1,107 +0,0 @@ -hydrator->extract($data); - - unset($value['id']); - - - try { - $lastInsertId = $this->query->insertInto($this->table, $value)->execute(); - } catch (PDOException $e) { - throw new DuplicateEntryException($this->getTableName(), $data->id); - } - - return (int)$lastInsertId; - } - - public function update(AccountInterface $data): true - { - $value = $this->hydrator->extract($data); - - $result = $this->query->update($this->table, $value, $data->id)->execute(); - - if ($result === false) { - throw new InvalidArgumentException( - sprintf('Unknown Error while updating %s with id: %s', $this->getTableName(), $data->id) - ); - } - - return true; - } - - public function findById(int $id): ?AccountInterface - { - $result = $this->query->from($this->table) - ->where('id', $id) - ->fetch(); - - return is_array($result) ? $this->hydrator->hydrate($result) : null; - } - - public function findByUuid(UuidInterface $uuid): ?AccountInterface - { - $result = $this->query->from($this->table) - ->where('uuid', $uuid->toString()) - ->fetch(); - - return is_array($result) ? $this->hydrator->hydrate($result) : null; - } - - public function findByName(string $name): ?AccountInterface - { - $result = $this->query->from($this->table) - ->where('name', $name) - ->fetch(); - - return is_array($result) ? $this->hydrator->hydrate($result) : null; - } - - public function findByEmail(EmailType $email): ?AccountInterface - { - $result = $this->query->from($this->table) - ->where('email', $email->toString()) - ->fetch(); - - return is_array($result) ? $this->hydrator->hydrate($result) : null; - } - - public function findAll(): AccountCollectionInterface - { - $result = $this->query->from($this->table)->fetchAll(); - - return is_array($result) ? $this->hydrator->hydrateCollection($result) : $this->hydrator->hydrateCollection([]); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Persistence/Table/Token/TokenTable.php b/src/App/Account/Identity/src/Infrastructure/Persistence/Table/Token/TokenTable.php deleted file mode 100644 index 739e341b..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Persistence/Table/Token/TokenTable.php +++ /dev/null @@ -1,105 +0,0 @@ -hydrator->extract($data); - - unset($value['id']); - - try { - $this->query->insertInto($this->table, $value)->execute(); - } catch (PDOException $e) { - throw new DuplicateEntryException($this->getTableName(), $data->id); - } - - return true; - } - - public function update(TokenInterface $data): true - { - $value = $this->hydrator->extract($data); - - $result = $this->query->update($this->table, $value, $data->id)->execute(); - - if ($result === false) { - throw new InvalidArgumentException( - sprintf('Unknown Error while updating %s with id: %s', $this->getTableName(), $data->id) - ); - } - - return true; - } - - public function findById(int $id): ?TokenInterface - { - $result = $this->query->from($this->table) - ->where('id', $id) - ->fetch(); - - return is_array($result) ? $this->hydrator->hydrate($result) : null; - } - - public function findByAccountId(int $accountId): TokenCollectionInterface - { - $result = $this->query->from($this->table) - ->where('accountId', $accountId) - ->fetchAll(); - - return is_array($result) ? $this->hydrator->hydrateCollection($result) : $this->hydrator->hydrateCollection([]); - } - - public function findByToken(string $token): ?TokenInterface - { - $result = $this->query->from($this->table) - ->where('token', $token) - ->fetch(); - - return is_array($result) ? $this->hydrator->hydrate($result) : null; - } - - public function findAll(): TokenCollectionInterface - { - $result = $this->query->from($this->table)->fetchAll(); - - return is_array($result) ? $this->hydrator->hydrateCollection($result) : $this->hydrator->hydrateCollection([]); - } - - public function deleteByAccountId(int $accountId): true - { - $result = $this->query->delete($this->table) - ->where('accountId', $accountId) - ->execute(); - - if ($result === false) { - throw new InvalidArgumentException( - sprintf('Failed to delete %s table with accountId: `%s`', $this->getTableName(), $accountId) - ); - } - - return true; - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Service/Account/AccountAuthenticationService.php b/src/App/Account/Identity/src/Infrastructure/Service/Account/AccountAuthenticationService.php deleted file mode 100644 index 8476ef19..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Service/Account/AccountAuthenticationService.php +++ /dev/null @@ -1,78 +0,0 @@ -accountRepository->findByEmail(EmailType::fromString($auth->email)); - if (!($account instanceof AccountInterface)) { - throw new AccountNotFoundException(email: $auth->email); - } - - if (!$this->authenticationService->isPasswordMatch($auth->password, $account->password)) { - throw new PasswordMismatchException(email: $auth->email); - } - - $refreshToken = $this->refreshTokenService->generate($clientId); - $accessToken = $this->accessTokenService->generate($account->uuid); - - $accountAccessAuth = new AccountAccessAuth( - null, - $account->id, - 'default', - $refreshToken->refreshToken, - $clientId->clientIdentificationData->userAgent, - $clientId->identificationHash, - new DateTimeImmutable() - ); - - try { - $this->accountAccessAuthRepository->insert($accountAccessAuth); - } catch (DuplicateEntryException $e) { - throw new DuplicateAuthException( - account: $account->name, - accountId: $account->id, - clientId: $clientId->identificationHash, - errorMessage: $e->getMessage(), - ); - } - - $this->accountService->updateLastAction($account); - - return AuthenticationResponse::from($accessToken, $refreshToken); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Service/Account/AccountCreatorService.php b/src/App/Account/Identity/src/Infrastructure/Service/Account/AccountCreatorService.php deleted file mode 100644 index 06639321..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Service/Account/AccountCreatorService.php +++ /dev/null @@ -1,92 +0,0 @@ - $activationToken, - ] - ); - } - - $persistActivationToken = $this->accountActivationRepository->findByToken($activationToken); - - if (!$persistActivationToken instanceof AccountActivationInterface) { - throw new HttpInvalidArgumentException( - IdentityLogMessage::ACTIVATION_TOKEN_MISSING, - IdentityStatusMessage::TOKEN_INVALID, - [ - 'Invalid activation token:' => $activationToken, - ] - ); - } - - $account = new Account( - id: null, - uuid: $this->uuid->uuid7(), - name: $accountRegistration->accountName, - password: password_hash($accountRegistration->password, PASSWORD_BCRYPT), - email: $persistActivationToken->email, - registeredAt: new DateTimeImmutable(), - lastActionAt: new DateTimeImmutable() - ); - - try { - $accountId = $this->accountRepository->insert($account); - } catch (DuplicateEntryException $e) { - throw new HttpDuplicateEntryException( - IdentityLogMessage::ACCOUNT_ALREADY_EXISTS, - IdentityStatusMessage::INVALID_DATA, - [ - 'E-Mail' => $account->email->toString(), - 'Exception Message:' => $e->getMessage(), - ] - ); - } - - try { - $this->accountActivationRepository->deleteById($persistActivationToken->id); - } catch (InvalidArgumentException $exception) { - throw new HttpInvalidArgumentException( - IdentityLogMessage::ACCOUNT_UPDATE_UNKNOWN_ERROR, - IdentityStatusMessage::UNKNOWN_ERROR, - [ - 'account' => $account->name, - 'exception' => $exception, - ] - ); - } - - $account = $this->accountRepository->findById($accountId); - return AccountDTO::createFromAccount($account); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Service/Account/AccountRegisterService.php b/src/App/Account/Identity/src/Infrastructure/Service/Account/AccountRegisterService.php deleted file mode 100644 index a449a79f..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Service/Account/AccountRegisterService.php +++ /dev/null @@ -1,41 +0,0 @@ -accountService->isEmailAvailable($email)) { - $this->accountService->sendTokenForPasswordChange($email); - throw new DuplicateEmailException($email->toString()); - } - - $activation = new AccountActivation( - id: null, - email: $email, - token: $this->uuid->uuid7(), - createdAt: new DateTimeImmutable() - ); - - $this->accountActivationRepository->insert($activation); - - $this->activationTokenService->sendEmail($activation); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Service/Account/AccountRegisterServiceInterface.php b/src/App/Account/Identity/src/Infrastructure/Service/Account/AccountRegisterServiceInterface.php deleted file mode 100644 index d236f60b..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Service/Account/AccountRegisterServiceInterface.php +++ /dev/null @@ -1,10 +0,0 @@ -accountRepository->findByEmail($email); - $token = $this->createPasswordChangeTokenForUserId($account->id); - $this->tokenRepository->insert($token); - $this->tokenService->sendEmail($email, $token); - } - - public function isEmailAvailable(EmailType $email): bool - { - $account = $this->accountRepository->findByEmail($email); - - return $account === null; - } - - public function createPasswordChangeTokenForUserId(int $userId): TokenInterface - { - return new Token( - id: null, - accountId: $userId, - tokenType: TokenType::EMail, - token: $this->uuid->uuid7(), - createdAt: new DateTimeImmutable() - ); - } - - public function cryptPassword(string $password): string - { - return password_hash($password, PASSWORD_BCRYPT); - } - - public function updateLastAction(AccountInterface $account): void - { - $this->accountRepository->update( - $account->with(lastActionAt: new DateTimeImmutable()) - ); - } - - public function logout(AccountInterface $account, RefreshToken $refreshToken): void - { - $accountAccessAuth = $this->authRepository->findByRefreshToken($refreshToken->refreshToken); - - if (!($accountAccessAuth instanceof AccountAccessAuthInterface)) { - throw new HttpUnauthorizedException( - IdentityLogMessage::LOGOUT_REFRESH_TOKEN_MISMATCH, - IdentityStatusMessage::UNAUTHORIZED_ACCESS, - [ - 'accountId' => $account->id, - 'refreshToken' => $refreshToken->refreshToken, - ], - Level::Warning - ); - } - - if ($account->id !== $accountAccessAuth->accountId) { - throw new HttpUnauthorizedException( - IdentityLogMessage::LOGOUT_REFRESH_TOKEN_MISMATCH, - IdentityStatusMessage::UNAUTHORIZED_ACCESS, - [ - 'accountId' => $account->id, - 'refreshToken' => $refreshToken->refreshToken, - ], - Level::Warning - ); - } - - $this->authRepository->deleteById($accountAccessAuth->id); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Service/Account/PasswordChangeService.php b/src/App/Account/Identity/src/Infrastructure/Service/Account/PasswordChangeService.php deleted file mode 100644 index 7f876c29..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Service/Account/PasswordChangeService.php +++ /dev/null @@ -1,60 +0,0 @@ -token === null) { - $this->errorResponse(IdentityLogMessage::PASSWORD_CHANGE_TOKEN_MISSING, $token->token); - } - - $persistedToken = $this->tokenRepository->findByToken($token->token); - - if (!($persistedToken instanceof TokenInterface) || $persistedToken->tokenType !== TokenType::EMail) { - $this->errorResponse(IdentityLogMessage::PASSWORD_CHANGE_TOKEN_INVALID, $token->token); - } - - $account = $this->accountRepository->findById($persistedToken->accountId); - - if (!($account instanceof Account)) { - $this->errorResponse(IdentityLogMessage::PASSWORD_CHANGE_TOKEN_ACCOUNT_NOT_FOUND, $token->token); - } - - $hashedPassword = $this->accountService->cryptPassword($password->password); - $account = $account->with(password: $hashedPassword); - - $this->accountRepository->update($account); - $this->tokenRepository->deleteById($persistedToken->id); - } - - private function errorResponse(string $logMessage, ?string $token): void - { - throw new HttpInvalidArgumentException( - $logMessage, - IdentityStatusMessage::TOKEN_INVALID, - [ - 'Token:' => $token, - ] - ); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Service/Account/PasswordService.php b/src/App/Account/Identity/src/Infrastructure/Service/Account/PasswordService.php deleted file mode 100644 index 6fce71fa..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Service/Account/PasswordService.php +++ /dev/null @@ -1,33 +0,0 @@ -accountService->isEmailAvailable($email)) { - throw new HttpHandledInvalidArgumentAsSuccessException( - IdentityLogMessage::PASSWORD_REQUEST_MISSING_ACCOUNT, - IdentityStatusMessage::INVALID_DATA, - [ - 'email:' => $email->toString(), - ], - Level::Warning - ); - } - - $this->accountService->sendTokenForPasswordChange($email); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Service/Authentication/AuthenticationService.php b/src/App/Account/Identity/src/Infrastructure/Service/Authentication/AuthenticationService.php deleted file mode 100644 index 71adfa93..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Service/Authentication/AuthenticationService.php +++ /dev/null @@ -1,11 +0,0 @@ -getIdentificationHash($clientIdentificationData); - } - - private function getIdentificationHash(ClientIdentificationData $clientIdentificationData): string - { - return hash('sha512', serialize($clientIdentificationData)); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Service/Token/AccessTokenService.php b/src/App/Account/Identity/src/Infrastructure/Service/Token/AccessTokenService.php deleted file mode 100644 index e2dd2c98..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Service/Token/AccessTokenService.php +++ /dev/null @@ -1,37 +0,0 @@ - $this->config->iss, - 'aud' => $this->config->aud, - 'iat' => $now, - 'exp' => $now + $this->config->duration, - 'uuid' => $uuid->toString(), - ]; - - $token = JWT::encode($payload, $this->config->key, $this->config->algorithmus); - return AccessToken::fromString($token); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Service/Token/AccessTokenServiceFactory.php b/src/App/Account/Identity/src/Infrastructure/Service/Token/AccessTokenServiceFactory.php deleted file mode 100644 index 31d43e03..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Service/Token/AccessTokenServiceFactory.php +++ /dev/null @@ -1,17 +0,0 @@ -get('config')['jwt_token']['access']; - $jwtTokenConfig = JwtTokenConfig::createFromArray($jwtTokenConfig); - - return new AccessTokenService($jwtTokenConfig); - } -} diff --git a/src/App/Account/Identity/src/Infrastructure/Service/Token/ActivationTokenService.php b/src/App/Account/Identity/src/Infrastructure/Service/Token/ActivationTokenService.php deleted file mode 100644 index 461e7c9a..00000000 --- a/src/App/Account/Identity/src/Infrastructure/Service/Token/ActivationTokenService.php +++ /dev/null @@ -1,60 +0,0 @@ -projectUri, - $activation->token->toString() - ); - - $html = sprintf( - '
Hallo!
-Vielen Dank für Ihr Interesse an ownHackathon.
-Sie haben eine Registrierung mit dieser E-Mail-Adresse angefordert. - Um den Vorgang abzuschließen und Ihr Benutzerkonto zu erstellen, - bestätigen Sie bitte Ihre E-Mail-Adresse über den folgenden Link:
- -Hinweis: Erst wenn Sie diesen Link anklicken, wird Ihr Account verbindlich angelegt. - Der Link ist nur für begrenzte Zeit gültig.
-Falls Sie diese Anfrage nicht selbst gestellt haben, können Sie diese Nachricht einfach ignorieren. - Es wird in diesem Fall kein Konto erstellt und Ihre E-Mail-Adresse wird nicht dauerhaft bei uns gespeichert.
-Mit freundlichen Grüßen,
- Ihr Team von ownHackathon
Hallo!
-Vielen Dank für Ihr Interesse an unserem Service.
-Sie haben versucht, sich mit dieser E-Mail-Adresse neu zu registrieren oder wollen Ihr Passwort zurücksetzen. - Da unter dieser Adresse bereits ein aktives Konto bei uns besteht, - senden wir Ihnen hiermit einen Link, mit dem Sie Ihr Passwort zurücksetzen können, - falls Sie den Zugriff auf Ihren Account wiederherstellen möchten.
-Klicken Sie auf den folgenden Link, um ein neues Passwort festzulegen:
- Passwort resetten
Falls Sie keine Registrierung oder Passwortänderung veranlasst haben, - können Sie diese Nachricht einfach ignorieren. Ihr Account bleibt weiterhin mit - Ihrem bestehenden Passwort geschützt.
-Mit freundlichen Grüßen,
- Ihr Team von ownHackathon