Encrypt Cast Attribute Idea - Encrypted By Default #42925
Unanswered
mathiasgrimm
asked this question in
Ideas
Replies: 1 comment
-
For those interested, you can use a package I created https://github.com/mathiasgrimm/laravel-encrypted-attributes |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Laravel Encrypted Model Attributes Idea
I was thinking in a way to improve the existing Eloquent cast
encrypted
Encrypted Casting.
Laravel Documentation:
Laravel's default behavior is to keep it encrypted only in the database, and plain text for the rest.
I think the default behaviour should be to always keep it encrypted unless you specifically ask for it decrypted.
Current Behavior
The examples bellow will all output the encrypted cast attributes in plain text:
The New API
I would phase out the encrypted casts and add a new
$encrypted
category for the attributes to avoid confusion betweenthem.
In addition to having the value encrypted, I would prepend the environment in which the string was encrypted in.
New Api Examples
I've thought the following API would be more or less the one I'd like to work.
Environment Scope
Environment prefixes
By doing that we can add extra checks based on the prefix.
Some companies already do that.
With that we could do things like:
https://github.com/mathiasgrimm/blog/blob/master/articles/laravel-encrypted-attributes-idea/
Beta Was this translation helpful? Give feedback.
All reactions