agoston / spring-data-mongodb-encrypt

Lightweight library for simple & easy per-field encryption in mongodb+spring
Apache License 2.0
80 stars 30 forks source link

@Encrypted Support in POJOs for Aggregation Pipeline #61

Open PradeepNooney4569 opened 9 months ago

PradeepNooney4569 commented 9 months ago

Hello , I'm using an aggregate pipeline in MongoDB and have a POJO class to represent the results. Projection involves a class with encrypted fields.

I tried using @Encrypted in the POJO class, expecting automatic decryption during aggregation, but its getting only Binary Data only.

If there's an existing solution or workaround, kindly provide guidance. Thanks!

agoston commented 9 months ago

Hi!

Thanks for the report. Some operations are not supported, since they do not go through the 'normal' spring-data save/load events.

This is one of those. There is no actual 'save' or 'load' event sent by spring-data-mongodb, however, there seems to be a way to register for conversion to cover this case too.

I'll need to take a deep dive into how to make use of the BeforeConvert/AfterConvert events in spring-data. And also add coverage for mongoTemplate.aggregate() in the test suite. If you feel like it, feel free to peek into this, or else I'll try check this out.