add nonce to token tables just in case, add public key token type for future auth features

This commit is contained in:
Evert Prants 2022-09-11 10:56:07 +03:00
parent 4b4cd88698
commit 991bc68624
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,27 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class tokentypes1662882569739 implements MigrationInterface {
name = 'tokentypes1662882569739';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE \`user_token\` ADD \`nonce\` text NULL`,
);
await queryRunner.query(
`ALTER TABLE \`o_auth2_token\` ADD \`nonce\` text NULL`,
);
await queryRunner.query(
`ALTER TABLE \`user_token\` CHANGE \`type\` \`type\` enum ('generic', 'activation', 'deactivation', 'password', 'login', 'gdpr', 'totp', 'public_key', 'recovery') NOT NULL`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE \`user_token\` CHANGE \`type\` \`type\` enum ('generic', 'activation', 'deactivation', 'password', 'login', 'gdpr', 'totp', 'recovery') NOT NULL`,
);
await queryRunner.query(`ALTER TABLE \`user_token\` DROP COLUMN \`nonce\``);
await queryRunner.query(
`ALTER TABLE \`o_auth2_token\` DROP COLUMN \`nonce\``,
);
}
}

View File

@ -26,6 +26,9 @@ export class OAuth2Token {
@Column({ nullable: false, type: 'text' })
token: string;
@Column({ nullable: true, type: 'text' })
nonce: string;
@Column({ type: 'text', nullable: true })
scope: string;

View File

@ -15,6 +15,7 @@ export enum UserTokenType {
LOGIN = 'login',
GDPR = 'gdpr',
TOTP = 'totp',
PUBLIC_KEY = 'public_key',
RECOVERY = 'recovery',
}
@ -26,6 +27,9 @@ export class UserToken {
@Column({ nullable: false, type: 'text' })
token: string;
@Column({ nullable: true, type: 'text' })
nonce: string;
@Column({ type: 'enum', enum: UserTokenType, nullable: false })
type: UserTokenType;