[E5.S1] Database-Backed Secure Credential Manager Implementation #50
Labels
No labels
Epic 5
MCP
P1
PR-0
PR-1
api
api-layer
architecture
area:backend
area:frontend
arrow
authentication
backend
bug
chat
client
clipboard
common-module
compose
cross-cutting
cross-cutting-requirement
data-layer
data-models
database
desktop-client
documentation
duplicate
enhancement
epic
epic-1
epic-2
epic-3
epic-4
epic-5
epic-6
epic-7
epic-llm-config
error-handling
feature
frontend
good first issue
help wanted
implementation
infrastructure
installer
invalid
kotlin
ktor
llm
medium-priority
message
multiplatform
needs-review
needs-triage
packaging
performance
phase-1
phase-2
phase-3
phase-4
phase-5
phase3
phase:3
priority: high
question
refactor
refactoring
resource-sharing
security
server
server-module
services
session
session-management
settings
setup
shutdown
state
storage
streaming
sub-issue
tests
tooling
type:task
ui
ui/ux
user-accounts
user-management
ux
viewmodel
websocket
windows
windows-integration
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Torvian.eu/chatbot#50
Loading…
Reference in a new issue
No description provided.
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?
Description
As a developer, I need to implement the core logic for securely storing and managing sensitive API keys by utilizing custom envelope encryption and storing the resulting encrypted data in a dedicated database table (
api_secrets), so that user keys are protected locally without relying on OS-specific credential managers.Acceptance Criteria
CredentialManagerinterface is implemented byDbEncryptedCredentialManager.EncryptionServiceandCryptoProvider(handling DEK/KEK), with KEK configuration managed byEncryptionConfig.ApiSecretDaoto interact with a dedicatedapi_secretsdatabase table (E7.S4).api_secretstable stores the encrypted API key (encrypted_credential), the wrapped Data Encryption Key (wrapped_dek), and the KEK version, uniquely identified by a generated UUIDalias.DbEncryptedCredentialManager'sstoreCredentialmethod encrypts the raw key, generates a UUIDalias, and saves the encrypted data (with thealias) to theapi_secretstable viaApiSecretDao, returning thealias.DbEncryptedCredentialManager'sgetCredentialmethod retrieves the encrypted data byaliasfromapi_secretsviaApiSecretDao, unwraps the DEK, decrypts the key, and returns the raw key string.DbEncryptedCredentialManager'sdeleteCredentialmethod deletes the record matching thealiasfrom theapi_secretstable viaApiSecretDao.LLMModeldatabase schema (E7.S4) includes anapiKeyIdfield (String, nullable) that stores the UUIDaliasreferencing theapi_secretstable record, not the raw key.CredentialManagerto store keys securely, saving the returnedaliasin the correspondingLLMModelrecord.api_secretstable are persisted.ApiSecretDaoand encryption/decryption operations are performed asynchronously using Coroutines.Implementation Details
This story involves implementing a secure database-backed credential manager using envelope encryption:
The
CredentialManagerinterface will define the contract for credential operations:suspend fun storeCredential(rawCredential: String): String- returns aliassuspend fun getCredential(alias: String): String?- returns decrypted credentialsuspend fun deleteCredential(alias: String): BooleanThe
DbEncryptedCredentialManagerimplementation will:api_secretstable in the SQLite databaseApiSecretDaothat handles data persistenceThe
EncryptionServicewill:A
CryptoProviderwill:Dependencies
api_secretstableParent Epic
Epic 5: API Key Management
Related Stories
Technical Notes