-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feature/oidc
- Loading branch information
Showing
57 changed files
with
2,180 additions
and
613 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
backend/src/db/migrations/20240609133400_private-key-handoff.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Knex } from "knex"; | ||
|
||
import { TableName } from "../schemas"; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
const doesPasswordFieldExist = await knex.schema.hasColumn(TableName.UserEncryptionKey, "hashedPassword"); | ||
const doesPrivateKeyFieldExist = await knex.schema.hasColumn( | ||
TableName.UserEncryptionKey, | ||
"serverEncryptedPrivateKey" | ||
); | ||
const doesPrivateKeyIVFieldExist = await knex.schema.hasColumn( | ||
TableName.UserEncryptionKey, | ||
"serverEncryptedPrivateKeyIV" | ||
); | ||
const doesPrivateKeyTagFieldExist = await knex.schema.hasColumn( | ||
TableName.UserEncryptionKey, | ||
"serverEncryptedPrivateKeyTag" | ||
); | ||
const doesPrivateKeyEncodingFieldExist = await knex.schema.hasColumn( | ||
TableName.UserEncryptionKey, | ||
"serverEncryptedPrivateKeyEncoding" | ||
); | ||
if (await knex.schema.hasTable(TableName.UserEncryptionKey)) { | ||
await knex.schema.alterTable(TableName.UserEncryptionKey, (t) => { | ||
if (!doesPasswordFieldExist) t.string("hashedPassword"); | ||
if (!doesPrivateKeyFieldExist) t.text("serverEncryptedPrivateKey"); | ||
if (!doesPrivateKeyIVFieldExist) t.text("serverEncryptedPrivateKeyIV"); | ||
if (!doesPrivateKeyTagFieldExist) t.text("serverEncryptedPrivateKeyTag"); | ||
if (!doesPrivateKeyEncodingFieldExist) t.text("serverEncryptedPrivateKeyEncoding"); | ||
}); | ||
} | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
const doesPasswordFieldExist = await knex.schema.hasColumn(TableName.UserEncryptionKey, "hashedPassword"); | ||
const doesPrivateKeyFieldExist = await knex.schema.hasColumn( | ||
TableName.UserEncryptionKey, | ||
"serverEncryptedPrivateKey" | ||
); | ||
const doesPrivateKeyIVFieldExist = await knex.schema.hasColumn( | ||
TableName.UserEncryptionKey, | ||
"serverEncryptedPrivateKeyIV" | ||
); | ||
const doesPrivateKeyTagFieldExist = await knex.schema.hasColumn( | ||
TableName.UserEncryptionKey, | ||
"serverEncryptedPrivateKeyTag" | ||
); | ||
const doesPrivateKeyEncodingFieldExist = await knex.schema.hasColumn( | ||
TableName.UserEncryptionKey, | ||
"serverEncryptedPrivateKeyEncoding" | ||
); | ||
if (await knex.schema.hasTable(TableName.UserEncryptionKey)) { | ||
await knex.schema.alterTable(TableName.UserEncryptionKey, (t) => { | ||
if (doesPasswordFieldExist) t.dropColumn("hashedPassword"); | ||
if (doesPrivateKeyFieldExist) t.dropColumn("serverEncryptedPrivateKey"); | ||
if (doesPrivateKeyIVFieldExist) t.dropColumn("serverEncryptedPrivateKeyIV"); | ||
if (doesPrivateKeyTagFieldExist) t.dropColumn("serverEncryptedPrivateKeyTag"); | ||
if (doesPrivateKeyEncodingFieldExist) t.dropColumn("serverEncryptedPrivateKeyEncoding"); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.