-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,090 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Security Pack | ||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- main | ||
release: | ||
types: [ created ] | ||
schedule: | ||
- | ||
cron: "0 1 * * 6" # Run at 1am every Saturday | ||
workflow_dispatch: | ||
|
||
permissions: | ||
actions: write | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
cqrs-pack: | ||
runs-on: ubuntu-latest | ||
|
||
name: "Tests (PHP ${{ matrix.php }})" | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: ["8.3"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: "Setup PHP" | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: "${{ matrix.php }}" | ||
ini-values: date.timezone=Europe/Warsaw | ||
extensions: intl, gd, mysql, pdo_mysql, :xdebug | ||
tools: symfony | ||
coverage: none | ||
|
||
- name: "Get Composer cache directory" | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
- name: "Setup cache" | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ github.run_id }}-${{ runner.os }}-${{ hashFiles('composer.json') }}-symfony-${{ matrix.symfony }} | ||
|
||
- name: "Create test application" | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Your Name" | ||
(cd tests/Security && make create-test-application) | ||
id: end-of-setup | ||
|
||
- name: "Lint container" | ||
run: (cd tests/Security/app && bin/console lint:container) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"copy-from-recipe": { | ||
"src/": "%SRC_DIR%/" | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...pplication-meta/0.1/src/Security/Application/AdminUser/Command/CreateAdminUserCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Application\AdminUser\Command; | ||
|
||
use App\Security\Domain\ValueObject\User\AdminUserEmail; | ||
use App\Security\Domain\ValueObject\User\AdminUserPassword; | ||
use App\Shared\Application\Command\CommandInterface; | ||
|
||
final class CreateAdminUserCommand implements CommandInterface | ||
{ | ||
public function __construct( | ||
public AdminUserEmail $email, | ||
public AdminUserPassword $password, | ||
) { | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...ion-meta/0.1/src/Security/Application/AdminUser/Command/CreateAdminUserCommandHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Application\AdminUser\Command; | ||
|
||
use App\Security\Domain\Model\User\AdminUser; | ||
use App\Security\Domain\Repository\AdminUserRepositoryInterface; | ||
use App\Security\Infrastructure\Identity\AdminUserIdGenerator; | ||
use App\Shared\Application\Command\CommandHandlerInterface; | ||
|
||
final readonly class CreateAdminUserCommandHandler implements CommandHandlerInterface | ||
{ | ||
public function __construct( | ||
private AdminUserIdGenerator $generator, | ||
private AdminUserRepositoryInterface $adminUserRepository, | ||
) { | ||
} | ||
|
||
public function __invoke(CreateAdminUserCommand $command): AdminUser | ||
{ | ||
$adminUser = new AdminUser( | ||
$this->generator->nextIdentity(), | ||
$command->email, | ||
$command->password, | ||
); | ||
|
||
$this->adminUserRepository->save($adminUser); | ||
|
||
return $adminUser; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...pplication-meta/0.1/src/Security/Application/AdminUser/Command/DeleteAdminUserCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Application\AdminUser\Command; | ||
|
||
use App\Shared\Application\Command\CommandInterface; | ||
|
||
final class DeleteAdminUserCommand implements CommandInterface | ||
{ | ||
public function __construct( | ||
public string $id, | ||
) { | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ion-meta/0.1/src/Security/Application/AdminUser/Command/DeleteAdminUserCommandHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Application\AdminUser\Command; | ||
|
||
use App\Security\Domain\Repository\AdminUserRepositoryInterface; | ||
use App\Shared\Application\Command\CommandHandlerInterface; | ||
|
||
final class DeleteAdminUserCommandHandler implements CommandHandlerInterface | ||
{ | ||
public function __construct( | ||
private AdminUserRepositoryInterface $adminUserRepository | ||
) { | ||
} | ||
|
||
public function __invoke(DeleteAdminUserCommand $command): void | ||
{ | ||
if (null === $boardGame = $this->adminUserRepository->ofId($command->id)) { | ||
return; | ||
} | ||
|
||
$this->adminUserRepository->remove($boardGame); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...pplication-meta/0.1/src/Security/Application/AdminUser/Command/UpdateAdminUserCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Application\AdminUser\Command; | ||
|
||
use App\Security\Domain\ValueObject\User\AdminUserEmail; | ||
use App\Security\Domain\ValueObject\User\AdminUserPassword; | ||
use App\Shared\Application\Command\CommandInterface; | ||
|
||
final readonly class UpdateAdminUserCommand implements CommandInterface | ||
{ | ||
public function __construct( | ||
public string $id, | ||
public AdminUserEmail $email, | ||
public AdminUserPassword|null $password, | ||
) { | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ion-meta/0.1/src/Security/Application/AdminUser/Command/UpdateAdminUserCommandHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Application\AdminUser\Command; | ||
|
||
use App\Security\Domain\Model\User\AdminUser; | ||
use App\Security\Domain\Repository\AdminUserRepositoryInterface; | ||
use App\Security\Domain\ValueObject\User\AdminUserId; | ||
use App\Shared\Application\Command\CommandHandlerInterface; | ||
|
||
final readonly class UpdateAdminUserCommandHandler implements CommandHandlerInterface | ||
{ | ||
public function __construct( | ||
private AdminUserRepositoryInterface $adminUserRepository, | ||
) { | ||
} | ||
|
||
public function __invoke(UpdateAdminUserCommand $command): AdminUser | ||
{ | ||
$adminUser = new AdminUser( | ||
new AdminUserId($command->id), | ||
$command->email, | ||
$command->password, | ||
); | ||
|
||
$this->adminUserRepository->save($adminUser); | ||
|
||
return $adminUser; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...rity-application-meta/0.1/src/Security/Application/AdminUser/Query/FindAdminUserQuery.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Application\AdminUser\Query; | ||
|
||
use App\Shared\Application\Query\QueryInterface; | ||
|
||
class FindAdminUserQuery implements QueryInterface | ||
{ | ||
public function __construct( | ||
public string $id, | ||
) { | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...plication-meta/0.1/src/Security/Application/AdminUser/Query/FindAdminUserQueryHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Application\AdminUser\Query; | ||
|
||
use App\Security\Domain\Model\User\AdminUser; | ||
use App\Security\Domain\Repository\AdminUserRepositoryInterface; | ||
use App\Shared\Application\Query\QueryHandlerInterface; | ||
|
||
final class FindAdminUserQueryHandler implements QueryHandlerInterface | ||
{ | ||
public function __construct( | ||
private AdminUserRepositoryInterface $repository | ||
) { | ||
} | ||
|
||
public function __invoke(FindAdminUserQuery $query): AdminUser|null | ||
{ | ||
return $this->repository->ofId($query->id); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...ity-application-meta/0.1/src/Security/Application/AdminUser/Query/FindAdminUsersQuery.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Application\AdminUser\Query; | ||
|
||
use App\Shared\Application\Query\QueryInterface; | ||
|
||
final readonly class FindAdminUsersQuery implements QueryInterface | ||
{ | ||
public function __construct( | ||
public int|null $page = null, | ||
public int|null $itemsPerPage = null, | ||
public bool|null $emailSortingAsc = null, | ||
public bool|null $emailSortingDesc = null, | ||
public string|null $searchQuery = null, | ||
) { | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...lication-meta/0.1/src/Security/Application/AdminUser/Query/FindAdminUsersQueryHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Application\AdminUser\Query; | ||
|
||
use App\Security\Domain\Repository\AdminUserRepositoryInterface; | ||
use App\Shared\Application\Query\QueryHandlerInterface; | ||
|
||
final readonly class FindAdminUsersQueryHandler implements QueryHandlerInterface | ||
{ | ||
public function __construct( | ||
private AdminUserRepositoryInterface $adminUserRepository, | ||
) { | ||
} | ||
|
||
public function __invoke(FindAdminUsersQuery $query): AdminUserRepositoryInterface | ||
{ | ||
$adminUserRepository = $this->adminUserRepository; | ||
|
||
if (null !== $query->page && null !== $query->itemsPerPage) { | ||
$adminUserRepository = $adminUserRepository->withPagination($query->page, $query->itemsPerPage); | ||
} | ||
|
||
if ($query->emailSortingAsc) { | ||
$adminUserRepository = $adminUserRepository->withAscendingEmailSorting(); | ||
} | ||
|
||
if ($query->emailSortingDesc) { | ||
$adminUserRepository = $adminUserRepository->withDescendingEmailSorting(); | ||
} | ||
|
||
if (null !== $query->searchQuery) { | ||
$adminUserRepository = $adminUserRepository->withSearchQuery($query->searchQuery); | ||
} | ||
|
||
return $adminUserRepository; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"copy-from-recipe": { | ||
"src/": "%SRC_DIR%/" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
monofony/security-domain-meta/0.1/src/Security/Domain/Model/User/AdminUser.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Domain\Model\User; | ||
|
||
use App\Security\Domain\ValueObject\User\AdminUserEmail; | ||
use App\Security\Domain\ValueObject\User\AdminUserId; | ||
use App\Security\Domain\ValueObject\User\AdminUserPassword; | ||
|
||
final readonly class AdminUser | ||
{ | ||
public function __construct( | ||
public AdminUserId $id, | ||
public AdminUserEmail $email, | ||
public AdminUserPassword|null $password = null, | ||
) { | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
.../security-domain-meta/0.1/src/Security/Domain/Repository/AdminUserRepositoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Domain\Repository; | ||
|
||
use App\Security\Domain\Model\User\AdminUser; | ||
use App\Shared\Domain\Repository\RepositoryInterface; | ||
|
||
/** | ||
* @extends RepositoryInterface<AdminUser> | ||
*/ | ||
interface AdminUserRepositoryInterface extends RepositoryInterface | ||
{ | ||
public function save(AdminUser $adminUser): void; | ||
|
||
public function remove(AdminUser $adminUser): void; | ||
|
||
public function ofId(string $id): AdminUser|null; | ||
|
||
public function withAscendingEmailSorting(): static; | ||
|
||
public function withDescendingEmailSorting(): static; | ||
|
||
public function withSearchQuery(string $query): static; | ||
} |
13 changes: 13 additions & 0 deletions
13
monofony/security-domain-meta/0.1/src/Security/Domain/ValueObject/User/AdminUserEmail.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Domain\ValueObject\User; | ||
|
||
final readonly class AdminUserEmail | ||
{ | ||
public function __construct( | ||
public string $value, | ||
) { | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
monofony/security-domain-meta/0.1/src/Security/Domain/ValueObject/User/AdminUserId.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Domain\ValueObject\User; | ||
|
||
final readonly class AdminUserId | ||
{ | ||
public function __construct( | ||
public string $value, | ||
) { | ||
} | ||
} |
Oops, something went wrong.