-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
use Jasny\Auth\AuthMiddleware;
use Jasny\Auth\AttributesHandler;
$fn = static function (ServerRequestInterface $request) {
return new ReflectionMethod($request->getAttribute('route.controller'), $request->getAttribute('route.action'));
};
$middleware = new AuthMiddleware($auth, $fn, $responseFactory);
$router->add($middleware);If the callback for AuthMiddleware returns a reflection object, the attributes will be obtained and verified.
use Jasny\Auth\Attributes\Roles;
#[Roles('admin')]
class AdminController
{
}use Jasny\Auth\Attributes\Roles;
use Jasny\Auth\Attributes\Context;
#[Controller('clients')]
class ClientController
{
#[Post('/:id')]
#[Roles('manager')]
public edit(
#[Context] string $clientId,
) {
// ...
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels