add nonce to token tables just in case, add public key token type for future auth features
This commit is contained in:
parent
4b4cd88698
commit
991bc68624
27
src/migration/1662882569739-tokentypes.ts
Normal file
27
src/migration/1662882569739-tokentypes.ts
Normal 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\``,
|
||||
);
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user