[PR #4212] [MERGED] HSB-473 feat: encrypt sensitive data before storing in db #4704

Closed
opened 2026-03-17 02:12:57 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/4212
Author: @mirarifhasan
Created: 7/25/2024
Status: Merged
Merged: 8/14/2024
Merged by: @balub

Base: nextHead: feat/infra-config-encryption


📝 Commits (10+)

  • 1e997c7 feat: encryption added on onMuduleInit
  • 8cbe7b2 feat: encryption changes added on sh admin mutations and query
  • 5dcaefe chore: fetch minimum column from DB
  • 8025afb feat: data encryption added on account table
  • 9c6f7ca test: infra config test case update
  • e529293 chore: env example modified
  • 1b0a82b chore: update variable name
  • c91fd3a chore: refactor the code
  • 1ef2b6d feat: client-ids made encrypted
  • 0a4a77e chore: encrypted auth client id's

📊 Changes

8 files changed (+213 additions, -26 deletions)

View changed files

📝 .env.example (+3 -0)
packages/hoppscotch-backend/prisma/migrations/20240725043411_infra_config_encryption/migration.sql (+2 -0)
📝 packages/hoppscotch-backend/prisma/schema.prisma (+7 -6)
📝 packages/hoppscotch-backend/src/infra-config/helper.ts (+69 -13)
📝 packages/hoppscotch-backend/src/infra-config/infra-config.service.spec.ts (+23 -0)
📝 packages/hoppscotch-backend/src/infra-config/infra-config.service.ts (+55 -4)
📝 packages/hoppscotch-backend/src/user/user.service.ts (+3 -3)
📝 packages/hoppscotch-backend/src/utils.ts (+51 -0)

📄 Description

Closes HSB-473

This PR introduces data encryption before storing sensitive data in the database. For example, previously we stored SSO's secret key as plain text in the infraConfig table. From now on, before saving to DB, the value will be encrypted.
Also, after fetching the data from the DB, we decrypt it to the original value to use.

What's changed

In Account and InfraConfig tables, we added encryption and decryption logic to store/ fetch sensitive data.

Notes to reviewers

Nil


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/4212 **Author:** [@mirarifhasan](https://github.com/mirarifhasan) **Created:** 7/25/2024 **Status:** ✅ Merged **Merged:** 8/14/2024 **Merged by:** [@balub](https://github.com/balub) **Base:** `next` ← **Head:** `feat/infra-config-encryption` --- ### 📝 Commits (10+) - [`1e997c7`](https://github.com/hoppscotch/hoppscotch/commit/1e997c71ccceba6d86e041d0f252c131d4d5dd66) feat: encryption added on onMuduleInit - [`8cbe7b2`](https://github.com/hoppscotch/hoppscotch/commit/8cbe7b2a429f7ffd212b6b8c943e9b2018e78e37) feat: encryption changes added on sh admin mutations and query - [`5dcaefe`](https://github.com/hoppscotch/hoppscotch/commit/5dcaefed30d3253bb00655ce21d18e68ec14a3e9) chore: fetch minimum column from DB - [`8025afb`](https://github.com/hoppscotch/hoppscotch/commit/8025afb7293a2ba14408c12892d840a90f73b1ba) feat: data encryption added on account table - [`9c6f7ca`](https://github.com/hoppscotch/hoppscotch/commit/9c6f7ca0abca36a77081aa92d6d17ad596329941) test: infra config test case update - [`e529293`](https://github.com/hoppscotch/hoppscotch/commit/e5292939581732b0617dcd6ec51105960af5f3ff) chore: env example modified - [`1b0a82b`](https://github.com/hoppscotch/hoppscotch/commit/1b0a82b5c3f3233db1a7e5f165bc981eeeca6f80) chore: update variable name - [`c91fd3a`](https://github.com/hoppscotch/hoppscotch/commit/c91fd3ae1ff88a35272135e26ca5580ef3fe6e1d) chore: refactor the code - [`1ef2b6d`](https://github.com/hoppscotch/hoppscotch/commit/1ef2b6d15c95802dca95092e74f4e22f376d896f) feat: client-ids made encrypted - [`0a4a77e`](https://github.com/hoppscotch/hoppscotch/commit/0a4a77e8165a83e66b426ec25a75aa58de4ed1a2) chore: encrypted auth client id's ### 📊 Changes **8 files changed** (+213 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+3 -0) ➕ `packages/hoppscotch-backend/prisma/migrations/20240725043411_infra_config_encryption/migration.sql` (+2 -0) 📝 `packages/hoppscotch-backend/prisma/schema.prisma` (+7 -6) 📝 `packages/hoppscotch-backend/src/infra-config/helper.ts` (+69 -13) 📝 `packages/hoppscotch-backend/src/infra-config/infra-config.service.spec.ts` (+23 -0) 📝 `packages/hoppscotch-backend/src/infra-config/infra-config.service.ts` (+55 -4) 📝 `packages/hoppscotch-backend/src/user/user.service.ts` (+3 -3) 📝 `packages/hoppscotch-backend/src/utils.ts` (+51 -0) </details> ### 📄 Description <!-- Thanks for creating this pull request 🤗 Please make sure that the pull request is limited to one type (docs, feature, etc.) and keep it as small as possible. You can open multiple prs instead of opening a huge one. --> <!-- If this pull request closes an issue, please mention the issue number below --> <!-- Issue # here --> Closes HSB-473 <!-- Add an introduction into what this PR tries to solve in a couple of sentences --> This PR introduces data encryption before storing sensitive data in the database. For example, previously we stored SSO's secret key as plain text in the infraConfig table. From now on, before saving to DB, the value will be encrypted. Also, after fetching the data from the DB, we decrypt it to the original value to use. ### What's changed <!-- Describe point by point the different things you have changed in this PR --> In `Account` and `InfraConfig` tables, we added encryption and decryption logic to store/ fetch sensitive data. <!-- You can also choose to add a list of changes and if they have been completed or not by using the markdown to-do list syntax - [ ] Not Completed - [x] Completed --> ### Notes to reviewers <!-- Any information you feel the reviewer should know about when reviewing your PR --> Nil --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:12:57 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#4704
No description provided.