# |
Jul 24th 2021, 09:45 |
kevin.pfeifer |
there is only one post-install hook after `composer install` which sets `chmod -R 777 logs tmp` https://github.com/cakephp/app/blob/54b699c2b0b212cef645f8c764c6b7494c9bba32/src/Console/Installer.php#L136 |
# |
Jul 24th 2021, 09:35 |
kevin.pfeifer |
what permissions problems do you have? |
# |
Jul 24th 2021, 09:10 |
noel |
I tried this:-https://book.cakephp.org/3/en/installation.html#permissions ... but it doesn't work on Mac |
# |
Jul 24th 2021, 09:09 |
noel |
Is there a bin/cake command to reset folder permissions for cake? |
# |
Jul 24th 2021, 08:25 |
rohith |
Never mind, I think I am supposed to do that using TypeFactory::map() function :) |
# |
Jul 24th 2021, 08:20 |
rohith |
Hi, is there any way to disable date and time converting to FrozenDate Object when executing queries ? |
# |
Jul 23rd 2021, 13:27 |
kevin.pfeifer |
but thats how the authentication and authorization plugin is built now |
# |
Jul 23rd 2021, 13:27 |
kevin.pfeifer |
not that easy for sure |
# |
Jul 23rd 2021, 13:27 |
paolo.bragagni |
thanks Kevin |
# |
Jul 23rd 2021, 13:27 |
paolo.bragagni |
but probaby from now on I can go with my legs |
# |
Jul 23rd 2021, 13:27 |
kevin.pfeifer |
then you need to adjust that in the given config |
# |
Jul 23rd 2021, 13:26 |
paolo.bragagni |
and not to https://cakephp.local/myapp/users/login |
# |
Jul 23rd 2021, 13:26 |
paolo.bragagni |
https://cakephp.local/users/login |
# |
Jul 23rd 2021, 13:26 |
paolo.bragagni |
it redirects to |
# |
Jul 23rd 2021, 13:26 |
kevin.pfeifer |
and the ```$request->getFlash()->error('You are not authorized to access that location');``` needs to be added anywhere in the handle function before the reutnr |
# |
Jul 23rd 2021, 13:24 |
kevin.pfeifer |
and adjust the namespace to `namespace App\Middleware\UnauthorizedHandler;` |
# |
Jul 23rd 2021, 13:24 |
kevin.pfeifer |
if you copied the whole RedirectHandler then you will have to add at least ```use Authorization\Middleware\UnauthorizedHandler\HandlerInterface;``` at the top since the interface can’t be autoloaded |
# |
Jul 23rd 2021, 13:22 |
paolo.bragagni |
steps ahead |
# |
Jul 23rd 2021, 13:20 |
kevin.pfeifer |
ok and ```use Authorization\Exception\ForbiddenException; ``` at the top |
# |
Jul 23rd 2021, 13:20 |
paolo.bragagni |
$middlewareQueue->add(new AuthorizationMiddleware($this, [ 'requireAuthorizationCheck' => false, 'unauthorizedHandler' => [ 'className' => 'Regtosc', 'url' => '/users/login', 'queryParam' => 'redirectUrl', 'exceptions' => [ ForbiddenException::class, MissingIdentityException::class, OtherException::class, ], ], ])); |
# |
Jul 23rd 2021, 13:19 |
kevin.pfeifer |
do you have the `ForbiddenException::class` in your exceptions array |
# |
Jul 23rd 2021, 13:18 |
kevin.pfeifer |
check your middleware |
# |
Jul 23rd 2021, 13:18 |
paolo.bragagni |
*Identity is not authorized to perform `add` on `App\Model\Entity\Libro`.* |
# |
Jul 23rd 2021, 13:18 |
paolo.bragagni |
but it doesnt redirect |
# |
Jul 23rd 2021, 13:17 |
kevin.pfeifer |
ok sure |
# |
Jul 23rd 2021, 13:17 |
paolo.bragagni |
no. now I've copied all redirect handler to my handler |
# |
Jul 23rd 2021, 13:17 |
kevin.pfeifer |
``` // Add authorization **after** authentication ->add(new AuthorizationMiddleware($this, [ 'unauthorizedHandler' => [ 'className' => 'CustomRedirect', 'url' => '/users/login', 'queryParam' => 'redirectUrl', 'exceptions' => [ MissingIdentityException::class, ForbiddenException::class ], ], ]))``` |
# |
Jul 23rd 2021, 13:15 |
kevin.pfeifer |
so its not working for you? |
# |
Jul 23rd 2021, 13:14 |
kevin.pfeifer |
basically what is done here https://github.com/cakephp/authorization/blob/master/src/Middleware/UnauthorizedHandler/RedirectHandler.php#L61 |
# |
Jul 23rd 2021, 13:14 |
paolo.bragagni |
a little bit too much for me :S |
# |
Jul 23rd 2021, 13:13 |
kevin.pfeifer |
and you have to tell the handler which exceptions it should “listen” to |
# |
Jul 23rd 2021, 13:13 |
kevin.pfeifer |
the handler only redirects certain exceptions |
# |
Jul 23rd 2021, 13:10 |
kevin.pfeifer |
and `use Authorization\Exception\ForbiddenException;` at the top |
# |
Jul 23rd 2021, 13:10 |
kevin.pfeifer |
you need to add `ForbiddenException::class` to the `exception` array |
# |
Jul 23rd 2021, 13:09 |
kevin.pfeifer |
as said, thats a different exception |
# |
Jul 23rd 2021, 13:08 |
paolo.bragagni |
*Identity is not authorized to perform `add` on `App\Model\Entity\Libro`* |
# |
Jul 23rd 2021, 13:05 |
kevin.pfeifer |
depending on the thrown execption could be that you need to adjust the expections array in the config |
# |
Jul 23rd 2021, 13:05 |
kevin.pfeifer |
works for me now :thinking_face: |
# |
Jul 23rd 2021, 13:04 |
paolo.bragagni |
mmm |
# |
Jul 23rd 2021, 13:04 |
kevin.pfeifer |
try to just return false to test it |
# |
Jul 23rd 2021, 13:04 |
kevin.pfeifer |
thats a problem inside your policy |