From 709dc7280e8b4aab2b173c3897b418f6e1759ae7 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Sun, 29 Jan 2023 21:30:42 -0500 Subject: Implement WebAuthn (#967) * implement webauthn * code review --------- Co-authored-by: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> --- src/util/migration/mysql/1675045120206-webauthn.ts | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/util/migration/mysql/1675045120206-webauthn.ts (limited to 'src/util/migration/mysql') diff --git a/src/util/migration/mysql/1675045120206-webauthn.ts b/src/util/migration/mysql/1675045120206-webauthn.ts new file mode 100644 index 00000000..e009fa0c --- /dev/null +++ b/src/util/migration/mysql/1675045120206-webauthn.ts @@ -0,0 +1,27 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class webauthn1675045120206 implements MigrationInterface { + name = "webauthn1675045120206"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE \`security_keys\` (\`id\` varchar(255) NOT NULL, \`user_id\` varchar(255) NULL, \`key_id\` varchar(255) NOT NULL, \`public_key\` varchar(255) NOT NULL, \`counter\` int NOT NULL, \`name\` varchar(255) NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`, + ); + await queryRunner.query( + `ALTER TABLE \`users\` ADD \`webauthn_enabled\` tinyint NOT NULL DEFAULT 0`, + ); + await queryRunner.query( + `ALTER TABLE \`security_keys\` ADD CONSTRAINT \`FK_24c97d0771cafedce6d7163eaad\` FOREIGN KEY (\`user_id\`) REFERENCES \`users\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE \`security_keys\` DROP FOREIGN KEY \`FK_24c97d0771cafedce6d7163eaad\``, + ); + await queryRunner.query( + `ALTER TABLE \`users\` DROP COLUMN \`webauthn_enabled\``, + ); + await queryRunner.query(`DROP TABLE \`security_keys\``); + } +} -- cgit 1.5.1