Skip to content

Demo showcasing MongoDB Queryable Encryption with Spring Data MongoDB. Includes secure collection creation, encrypted fields, and range/equality queries.

License

Notifications You must be signed in to change notification settings

mongodb-developer/spring-data-queryable-encryption

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Data Queryable Encryption

This repository demonstrates how to integrate MongoDB Queryable Encryption with Spring Data MongoDB. It covers essential practices for creating encrypted collections and querying encrypted data efficiently using MongoDB’s Queryable Encryption capabilities. The project includes sample code for:

  • Creating encrypted collections and data encryption keys (DEKs).
  • Running range and equality queries on encrypted fields.
  • Working with MongoRepository and MongoTemplate in a secure, encrypted context.

Getting Started

Prerequisites

Running the Application

Open your terminal and run:

export MONGODB_URI="<YOUR_CONNECTION_STRING>" CRYPT_PATH="<PATH_TO_AUTOMATIC_ENC_SHA_LIB>"
mvn spring-boot:run

Swagger UI (API Documentation)

Once the application is running, access:

http://localhost:8080/swagger-ui.html

Or (for some versions):

http://localhost:8080/swagger-ui/index.html

It includes endpoints for:

  • /employees → Manage employees records

Example Endpoints

Create a Employee

POST /employees

Find All employees

GET /employees

Find employees with age greater than a specified value

GET /employees/ages/greater-than?age=50

Running the API with .http Files

This project includes ready-to-use .http files to test all API endpoints easily from your IDE (such as IntelliJ IDEA, Rider, or VSCode with REST Client plugin).

Files included:

  • employee_requests.http → Test all endpoints under /employees

How to use:

  1. Open the .http file in IntelliJ.
  2. Click on the green "Run" icon next to any request.
  3. You’ll see the response in a built-in HTTP client tab.

About

Demo showcasing MongoDB Queryable Encryption with Spring Data MongoDB. Includes secure collection creation, encrypted fields, and range/equality queries.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages