-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2857 from Infisical/feat/jwt-auth
feat: jwt auth
- Loading branch information
Showing
37 changed files
with
2,404 additions
and
44 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
34 changes: 34 additions & 0 deletions
34
backend/src/db/migrations/20241209144123_add-identity-jwt-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,34 @@ | ||
import { Knex } from "knex"; | ||
|
||
import { TableName } from "../schemas"; | ||
import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils"; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
if (!(await knex.schema.hasTable(TableName.IdentityJwtAuth))) { | ||
await knex.schema.createTable(TableName.IdentityJwtAuth, (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.uuid("identityId").notNullable().unique(); | ||
t.foreign("identityId").references("id").inTable(TableName.Identity).onDelete("CASCADE"); | ||
t.string("configurationType").notNullable(); | ||
t.string("jwksUrl").notNullable(); | ||
t.binary("encryptedJwksCaCert").notNullable(); | ||
t.binary("encryptedPublicKeys").notNullable(); | ||
t.string("boundIssuer").notNullable(); | ||
t.string("boundAudiences").notNullable(); | ||
t.jsonb("boundClaims").notNullable(); | ||
t.string("boundSubject").notNullable(); | ||
t.timestamps(true, true, true); | ||
}); | ||
|
||
await createOnUpdateTrigger(knex, TableName.IdentityJwtAuth); | ||
} | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.schema.dropTableIfExists(TableName.IdentityJwtAuth); | ||
await dropOnUpdateTrigger(knex, TableName.IdentityJwtAuth); | ||
} |
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,33 @@ | ||
// 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 { zodBuffer } from "@app/lib/zod"; | ||
|
||
import { TImmutableDBKeys } from "./models"; | ||
|
||
export const IdentityJwtAuthsSchema = 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(), | ||
identityId: z.string().uuid(), | ||
configurationType: z.string(), | ||
jwksUrl: z.string(), | ||
encryptedJwksCaCert: zodBuffer, | ||
encryptedPublicKeys: zodBuffer, | ||
boundIssuer: z.string(), | ||
boundAudiences: z.string(), | ||
boundClaims: z.unknown(), | ||
boundSubject: z.string(), | ||
createdAt: z.date(), | ||
updatedAt: z.date() | ||
}); | ||
|
||
export type TIdentityJwtAuths = z.infer<typeof IdentityJwtAuthsSchema>; | ||
export type TIdentityJwtAuthsInsert = Omit<z.input<typeof IdentityJwtAuthsSchema>, TImmutableDBKeys>; | ||
export type TIdentityJwtAuthsUpdate = Partial<Omit<z.input<typeof IdentityJwtAuthsSchema>, 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
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.