Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

refactor: remove name column from enrollment tokens, revert V2 register to required fields

bernie-geff661afc5a8
diff --git a/backend/src/db/migrations/20260413000001_gateway-enrollment-tokens.ts b/backend/src/db/migrations/20260413000001_gateway-enrollment-tokens.ts
index bf06cf0385..d182def0ce 100644
--- a/backend/src/db/migrations/20260413000001_gateway-enrollment-tokens.ts
+++ b/backend/src/db/migrations/20260413000001_gateway-enrollment-tokens.ts
@@ -15,7 +15,6 @@ export async function up(knex: Knex): Promise<void> {
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
t.uuid("orgId").notNullable();
t.foreign("orgId").references("id").inTable(TableName.Organization).onDelete("CASCADE");
- t.string("name", 64).notNullable();
t.string("tokenHash", 128).notNullable().unique();
t.integer("ttl").notNullable().defaultTo(3600);
t.timestamp("expiresAt").notNullable();
diff --git a/backend/src/db/schemas/gateway-enrollment-tokens.ts b/backend/src/db/schemas/gateway-enrollment-tokens.ts
index 11d1d7c8fa..99cc5ebfd6 100644
--- a/backend/src/db/schemas/gateway-enrollment-tokens.ts
+++ b/backend/src/db/schemas/gateway-enrollment-tokens.ts
@@ -10,7 +10,6 @@ import { TImmutableDBKeys } from "./models";
export const GatewayEnrollmentTokensSchema = z.object({
id: z.string().uuid(),
orgId: z.string().uuid(),
- name: z.string(),
tokenHash: z.string(),
ttl: z.number().default(3600),
expiresAt: z.date(),
diff --git a/backend/src/ee/routes/v2/gateway-router.ts b/backend/src/ee/routes/v2/gateway-router.ts
index 2f18e29d7c..754043dfbe 100644
--- a/backend/src/ee/routes/v2/gateway-router.ts
+++ b/backend/src/ee/routes/v2/gateway-router.ts
@@ -24,8 +24,8 @@ export const registerGatewayV2Router = async (server: FastifyZodProvider) => {
schema: {
operationId: "registerGateway",
body: z.object({
- relayName: slugSchema({ min: 1, max: 32, field: "relayName" }).optional(),
- name: slugSchema({ min: 1, max: 32, field: "name" }).optional()
+ relayName: slugSchema({ min: 1, max: 32, field: "relayName" }),
+ name: slugSchema({ min: 1, max: 32, field: "name" })
}),
response: {
200: z.object({
diff --git a/backend/src/ee/routes/v3/gateway-router.ts b/backend/src/ee/routes/v3/gateway-router.ts
index 3efe490868..0939316a23 100644
--- a/backend/src/ee/routes/v3/gateway-router.ts
+++ b/backend/src/ee/routes/v3/gateway-router.ts
@@ -91,7 +91,7 @@ export const registerGatewayV3Router = async (server: FastifyZodProvider) => {
type: EventType.GATEWAY_ENROLLMENT_TOKEN_CREATE,
metadata: {
tokenId: result.id,
- name: result.name
+ name: result.gatewayName
}
}
});
diff --git a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts b/backend/src/ee/services/gateway-v2/gateway-v2-service.ts
index aa49d5cd49..c59e82f736 100644
--- a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts
+++ b/backend/src/ee/services/gateway-v2/gateway-v2-service.ts
@@ -1282,7 +1282,6 @@ export const gatewayV2ServiceFactory = ({
return gatewayEnrollmentTokenDAL.create(
{
orgId: orgPermission.orgId,
- name: gateway.name,
tokenHash: gatewayToken.tokenHash,
ttl: ENROLLMENT_TOKEN_TTL_SECONDS,
expiresAt: gatewayToken.expiresAt,
@@ -1292,7 +1291,7 @@ export const gatewayV2ServiceFactory = ({
);
});
- return { ...record, token: gatewayToken.plainToken };
+ return { ...record, token: gatewayToken.plainToken, gatewayName: gateway.name };
};
const connectGateway = async ({
@@ -1348,7 +1347,7 @@ export const gatewayV2ServiceFactory = ({
throw new BadRequestError({ message: "Enrollment token has expired" });
}
- const { orgId, name } = tokenRecord;
+ const { orgId } = tokenRecord;
// Resolve the relay before consuming the token so a missing relay doesn't burn it.
let relay: TRelays | undefined;
diff --git a/frontend/src/hooks/api/gateways-v2/types.ts b/frontend/src/hooks/api/gateways-v2/types.ts
index 6821df819e..d2281fceed 100644
--- a/frontend/src/hooks/api/gateways-v2/types.ts
+++ b/frontend/src/hooks/api/gateways-v2/types.ts
@@ -21,7 +21,6 @@ export type TGatewayV2 = {
export type TGatewayEnrollmentToken = {
id: string;
- name: string;
ttl: number;
expiresAt: string;
usedAt: string | null;