feat(core): Add LDAP support (#3835)

This commit is contained in:
Ricardo Espinoza
2023-01-24 20:18:39 -05:00
committed by GitHub
parent 259296c5c9
commit 0c70a40317
77 changed files with 3686 additions and 192 deletions

View File

@@ -0,0 +1,62 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/Ldap/constants';
import { getTablePrefix, logMigrationEnd, logMigrationStart } from '@db/utils/migrationHelpers';
export class CreateLdapEntities1674509946020 implements MigrationInterface {
name = 'CreateLdapEntities1674509946020';
async up(queryRunner: QueryRunner): Promise<void> {
logMigrationStart(this.name);
const tablePrefix = getTablePrefix();
await queryRunner.query(
`ALTER TABLE "${tablePrefix}user" ADD COLUMN disabled BOOLEAN NOT NULL DEFAULT false;`,
);
await queryRunner.query(`
INSERT INTO ${tablePrefix}settings (key, value, "loadOnStartup")
VALUES ('${LDAP_FEATURE_NAME}', '${JSON.stringify(LDAP_DEFAULT_CONFIGURATION)}', true)
`);
await queryRunner.query(
`CREATE TABLE IF NOT EXISTS "${tablePrefix}auth_identity" (
"userId" uuid REFERENCES "${tablePrefix}user" (id),
"providerId" VARCHAR(64) NOT NULL,
"providerType" VARCHAR(32) NOT NULL,
"createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY("providerId", "providerType")
);`,
);
await queryRunner.query(
`CREATE TABLE IF NOT EXISTS "${tablePrefix}auth_provider_sync_history" (
"id" serial NOT NULL PRIMARY KEY,
"providerType" VARCHAR(32) NOT NULL,
"runMode" TEXT NOT NULL,
"status" TEXT NOT NULL,
"startedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"endedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"scanned" INTEGER NOT NULL,
"created" INTEGER NOT NULL,
"updated" INTEGER NOT NULL,
"disabled" INTEGER NOT NULL,
"error" TEXT
);`,
);
logMigrationEnd(this.name);
}
async down(queryRunner: QueryRunner): Promise<void> {
const tablePrefix = getTablePrefix();
await queryRunner.query(`DROP TABLE "${tablePrefix}auth_provider_sync_history"`);
await queryRunner.query(`DROP TABLE "${tablePrefix}auth_identity"`);
await queryRunner.query(
`DELETE FROM ${tablePrefix}settings WHERE key = '${LDAP_FEATURE_NAME}'`,
);
await queryRunner.query(`ALTER TABLE "${tablePrefix}user" DROP COLUMN disabled`);
}
}

View File

@@ -27,6 +27,7 @@ import { AddTriggerCountColumn1669823906995 } from './1669823906995-AddTriggerCo
import { RemoveWorkflowDataLoadedFlag1671726148421 } from './1671726148421-RemoveWorkflowDataLoadedFlag';
import { MessageEventBusDestinations1671535397530 } from './1671535397530-MessageEventBusDestinations';
import { DeleteExecutionsWithWorkflows1673268682475 } from './1673268682475-DeleteExecutionsWithWorkflows';
import { CreateLdapEntities1674509946020 } from './1674509946020-CreateLdapEntities';
export const postgresMigrations = [
InitialMigration1587669153312,
@@ -58,4 +59,5 @@ export const postgresMigrations = [
RemoveWorkflowDataLoadedFlag1671726148421,
MessageEventBusDestinations1671535397530,
DeleteExecutionsWithWorkflows1673268682475,
CreateLdapEntities1674509946020,
];