2021-03-01 16:01:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use function DI\autowire, DI\create, DI\get;
|
|
|
|
|
|
|
|
use %NAMESPACE%\Entity;
|
|
|
|
|
2022-03-15 13:48:50 +00:00
|
|
|
use Psr\Http\Message\ServerRequestInterface;
|
|
|
|
|
2021-03-01 16:01:27 +00:00
|
|
|
use Ulmus\Entity\Field\Datetime,
|
|
|
|
Ulmus\User\Lib\Authenticate;
|
|
|
|
|
|
|
|
use Storage\{ Session, Cookie };
|
|
|
|
|
|
|
|
use Laminas\Diactoros\Response\{ RedirectResponse, HtmlResponse };
|
|
|
|
|
|
|
|
use Notes\Security\SecurityHandler;
|
|
|
|
|
|
|
|
use Picea\Picea;
|
|
|
|
|
|
|
|
use TheBugs\Email\{ EmailConfiguration, MailerInterface, SwiftMailer };
|
|
|
|
|
2022-03-15 13:48:50 +00:00
|
|
|
use Taxus\{ Taxus, PermissionGrantInterface };
|
2021-10-22 13:39:22 +00:00
|
|
|
|
2021-03-01 16:01:27 +00:00
|
|
|
return [
|
|
|
|
Entity\User::class => autowire(Entity\User::class),
|
|
|
|
|
|
|
|
Authenticate::class => create(Authenticate::class)->constructor(get(Session::class), get(Cookie::class), get('authentication.method')),
|
|
|
|
|
|
|
|
SecurityHandler::class => create(SecurityHandler::class)->constructor(function() {
|
2022-03-15 13:48:50 +00:00
|
|
|
return new RedirectResponse(getenv("URL_BASE")."/login");
|
2021-10-22 13:39:22 +00:00
|
|
|
}, get('authentication.unauthorize'), get(Taxus::class)),
|
2021-03-01 16:01:27 +00:00
|
|
|
|
2023-10-18 00:10:42 +00:00
|
|
|
'authentication.method' => null,
|
|
|
|
|
2021-03-01 16:01:27 +00:00
|
|
|
'authentication.error' => function($c, Picea $picea) {
|
|
|
|
return function($message) use ($picea) {
|
|
|
|
return new HtmlResponse($picea->renderHtml('lean/error/500', [
|
|
|
|
'title' => "",
|
|
|
|
'subtitle' => "",
|
|
|
|
'message' => $message,
|
|
|
|
]));
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2021-08-27 18:06:15 +00:00
|
|
|
'authentication.unauthorize' => function($c, Picea $picea) {
|
|
|
|
return function($message) use ($picea) {
|
|
|
|
return new HtmlResponse($picea->renderHtml('lean/error/401', [
|
|
|
|
'title' => "",
|
|
|
|
'subtitle' => "",
|
|
|
|
'message' => $message,
|
|
|
|
]));
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2021-03-01 16:01:27 +00:00
|
|
|
EmailConfiguration::class => function($c) {
|
|
|
|
$email = new EmailConfiguration( EmailConfiguration::AUTH_TYPE_SMTP );
|
2023-05-31 15:54:06 +00:00
|
|
|
$email->smtpHost = getenv('SMTP_HOSTNAME');
|
2021-03-01 16:01:27 +00:00
|
|
|
$email->smtpPort = getenv('SMTP_PORT');
|
|
|
|
$email->smtpUsername = getenv('SMTP_USERNAME');
|
|
|
|
$email->smtpPassword = getenv('SMTP_PASSWORD');
|
|
|
|
$email->smtpUseTLS = getenv('SMTP_TLS');
|
|
|
|
$email->toAddress = getenv("TO_EMAIL");
|
|
|
|
$email->fromAddress = getenv("FROM_EMAIL");
|
|
|
|
$email->fromName = getenv("FROM_NAME");
|
|
|
|
|
|
|
|
return $email;
|
|
|
|
},
|
|
|
|
];
|