# |
May 7th 2021, 22:42 |
thomas078 |
Application.php |
# |
May 7th 2021, 22:39 |
ndm |
maybe you're setting this in the wrong place |
# |
May 7th 2021, 22:30 |
thomas078 |
i set $service->setConfig([ 'unauthenticatedRedirect' => '/users/login', 'queryParam' => 'redirect', ]); but still i get *Error:* No identity found. You can skip this check by configuring `requireIdentity` to be `false`. but no redirect? |
# |
May 7th 2021, 22:28 |
thomas078 |
then i will really see the whole scope to see how much work to migrate from cake 3 to 4 |
# |
May 7th 2021, 22:27 |
thomas078 |
sure. Will test that as well |
# |
May 7th 2021, 22:21 |
ndm |
correct, authorization checks are done in policies now |
# |
May 7th 2021, 22:20 |
thomas078 |
and that old inAuthorized is not called nomore |
# |
May 7th 2021, 22:20 |
thomas078 |
I guess this is now with Authorization plugin |
# |
May 7th 2021, 22:19 |
thomas078 |
ok. Authentication set. Now basic Authorization. I used to do it like: public function isAuthorized($user) |
# |
May 7th 2021, 22:12 |
ndm |
yes |
# |
May 7th 2021, 22:12 |
thomas078 |
So, basically with that i can manually set it |
# |
May 7th 2021, 22:11 |
thomas078 |
ok. Got it. I was confused as Authentication already worked :) |
# |
May 7th 2021, 22:10 |
ndm |
That method _can_ be used to manually authenticate an identity, or to update a persisted identity (for example in the session). You don't _have_ to use it for authentication to work. |
# |
May 7th 2021, 22:07 |
thomas078 |
This is confusing. Maybe after identifying user i have to setIdentity as well? ```$user = $this->Users->find()->where(['Users.id' => $this->Authentication->getIdentityData('id')])->first();` $this->Authentication->setIdentity($user);``` ? |
# |
May 7th 2021, 22:01 |
thomas078 |
what does it even do as i can anyway call logged in users with $this->Authentication->getIdentity() |
# |
May 7th 2021, 22:01 |
thomas078 |
Second question. In Auth component it was like $this->Auth->setUser($user);. Do i need to call ```// Persist the user into configured authenticators. $this->Authentication->setIdentity($user);``` |
# |
May 7th 2021, 22:00 |
thomas078 |
? |
# |
May 7th 2021, 22:00 |
thomas078 |
for e.g i can call like debug($this->Authentication->getIdentityData('role')); and i will get my role, is this the correct way to do it |
# |
May 7th 2021, 21:59 |
thomas078 |
debug($this->Authentication->getIdentity()); Getting the identify object will all correct. Littlebit confused what is the correct way to get actual information. Identifiers? |
# |
May 7th 2021, 21:04 |
tyler.adam.lazenby |
its for a CI |
# |
May 7th 2021, 21:04 |
tyler.adam.lazenby |
Does anybody have any docker files they would be willing to share for cakephp 4.x and php8.0 |
# |
May 7th 2021, 20:45 |
thomas078 |
will start to play with that now |
# |
May 7th 2021, 20:45 |
thomas078 |
cool. Thanks |
# |
May 7th 2021, 20:43 |
slackebot |
] ); }``` |
# |
May 7th 2021, 20:43 |
kevin.pfeifer |
if you want to have specific actions without authentication, then yes, they should be placed in the beforeFilter in the controller like ``` public function beforeFilter( \Cake\Event\EventInterface $event ) { parent::beforeFilter( $event ); // Configure the login action to not require authentication, preventing // the infinite redirect loop issue $this->Authentication->addUnauthenticatedActions( [ 'login' |
# |
May 7th 2021, 20:42 |
thomas078 |
@kevin.pfeifer Thanks. Thats it. Best place to set it is at controllers beforeFilter? |
# |
May 7th 2021, 20:35 |
kevin.pfeifer |
like it is stated here: https://book.cakephp.org/authentication/2/en/index.html#getting-started |
# |
May 7th 2021, 20:34 |
kevin.pfeifer |
do you have ```$this->loadComponent( 'Authentication.Authentication' );``` in your AppController.php initialize function? |
# |
May 7th 2021, 20:30 |
thomas078 |
Any idea where to look |
# |
May 7th 2021, 20:30 |
thomas078 |
trying my best to migrate Auth component to Authentication. debug($this->Authentication); on my UsersController is giving me ```Undefined property: UsersController::$Authentication in /src/Controller/UsersController.php on line 72 [CORE/src/Controller/Controller.php, line 387]``` |
# |
May 7th 2021, 17:49 |
mehov |
Okay, no surrogate it is then! Somehow never tried using a composite key, so this is about time. Thanks again for the advice guys :) |
# |
May 7th 2021, 17:39 |
kevin.pfeifer |
I don't even have Foreign Key constraints set on my database, I just let cakephp handle all that ,:) |
# |
May 7th 2021, 17:37 |
ndm |
Technically it doesn't even need to be a real constraint, but just defined in the table class, but that won't work with auto-tables. |
# |
May 7th 2021, 17:35 |
ndm |
Again, all is needed is a primary key constraint, it doesn't matter whether it's an additional field, or whether it's created over the existing foreign key fields. |
# |
May 7th 2021, 17:31 |
kevin.pfeifer |
but from a pure cakephp standpoint it isn't necesarry for a pure N:M aka HABTM connection between 2 tables |
# |
May 7th 2021, 17:30 |
kevin.pfeifer |
if you don't have any additional data that needs to be stored inside that junction table then you are fine without the id. If you need it for future data that needs to be stored inside there then sure, the ID is needed |
# |
May 7th 2021, 17:27 |
mehov |
Thank you Kevin! Also reading https://blog.jooq.org/2019/03/26/the-cost-of-useless-surrogate-keys-in-relationship-tables/ right now, they do say unnecessary surrogate keys are bad for performance. So I will try to go ahead without it this time. Thanks again! |
# |
May 7th 2021, 17:22 |
kevin.pfeifer |
see this comment and the one bellow it |
# |
May 7th 2021, 17:21 |
kevin.pfeifer |
1. no you don't need a seperate id column 2. if you stick with the cakephp naming conventions for table and column names it should auto-generate just fine with `cake bake all tablename` |
# |
May 7th 2021, 17:20 |
mehov |
Hi everyone! Quick question about a join table design for a HABTM association. Let's call it `articles_tags`. - Does it require a surrogate id? So `id | article_id | tag_id` - Or can I have only `article_id | tag_id` and simply make them a combined primary key? If I go for the latter, will Cake automatically recognise it, or will I have to configure something in the Table class? And am I going to regret this decision? |
# |
May 7th 2021, 16:46 |
thomas078 |
New Authentication seems to have token based auth as well |