- WIP on ulmus-user mechanics updates

This commit is contained in:
Dave Mc Nicoll committed 2025-06-13 19:14:30 +00:00
1 parent 69382f912b
commit af8b686e3b
9 files changed
+72 -27

No files matched your search

+19 -12
View File
@@ -1,10 +1,12 @@
<?php
use Lean\Factory\HttpFactory;
use Lean\Factory\HttpFactoryInterface;
use Ulmus\User\{Entity,
use Ulmus\User\{Authorize\HeaderAuthentication,
Entity,
Lib\Authenticate,
Lib\Authorize,
Middleware\AuthenticationMiddleware,
Middleware\HeaderAuthenticationMiddleware,
Middleware\PostRequestAuthenticationMiddleware,
Authorize\PostRequestAuthentication};
@@ -13,24 +15,29 @@ use Picea\Picea;
use Storage\{ Cookie, Session };
use Psr\Container\ContainerInterface;
use function DI\{get, autowire, create};
return [
Authenticate::class => create(Authenticate::class)->constructor(get(Entity\UserInterface::class), get(Session::class), get(Cookie::class), get('authentication.method')),
Authorize::class => create(Authorize::class)->constructor(get(Entity\UserInterface::class), get(Session::class), get(Cookie::class), get('authentication.method')),
HeaderAuthenticationMiddleware::class => create(HeaderAuthenticationMiddleware::class)->constructor(get(Authorize::class), get(Entity\UserInterface::class), get('authorize.error')),
Authenticate::class => create(Authenticate::class)->constructor(get(Entity\UserInterface::class), get(Session::class), get(Cookie::class), get('authentication.method')),
PostRequestAuthentication::class => create(PostRequestAuthentication::class)->constructor(get(Authenticate::class), "email", "email", "password"),
AuthenticationMiddleware::class => create(AuthenticationMiddleware::class)->constructor(get(Authorize::class), get('authorize.error')),
PostRequestAuthenticationMiddleware::class => create(PostRequestAuthenticationMiddleware::class)->constructor(get(Entity\UserInterface::class), get('authentication.error'), get(PostRequestAuthentication::class)),
HeaderAuthentication::class => autowire(HeaderAuthentication::class),
HeaderAuthenticationMiddleware::class => create(HeaderAuthenticationMiddleware::class)->constructor(get(HeaderAuthentication::class)),
PostRequestAuthentication::class => create(PostRequestAuthentication::class)->constructor("email", "email", "password"),
PostRequestAuthenticationMiddleware::class => create(PostRequestAuthenticationMiddleware::class)->constructor(get(PostRequestAuthentication::class)),
'authentication.method' => null,
'authorize.error' => function($c) {
return function(array $errorData) {
return HttpFactory::createJsonResponse($errorData + [
'authorize.error' => function(ContainerInterface $c) {
return function(array $errorData) use ($c) {
return $c->get(HttpFactoryInterface::class)::createJsonResponse($errorData + [
'api.error' => "Authorization failed",
'api.datetime' => (new \DateTime)->format(\DateTime::ISO8601),
], 403);
@@ -38,8 +45,8 @@ return [
},
'authentication.error' => function($c, Picea $picea) {
return function($message) use ($picea) {
return HttpFactory::createHtmlResponse($picea->renderHtml('lean/error/500', [
return function($message) use ($c, $picea) {
return $c->get(HttpFactoryInterface::class)::createHtmlResponse($picea->renderHtml('lean/error/500', [
'title' => "Authentication failed",
'subtitle' => "",
'message' => $message,