47ng / 47ng/prisma-field-encryption
Getting ciphertext back from the database
- 主要語言
- TypeScript
- 星號
- 306
- 分支
- 40
- PR 合併指標
- 30 天內沒有已合併 PR
描述
This issue somehow got turned into a thread about ciphertext not being decrypted and returned as-is from the database.
Such issues usually indicate:
1. That the setup is correct (encryption works, which means fields are correctly interpreted, and the encryption key is supplied correctly)
2. That there is something wrong with the decryption process.
Decryption will throw an error when in strict mode (using `/// @encrypted?mode=strict`), but will log a warning to the console in other modes. This could be the sign that you are missing the right key to decrypt data.
If there are no errors, it usually means that the ciphertext has been corrupted somehow, and failed to be detected by the middleware (so is passed through as any other data). Make sure your field maximum length is high enough to contain the largest expected ciphertext, which is larger than the clear-text. [Calculator available here](https://cloak.47ng.com/ciphertext-length-calculator).
---
Original issue content:
Adding a global strict decryption mode that throws errors when decryption fails (missing key) should help avoid building layers of encryption in migrations.
Use-case:
1. The decryption key is missing, encrypted data is returned in ciphertext (A)
3. The data migration re-encrypts ciphertext A with encryption key, producing ciphertext B
4. Decryption of re-encrypted records yield ciphertext A
貢獻指南
評估
這個 Issue 還沒有評估資料。