Johnnes Souza
Johnnes Souza

Reputation: 391

Protect Data in MongoDB using Java Spring

At this moment I've an application built in Spring (Java 11) and I'm trying to figure out a better way to cypher the data that is stored in MongoDB.

Currently I've a method to cypher the user's password:

@Bean
public PasswordEncoder encoder() {
    return new BCryptPasswordEncoder();
}

user.setPassword(passwordEncoder.encode(password));

It works fine, but since I'm getting worried about data leaks I'll encode the whole user's personal data like name, address and email...

The main question I want to ask is: There's a better way to make this effient? Or the best way is to use the same code above to the trick?

PS: I've no problems to add new modules from Spring, like Security or Cloud.

Upvotes: 0

Views: 69

Answers (1)

FishingIsLife
FishingIsLife

Reputation: 2372

If you Store the Data encrypted in your dB How should the search part work? You would have to do a lot of Computing for every search which makes no sense. Encode your backups and use database auth with strict permissions and you are good.

Glad this helped:)

Upvotes: 1

Related Questions