-
Notifications
You must be signed in to change notification settings - Fork 679
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish preliminary token auth method
- Loading branch information
1 parent
661e5ec
commit 93be409
Showing
25 changed files
with
1,336 additions
and
17 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
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
24 changes: 24 additions & 0 deletions
24
backend/src/db/migrations/20240702175124_identity-token-auth.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,24 @@ | ||
import { Knex } from "knex"; | ||
|
||
import { TableName } from "../schemas"; | ||
import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils"; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
await knex.schema.createTable(TableName.IdentityTokenAuth, (t) => { | ||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); | ||
t.bigInteger("accessTokenTTL").defaultTo(7200).notNullable(); | ||
t.bigInteger("accessTokenMaxTTL").defaultTo(7200).notNullable(); | ||
t.bigInteger("accessTokenNumUsesLimit").defaultTo(0).notNullable(); | ||
t.jsonb("accessTokenTrustedIps").notNullable(); | ||
t.timestamps(true, true, true); | ||
t.uuid("identityId").notNullable().unique(); | ||
t.foreign("identityId").references("id").inTable(TableName.Identity).onDelete("CASCADE"); | ||
}); | ||
|
||
await createOnUpdateTrigger(knex, TableName.IdentityTokenAuth); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.schema.dropTableIfExists(TableName.IdentityTokenAuth); | ||
await dropOnUpdateTrigger(knex, TableName.IdentityTokenAuth); | ||
} |
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,23 @@ | ||
// Code generated by automation script, DO NOT EDIT. | ||
// Automated by pulling database and generating zod schema | ||
// To update. Just run npm run generate:schema | ||
// Written by akhilmhdh. | ||
|
||
import { z } from "zod"; | ||
|
||
import { TImmutableDBKeys } from "./models"; | ||
|
||
export const IdentityTokenAuthsSchema = z.object({ | ||
id: z.string().uuid(), | ||
accessTokenTTL: z.coerce.number().default(7200), | ||
accessTokenMaxTTL: z.coerce.number().default(7200), | ||
accessTokenNumUsesLimit: z.coerce.number().default(0), | ||
accessTokenTrustedIps: z.unknown(), | ||
createdAt: z.date(), | ||
updatedAt: z.date(), | ||
identityId: z.string().uuid() | ||
}); | ||
|
||
export type TIdentityTokenAuths = z.infer<typeof IdentityTokenAuthsSchema>; | ||
export type TIdentityTokenAuthsInsert = Omit<z.input<typeof IdentityTokenAuthsSchema>, TImmutableDBKeys>; | ||
export type TIdentityTokenAuthsUpdate = Partial<Omit<z.input<typeof IdentityTokenAuthsSchema>, TImmutableDBKeys>>; |
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.