mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-11 07:32:57 +03:00
[PR #327] [MERGED] feat: Allow setting path where keys are stored + only store private key #873
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/pocket-id/pocket-id/pull/327
Author: @ItalyPaleAle
Created: 3/13/2025
Status: ✅ Merged
Merged: 3/13/2025
Merged by: @stonith404
Base:
main← Head:keys-path📝 Commits (3)
1e2d6c1feat: Allow setting path where keys are stored + only store private key01754a8Address review feedback2022629Merge branch 'main' into keys-path📊 Changes
3 files changed (+63 additions, -78 deletions)
View changed files
📝
backend/internal/common/env_config.go(+13 -9)📝
backend/internal/service/jwt_service.go(+49 -67)📝
backend/internal/service/test_service.go(+1 -2)📄 Description
Currently, it's possible to configure paths used by pocket-id to store the SQLite DB, uploads, and the GeoDB data. However, keys were stored in the hardcoded path
data/keys.This PR introduces the env var
KEYS_PATHwhich allows overriding where keys are stored. Its default value isdata/keys.Additionally, as I was implementing this, I realized that pocket-id was writing to disk both the private and public keys, and loading them independently. This was both unnecessary, since the public key can always be derived from the private one, and potentially a bit dangerous, as users could modify the public key on disk and pocket-id was not checking to make sure the two keys were related to each other.
PS: Also included a performance optimization where the ID of the key is pre-computed once and saved in the object, rather than re-computed every time, since the computation is expensive and the value is static
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.