-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Required JSON field name was missing at depth 0 on encryptJSON() in strict mode #87
Comments
There are a couple of limitations with the current JSON field design:
This works great if you're storing, e.g. Stripe events as JSONB in a PostgreSQL database but want to encrypt them first. It doesn't work for your use case. You could iterate over the list with an instance of EncryptedRow and encrypt each blob individually. For example: $encryptedRow
->addTextField('name')
->addTextField('prompt')
->addTextField('who')
->addTextField('type')
->addBlindIndex('name', new BlindIndex('name_index'));
// Encrypt path:
$encryptedData = [];
foreach ($data as $index => $row) {
$encryptedData[$index] = $encryptedRow->prepareRowForStorage($row);
}
$storeThis = json_encode($encryptedData);
// Decrypt path:
$fromDatabase = json_decode($_whatever_, true);
$data = [];
foreach ($fromDatabase as $index => $row) {
$data[$index] = $encryptedRow->decryptRow($row[1]);
}
var_dump($data); However, this has one serious drawback and limitation: The items within the list can be freely arranged because its position in the list is not authenticated. This may be desirable in some cases, however! If we decide to add arbitrary depth and list support to JsonFieldMap, it would not be as flexible: The indices of the list items would be authenticated, always. |
Ok, thanks for the reply. I my case I don't need to search in the json field, so I think I will convert the db field to a text and then json encode/decode |
I have noticed that if I do something like this UserDoc::select('from_title') I get an EmptyFieldException basically any select that does not include all the encrypted columns will throw this exception. I must have missed someting in my setup ? |
Yes, empty fields are not permitted by default. ciphersweet/src/EncryptedRow.php Lines 847 to 863 in 198a301
You can call |
The changes in #88 will also make this easier to automate. |
Hi
in a Laravel project, I'm trying to store an array of data.
here is the data
the table has 2 columns, name and data
code
The text was updated successfully, but these errors were encountered: