-
Notifications
You must be signed in to change notification settings - Fork 738
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
171 changed files
with
4,376 additions
and
527 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Knex } from "knex"; | ||
|
||
import { TableName } from "../schemas"; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
if (!(await knex.schema.hasTable(TableName.OidcConfig))) { | ||
await knex.schema.createTable(TableName.OidcConfig, (tb) => { | ||
tb.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); | ||
tb.string("discoveryURL"); | ||
tb.string("issuer"); | ||
tb.string("authorizationEndpoint"); | ||
tb.string("jwksUri"); | ||
tb.string("tokenEndpoint"); | ||
tb.string("userinfoEndpoint"); | ||
tb.text("encryptedClientId").notNullable(); | ||
tb.string("configurationType").notNullable(); | ||
tb.string("clientIdIV").notNullable(); | ||
tb.string("clientIdTag").notNullable(); | ||
tb.text("encryptedClientSecret").notNullable(); | ||
tb.string("clientSecretIV").notNullable(); | ||
tb.string("clientSecretTag").notNullable(); | ||
tb.string("allowedEmailDomains").nullable(); | ||
tb.boolean("isActive").notNullable(); | ||
tb.timestamps(true, true, true); | ||
tb.uuid("orgId").notNullable().unique(); | ||
tb.foreign("orgId").references("id").inTable(TableName.Organization); | ||
}); | ||
} | ||
|
||
if (await knex.schema.hasTable(TableName.SuperAdmin)) { | ||
if (!(await knex.schema.hasColumn(TableName.SuperAdmin, "trustOidcEmails"))) { | ||
await knex.schema.alterTable(TableName.SuperAdmin, (tb) => { | ||
tb.boolean("trustOidcEmails").defaultTo(false); | ||
}); | ||
} | ||
} | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.schema.dropTableIfExists(TableName.OidcConfig); | ||
|
||
if (await knex.schema.hasTable(TableName.SuperAdmin)) { | ||
if (await knex.schema.hasColumn(TableName.SuperAdmin, "trustOidcEmails")) { | ||
await knex.schema.alterTable(TableName.SuperAdmin, (t) => { | ||
t.dropColumn("trustOidcEmails"); | ||
}); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
backend/src/db/migrations/20240624172027_default-saml-ldap-org.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,27 @@ | ||
import { Knex } from "knex"; | ||
|
||
import { TableName } from "../schemas"; | ||
|
||
const DEFAULT_AUTH_ORG_ID_FIELD = "defaultAuthOrgId"; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
const hasDefaultOrgColumn = await knex.schema.hasColumn(TableName.SuperAdmin, DEFAULT_AUTH_ORG_ID_FIELD); | ||
|
||
await knex.schema.alterTable(TableName.SuperAdmin, (t) => { | ||
if (!hasDefaultOrgColumn) { | ||
t.uuid(DEFAULT_AUTH_ORG_ID_FIELD).nullable(); | ||
t.foreign(DEFAULT_AUTH_ORG_ID_FIELD).references("id").inTable(TableName.Organization).onDelete("SET NULL"); | ||
} | ||
}); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
const hasDefaultOrgColumn = await knex.schema.hasColumn(TableName.SuperAdmin, DEFAULT_AUTH_ORG_ID_FIELD); | ||
|
||
await knex.schema.alterTable(TableName.SuperAdmin, (t) => { | ||
if (hasDefaultOrgColumn) { | ||
t.dropForeign([DEFAULT_AUTH_ORG_ID_FIELD]); | ||
t.dropColumn(DEFAULT_AUTH_ORG_ID_FIELD); | ||
} | ||
}); | ||
} |
Oops, something went wrong.