Fix: SSH credential public key decryption across browser sessions #342
@@ -17,18 +17,31 @@ class FieldCrypto {
|
||||
private static readonly ENCRYPTED_FIELDS = {
|
||||
users: new Set([
|
||||
"password_hash",
|
||||
"passwordHash",
|
||||
"client_secret",
|
||||
"clientSecret",
|
||||
"totp_secret",
|
||||
"totpSecret",
|
||||
"totp_backup_codes",
|
||||
"totpBackupCodes",
|
||||
"oidc_identifier",
|
||||
"oidcIdentifier",
|
||||
]),
|
||||
ssh_data: new Set([
|
||||
"password",
|
||||
"key",
|
||||
"key_password",
|
||||
"keyPassword",
|
||||
]),
|
||||
ssh_data: new Set(["password", "key", "key_password"]),
|
||||
ssh_credentials: new Set([
|
||||
"password",
|
||||
"private_key",
|
||||
"privateKey",
|
||||
"key_password",
|
||||
"keyPassword",
|
||||
"key",
|
||||
"public_key",
|
||||
"publicKey",
|
||||
]),
|
||||
};
|
||||
|
||||
|
|
||||
|
||||
@@ -6,6 +6,10 @@ export class LazyFieldEncryption {
|
||||
key_password: "keyPassword",
|
||||
private_key: "privateKey",
|
||||
public_key: "publicKey",
|
||||
// Reverse mappings for Drizzle ORM (camelCase -> snake_case)
|
||||
keyPassword: "key_password",
|
||||
privateKey: "private_key",
|
||||
publicKey: "public_key",
|
||||
};
|
||||
|
||||
static isPlaintextField(value: string): boolean {
|
||||
|
||||
Reference in New Issue
Block a user
While adding both
snake_caseandcamelCaseversions of the field names fixes the issue, it introduces duplication and makes maintenance more error-prone. A developer might forget to add both versions for a new encrypted field in the future.A more robust and maintainable approach would be to keep only the canonical
snake_casenames inENCRYPTED_FIELDSand handle the case conversion inside theshouldEncryptFieldmethod. This would centralize the logic and keep the configuration clean.For example,
shouldEncryptFieldcould convert the incomingfieldNametosnake_casebefore checking for its existence in the set. This would work for bothcamelCaseandsnake_caseinputs and would allow you to revert this part of the change, simplifying the configuration.