refactor: update forward authentication handling in domain schema and tests

- Replaced `forwardAuthProviderId` with `forwardAuthEnabled` in the domain schema to simplify the configuration of forward authentication.
- Updated related tests to reflect this change, ensuring consistency across the application.
- Introduced a new SQL migration to create the `forward_auth_settings` table for managing authentication domains and their configurations.

This refactor enhances the clarity and maintainability of the forward authentication logic within the application.
This commit is contained in:
Mauricio Siu
2026-06-06 03:53:45 -06:00
parent 35f452d25f
commit 1df6774ee8
12 changed files with 8483 additions and 29 deletions

View File

@@ -16,7 +16,6 @@ import { applications } from "./application";
import { compose } from "./compose";
import { previewDeployments } from "./preview-deployments";
import { certificateType } from "./shared";
import { ssoProvider } from "./sso";
export const domainType = pgEnum("domainType", [
"compose",
@@ -56,10 +55,7 @@ export const domains = pgTable("domain", {
internalPath: text("internalPath").default("/"),
stripPath: boolean("stripPath").notNull().default(false),
middlewares: text("middlewares").array().default(sql`ARRAY[]::text[]`),
forwardAuthProviderId: text("forwardAuthProviderId").references(
() => ssoProvider.providerId,
{ onDelete: "set null" },
),
forwardAuthEnabled: boolean("forwardAuthEnabled").notNull().default(false),
});
export const domainsRelations = relations(domains, ({ one }) => ({
@@ -75,10 +71,6 @@ export const domainsRelations = relations(domains, ({ one }) => ({
fields: [domains.previewDeploymentId],
references: [previewDeployments.previewDeploymentId],
}),
forwardAuthProvider: one(ssoProvider, {
fields: [domains.forwardAuthProviderId],
references: [ssoProvider.providerId],
}),
}));
const createSchema = createInsertSchema(domains, {
@@ -103,7 +95,7 @@ export const apiCreateDomain = createSchema.pick({
internalPath: true,
stripPath: true,
middlewares: true,
forwardAuthProviderId: true,
forwardAuthEnabled: true,
});
export const apiFindDomain = z.object({
@@ -136,6 +128,6 @@ export const apiUpdateDomain = createSchema
internalPath: true,
stripPath: true,
middlewares: true,
forwardAuthProviderId: true,
forwardAuthEnabled: true,
})
.merge(createSchema.pick({ domainId: true }).required());