Comments (8)
You are right. It is impossible to search over encrypted values. And there is no workaround.
Probably, the only way is to use some 3d party solution, like haystack, to add a search index, using unencrypted data, but this approach could lead for security issues.
from django-fields.
Hi,
I think this is related to the object manager. When I tried MyModel.objects.get(email=user_email) it always says "matching query does not exist"
I tried adding method "get_prep_lookup" on BaseEncryptedField like this:
def get_prep_lookup(self, lookup_type, value):
value = self.get_db_prep_value(value)
return super(BaseEncryptedField, self).get_prep_lookup(lookup_type, value)
This isn't working because the method "get_db_prep_value" is appending random value from string.printable which isn't reversible. I changed this line into something reversible and everything worked as expected.
Hope this will be fixed.
Thanks
from django-fields.
What did you use to replace random value?
from django-fields.
I changed "random.choice(string.printable)" into "string.printable[index:index + 1] or 0". This way the get_prep_lookup will be able to recreate the encrypted value. I don't know if this would weaken the security.
I'm sorry, I think this didn't solve the admin search, but it did solve the "get" method of the object manager. I don't know why the search was working and now its not.
from django-fields.
Aha, I was searching using exact match. So if I search using a part or phrase it cant find any match.
from django-fields.
That is make sense, because part of the phrase can't be same as the whole phrase, after encoding.
from django-fields.
Probably, the best to close this issue, if there is now complete solution.
from django-fields.
Yeah, this doesn't solve the MyModel.objects.filter method too :(
from django-fields.
Related Issues (20)
- Wrong max_length value when using south HOT 5
- EncryptedCharField isn't decrypted in .values() HOT 1
- EncryptedCharField doesn't validate length HOT 1
- global name 'EncryptedPhoneNumberField' is not defined
- EncryptedCharField not encrypting value HOT 2
- Encryption password stored in a cleartext HOT 3
- Insecure block cipher mode HOT 5
- For consideration: Fields automatically decrypted in admin optional. HOT 1
- Use PKCS7 padding.
- Heroku and block_type='MODE_CBC' causes errors HOT 5
- EncryptedDateTimeField Causes "can't compare offset-naive and offset-aware datetimes" Error
- Filtering not supported? HOT 7
- Update Path for MODE_CBC deprecation warning
- Any plans for python3 or Django1.8 support? HOT 3
- Deprecation warning with django 1.3b4 HOT 2
- django 1.10 HOT 13
- Initial Update
- EncryptedDateField Still Broken
- Fix ReadMe so that people know what version of Django it works with
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-fields.