You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Laravel 5.5 - data is stored as decrypted after model update #22
changed the title [-]Laravel 5.5 - data is stored as decrypted after update[/-][+]Laravel 5.5 - data is stored as decrypted after model update[/+]on Sep 15, 2017
Hrm, interesting. I wonder if it can be over-ridden in the trait and if doing so will cause breakages on prior versions of Laravel? I haven't started migrating any projects to L5.5 yet although it's a planned change with the new LTS release. I will keep this ticket open for monitoring and if anyone has any further information.
IIRC originalIsNumericallyEquivalent method was renamed (and refactored) to originalIsEquivalent in L5.5, so simply adding getDirty would break the trait for users of older versions.
Maybe we could just add second, optional trait with just getDirty() overriden? This, and an information in the readme should be enough IMHO.
Users of older Laravel versions wouldn't be affected by the changes.
I can prepare pull request if you don't mind and if the change is ok for you.
I just want to chime in that I am also looking to migrate from Laravel 5.1 to 5.5. I use this package to encrypt data in my database so I welcome any ideas on how to make it work on 5.5.
There is also an other bug with Laravel 5.5: If an attribute is casted, the getDirty will fail as well in certain cases. Essentially Laravel is casting the encrypted values which will result in different encrypted values being regarded as the same. E.g. object, array or json will be tried to be read from JSON. However, since the provided input is encrypted, the casted value evaluates to false no matter what.
Our solution is to overwrite the castAttribute method
/** * Decrypt encrypted data before it is processed by cast attribute * @param $key * @param $value * * @return mixed */protectedfunctioncastAttribute($key, $value)
{
returnparent::castAttribute($key, $this->doDecryptAttribute($key, $value));
}
Thanks for the information. I'm continuing to track this. I'm about to migrate one project from 5.1 LTS to 5.5 LTS so I will try to build something that works for both LTS versions.
Instead of trying to fix it for both versions at the same time (or forks or whatever), @delatbabel you could just release a new version which requires Laravel 5.5
I ended up 1) forking this, 2) fixing all the Laravel 5.5 issues, 3) dropping support for Laravel below 5.5, and 4) a bunch of random cleanup & unit tests. Available below:
@ITwrx Overwrite it in the model that needs to be encrypted. We have a base model for all encrypted models which uses Elocrypt's trait and overrides the castAttribute method (amongst other things).
Or you could simply create your own EncryptedModel trait which extends the original Elocrypt one.
Hi all, firstly sorry about the delay. I have had a long period of illness, just getting back to health now. I'll certainly look at integrating the patches into a Laravel 5.5 branch shortly.
Reacted by Momo Kornher, key_r00k13 and Giorgio Balduzzi
Activity
[-]Laravel 5.5 - data is stored as decrypted after update[/-][+]Laravel 5.5 - data is stored as decrypted after model update[/+]dokicro commentedon Sep 20, 2017
Hey, I have the same problem did you found any solutions?
bjauy commentedon Sep 21, 2017
Yes, you need to override
getDirty()method in your models which depend on Elocrypt trait:dokicro commentedon Sep 23, 2017
Thanks 👍
delatbabel commentedon Sep 25, 2017
Hrm, interesting. I wonder if it can be over-ridden in the trait and if doing so will cause breakages on prior versions of Laravel? I haven't started migrating any projects to L5.5 yet although it's a planned change with the new LTS release. I will keep this ticket open for monitoring and if anyone has any further information.
bjauy commentedon Sep 27, 2017
IIRC
originalIsNumericallyEquivalentmethod was renamed (and refactored) tooriginalIsEquivalentin L5.5, so simply addinggetDirtywould break the trait for users of older versions.Maybe we could just add second, optional trait with just
getDirty()overriden? This, and an information in the readme should be enough IMHO.Users of older Laravel versions wouldn't be affected by the changes.
I can prepare pull request if you don't mind and if the change is ok for you.
schonhose commentedon Oct 16, 2017
I just want to chime in that I am also looking to migrate from Laravel 5.1 to 5.5. I use this package to encrypt data in my database so I welcome any ideas on how to make it work on 5.5.
mrgrain commentedon Nov 3, 2017
There is also an other bug with Laravel 5.5: If an attribute is casted, the
getDirtywill fail as well in certain cases. Essentially Laravel is casting the encrypted values which will result in different encrypted values being regarded as the same. E.g.object,arrayorjsonwill be tried to be read from JSON. However, since the provided input is encrypted, the casted value evaluates tofalseno matter what.Our solution is to overwrite the
castAttributemethoddelatbabel commentedon Nov 10, 2017
Thanks for the information. I'm continuing to track this. I'm about to migrate one project from 5.1 LTS to 5.5 LTS so I will try to build something that works for both LTS versions.
mrgrain commentedon Dec 3, 2017
Instead of trying to fix it for both versions at the same time (or forks or whatever), @delatbabel you could just release a new version which requires Laravel 5.5
mbardelmeijer commentedon Dec 5, 2017
@delatbabel any update on this?
austinheap commentedon Dec 14, 2017
I ended up 1) forking this, 2) fixing all the Laravel 5.5 issues, 3) dropping support for Laravel below 5.5, and 4) a bunch of random cleanup & unit tests. Available below:
ITwrx commentedon Feb 20, 2018
@mrgrain where should one override the castAttribute method?
thanks
mrgrain commentedon Feb 21, 2018
@ITwrx Overwrite it in the model that needs to be encrypted. We have a base model for all encrypted models which uses Elocrypt's trait and overrides the
castAttributemethod (amongst other things).Or you could simply create your own
EncryptedModeltrait which extends the original Elocrypt one.ITwrx commentedon Feb 21, 2018
@mrgrain cool, thanks.
delatbabel commentedon Feb 21, 2018
Hi all, firstly sorry about the delay. I have had a long period of illness, just getting back to health now. I'll certainly look at integrating the patches into a Laravel 5.5 branch shortly.
ITwrx commentedon Feb 21, 2018
glad you're back. stay well.