[PR #5425] [MERGED] feat: add configurable session cookie name #5197

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

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5425
Author: @CHANDRAHARSHIT
Created: 10/2/2025
Status: Merged
Merged: 10/28/2025
Merged by: @jamesgeorge007

Base: nextHead: Sessioncookie


📝 Commits (10+)

  • 9b3d6e0 Allow session cookie name override via config
  • 4f2be3e Added Session Cookie Name Configuration
  • 42cb547 Allow session cookie name override via config
  • 71879df Added Session Cookie Name Configuration
  • df3027d refactor: session config type usage
  • 408562d Update session cookie help text styling
  • 7b4c72c Merge remote changes and keep consistent hint text styling
  • 5f81d87 chore(admin): use shared cookie-name regex; feat(admin): mark session_cookie_name optional via metadata and remove hardcoded exclusion
  • 2bf2e85 chore: merge latest changes
  • 3a67193 refactor: optimize optional field validation and improve error messaging

📊 Changes

8 files changed (+68 additions, -3 deletions)

View changed files

📝 packages/hoppscotch-backend/src/infra-config/helper.ts (+5 -0)
📝 packages/hoppscotch-backend/src/infra-config/infra-config.service.ts (+5 -0)
📝 packages/hoppscotch-backend/src/main.ts (+6 -1)
📝 packages/hoppscotch-backend/src/types/InfraConfig.ts (+1 -0)
📝 packages/hoppscotch-sh-admin/locales/en.json (+3 -0)
📝 packages/hoppscotch-sh-admin/src/components/settings/AuthToken.vue (+14 -0)
📝 packages/hoppscotch-sh-admin/src/composables/useConfigHandler.ts (+26 -2)
📝 packages/hoppscotch-sh-admin/src/helpers/configs.ts (+8 -0)

📄 Description

What's changed

This pull request introduces support for configuring the session cookie name in the backend and admin UI, allowing deployments to override the default connect.sid cookie name for compatibility with certain proxies and load balancers. It includes backend changes to accept and validate the new configuration, updates to the admin interface for editing this value, and ensures validation on both backend and frontend.

Backend support for session cookie name configuration:

  • Added SESSION_COOKIE_NAME to the InfraConfigEnum and included it in the default infrastructure configs, allowing it to be set and stored (InfraConfigEnum, getDefaultInfraConfigs) [1] [2].
  • Updated session middleware initialization to use the configured cookie name, falling back to 'connect.sid' if unset, and documented the reason for this option (main.ts).
  • Added validation logic to ensure any custom cookie name only contains allowed characters (letters, numbers, underscore, hyphen), and allows leaving it empty to use the default (infra-config.service.ts).

Admin UI and configuration handling:

  • Added UI fields for editing and describing the session cookie name, including help text about valid values and the default (AuthToken.vue, en.json) [1] [2].
  • Updated configuration handling to support the new field, including validation to prevent invalid cookie names and exclusion from required field checks (useConfigHandler.ts, configs.ts) [1] [2] [3] [4] [5] [6].

Notes to reviewers

Test the additional field added in the Admin Dashboard's setting page.


🔄 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/5425 **Author:** [@CHANDRAHARSHIT](https://github.com/CHANDRAHARSHIT) **Created:** 10/2/2025 **Status:** ✅ Merged **Merged:** 10/28/2025 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `next` ← **Head:** `Sessioncookie` --- ### 📝 Commits (10+) - [`9b3d6e0`](https://github.com/hoppscotch/hoppscotch/commit/9b3d6e09dab6fe3ae6aae40dd6770d19208ab109) Allow session cookie name override via config - [`4f2be3e`](https://github.com/hoppscotch/hoppscotch/commit/4f2be3e8e7de3c0cc2a6eaab1a61fe92b6e26b1b) Added Session Cookie Name Configuration - [`42cb547`](https://github.com/hoppscotch/hoppscotch/commit/42cb54787f377cb48d3d5435cfdfed18b543fd8b) Allow session cookie name override via config - [`71879df`](https://github.com/hoppscotch/hoppscotch/commit/71879dfb3f69f6a0dcf835a56ba5156df0092048) Added Session Cookie Name Configuration - [`df3027d`](https://github.com/hoppscotch/hoppscotch/commit/df3027d1e62431db397a0d4c90138776e8fcc70d) refactor: session config type usage - [`408562d`](https://github.com/hoppscotch/hoppscotch/commit/408562dd641b596e2fdc720ae1e7df6f14ab9a27) Update session cookie help text styling - [`7b4c72c`](https://github.com/hoppscotch/hoppscotch/commit/7b4c72ce1ccde33a70d50735373791d2dde65b57) Merge remote changes and keep consistent hint text styling - [`5f81d87`](https://github.com/hoppscotch/hoppscotch/commit/5f81d87bbc13bfe69d7e131393c3266860563545) chore(admin): use shared cookie-name regex; feat(admin): mark session_cookie_name optional via metadata and remove hardcoded exclusion - [`2bf2e85`](https://github.com/hoppscotch/hoppscotch/commit/2bf2e859f771541aa795e35ed5be5e05613f7e2f) chore: merge latest changes - [`3a67193`](https://github.com/hoppscotch/hoppscotch/commit/3a67193217702182feabdeaa7e7fb8cb7809b3a6) refactor: optimize optional field validation and improve error messaging ### 📊 Changes **8 files changed** (+68 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-backend/src/infra-config/helper.ts` (+5 -0) 📝 `packages/hoppscotch-backend/src/infra-config/infra-config.service.ts` (+5 -0) 📝 `packages/hoppscotch-backend/src/main.ts` (+6 -1) 📝 `packages/hoppscotch-backend/src/types/InfraConfig.ts` (+1 -0) 📝 `packages/hoppscotch-sh-admin/locales/en.json` (+3 -0) 📝 `packages/hoppscotch-sh-admin/src/components/settings/AuthToken.vue` (+14 -0) 📝 `packages/hoppscotch-sh-admin/src/composables/useConfigHandler.ts` (+26 -2) 📝 `packages/hoppscotch-sh-admin/src/helpers/configs.ts` (+8 -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 --> <!-- Add an introduction into what this PR tries to solve in a couple of sentences --> ### What's changed <!-- Describe point by point the different things you have changed in this PR --> This pull request introduces support for configuring the session cookie name in the backend and admin UI, allowing deployments to override the default `connect.sid` cookie name for compatibility with certain proxies and load balancers. It includes backend changes to accept and validate the new configuration, updates to the admin interface for editing this value, and ensures validation on both backend and frontend. **Backend support for session cookie name configuration:** * Added `SESSION_COOKIE_NAME` to the `InfraConfigEnum` and included it in the default infrastructure configs, allowing it to be set and stored (`InfraConfigEnum`, `getDefaultInfraConfigs`) [[1]](diffhunk://#diff-47357014e310c83456bd4a2df2ffd2a604499cd3d75f0673f936f695c31287b8R7) [[2]](diffhunk://#diff-bc7e8193be965be1da1f064a60640676b277441f27f90d5867578525c80af283R130-R134). * Updated session middleware initialization to use the configured cookie name, falling back to `'connect.sid'` if unset, and documented the reason for this option (`main.ts`). * Added validation logic to ensure any custom cookie name only contains allowed characters (letters, numbers, underscore, hyphen), and allows leaving it empty to use the default (`infra-config.service.ts`). **Admin UI and configuration handling:** * Added UI fields for editing and describing the session cookie name, including help text about valid values and the default (`AuthToken.vue`, `en.json`) [[1]](diffhunk://#diff-1c1fc5edeab4d0fc72fa90a321530b17c295e367e1cb509006a576106c15c7f4R136-R149) [[2]](diffhunk://#diff-a82894606deb438ab68d013ec92c239fbbf19a56798deef330826a8b862a6086R55-R56). * Updated configuration handling to support the new field, including validation to prevent invalid cookie names and exclusion from required field checks (`useConfigHandler.ts`, `configs.ts`) [[1]](diffhunk://#diff-7a00400ff4b10955eaeb86e717562fb8b11be17f9b2e0ff6c18af57765efdb1dR156-R158) [[2]](diffhunk://#diff-7a00400ff4b10955eaeb86e717562fb8b11be17f9b2e0ff6c18af57765efdb1dL279-R284) [[3]](diffhunk://#diff-7a00400ff4b10955eaeb86e717562fb8b11be17f9b2e0ff6c18af57765efdb1dR565-R574) [[4]](diffhunk://#diff-7a00400ff4b10955eaeb86e717562fb8b11be17f9b2e0ff6c18af57765efdb1dR612-R615) [[5]](diffhunk://#diff-5403ef86c6b0ecea0765b06a22c80b6620f8d0ddcdd93ef814eb0b0fefdb1b22R70) [[6]](diffhunk://#diff-5403ef86c6b0ecea0765b06a22c80b6620f8d0ddcdd93ef814eb0b0fefdb1b22R255-R258). <!-- 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 --> Test the additional field added in the Admin Dashboard's setting page. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:40:07 +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#5197
No description provided.