Conversation
8451cec to
f2b1166
Compare
Preview of modified filesPreview of modified Markdown: |
code_samples/ change report
|
| In the following example the user doesn't have access to the controller unless they have the `section/view` policy and are [logged in using the "rememeber me cookie"]([[= symfony_doc =]]/security.html#checking-to-see-if-a-user-is-logged-in). | ||
| It uses the [`AuthenticatedRememberedCheckTrait`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-User-Controller-AuthenticatedRememberedCheckTrait.html) for the latter check. |
There was a problem hiding this comment.
In the description paragraph,
the policy must match example's new Attribute('custom_module', 'custom_function_2'),
the functions should be introduced in the same order than they're used in the example,
and there was a typo in "rememeber".
| In the following example the user doesn't have access to the controller unless they have the `section/view` policy and are [logged in using the "rememeber me cookie"]([[= symfony_doc =]]/security.html#checking-to-see-if-a-user-is-logged-in). | |
| It uses the [`AuthenticatedRememberedCheckTrait`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-User-Controller-AuthenticatedRememberedCheckTrait.html) for the latter check. | |
| In the following example the user doesn't have access to the controller unless they are [logged in using the "remember me cookie"]([[= symfony_doc =]]/security.html#checking-to-see-if-a-user-is-logged-in) and have the `custom_module/custom_function_2` policy. | |
| It uses the [`AuthenticatedRememberedCheckTrait::performAccessCheck()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-User-Controller-AuthenticatedRememberedCheckTrait.html#method_performAccessCheck) for the cookie check. |
I still don't get why we need to use the trait directly when we extends Admin UI Controller which already uses it so parent::performAccessCheck would work. https://doc.ibexa.co/en/5.0/api/php_api/php_api_reference/classes/Ibexa-Contracts-AdminUi-Controller-Controller.html.
Where you implements the RestrictedControllerInterface you don't inherit performAccessCheck, got to implement it, and to use the trait's one, here you need the method alias to have a method of the same name and still use it.
| use App\Security\Limitation\CustomLimitationValue; | ||
| use Ibexa\Contracts\AdminUi\Controller\Controller; | ||
| use Ibexa\Contracts\AdminUi\Permission\PermissionCheckerInterface; | ||
| use Ibexa\Contracts\Core\Repository\PermissionResolver; | ||
| use Ibexa\Contracts\User\Controller\AuthenticatedRememberedCheckTrait; | ||
| use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute; | ||
| use Symfony\Component\HttpFoundation\Request; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
|
|
||
| class CustomLimitationController extends Controller | ||
| { | ||
| use AuthenticatedRememberedCheckTrait { | ||
| AuthenticatedRememberedCheckTrait::performAccessCheck as public traitPerformAccessCheck; | ||
| } |
There was a problem hiding this comment.
Maybe it's a front office controller and we don't want to extend that. Could it simply implements the RestrictedControllerInterface?
| use App\Security\Limitation\CustomLimitationValue; | |
| use Ibexa\Contracts\AdminUi\Controller\Controller; | |
| use Ibexa\Contracts\AdminUi\Permission\PermissionCheckerInterface; | |
| use Ibexa\Contracts\Core\Repository\PermissionResolver; | |
| use Ibexa\Contracts\User\Controller\AuthenticatedRememberedCheckTrait; | |
| use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute; | |
| use Symfony\Component\HttpFoundation\Request; | |
| use Symfony\Component\HttpFoundation\Response; | |
| class CustomLimitationController extends Controller | |
| { | |
| use AuthenticatedRememberedCheckTrait { | |
| AuthenticatedRememberedCheckTrait::performAccessCheck as public traitPerformAccessCheck; | |
| } | |
| use App\Security\Limitation\CustomLimitationValue; | |
| use Ibexa\Contracts\AdminUi\Permission\PermissionCheckerInterface; | |
| use Ibexa\Contracts\Core\Repository\PermissionResolver; | |
| use Ibexa\Contracts\User\Controller\AuthenticatedRememberedCheckTrait; | |
| use Ibexa\Contracts\User\Controller\RestrictedControllerInterface | |
| use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute; | |
| use Symfony\Component\HttpFoundation\Request; | |
| use Symfony\Component\HttpFoundation\Response; | |
| class CustomLimitationController implements RestrictedControllerInterface | |
| { | |
| use AuthenticatedRememberedCheckTrait { | |
| AuthenticatedRememberedCheckTrait::performAccessCheck as public traitPerformAccessCheck; | |
| } |
Things done:
include_filecalls manually.