44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
use App\Auth\BcryptPasswordHasher;
|
|
use App\Auth\Clock;
|
|
use App\Auth\PasswordHasher;
|
|
use App\Auth\PostgresSessionRepository;
|
|
use App\Auth\RandomTokenGenerator;
|
|
use App\Auth\SessionRepository;
|
|
use App\Auth\SystemClock;
|
|
use App\Auth\TokenGenerator;
|
|
use App\Auth\UseCases\AuthenticateUser\AuthenticateUser;
|
|
use App\Auth\UseCases\CreateSession\CreateSession;
|
|
use App\Auth\UseCases\Logout\Logout;
|
|
use App\Controllers\AuthController;
|
|
use App\Middleware\AuthMiddleware;
|
|
use App\User\PostgresUserRepository;
|
|
use App\User\UserRepository;
|
|
use DI\ContainerBuilder;
|
|
|
|
$builder = new ContainerBuilder();
|
|
|
|
$builder->addDefinitions([
|
|
|
|
// Services
|
|
PasswordHasher::class => DI\create(BcryptPasswordHasher::class),
|
|
TokenGenerator::class => DI\create(RandomTokenGenerator::class),
|
|
Clock::class => DI\create(SystemClock::class),
|
|
|
|
// Repositories
|
|
UserRepository::class => DI\create(PostgresUserRepository::class),
|
|
SessionRepository::class => DI\create(PostgresSessionRepository::class),
|
|
|
|
// Use cases
|
|
AuthenticateUser::class => DI\autowire(),
|
|
CreateSession::class => DI\autowire(),
|
|
Logout::class => DI\autowire(),
|
|
|
|
// HTTP layer
|
|
AuthController::class => DI\autowire(),
|
|
AuthMiddleware::class => DI\autowire(),
|
|
|
|
]);
|
|
|
|
return $builder->build();
|