Skip to content

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

fix validation

Thiago Araujo da Silva5b1a563f74d8
diff --git a/backend/e2e-test/routes/v1/oauth-token-exchange.spec.ts b/backend/e2e-test/routes/v1/oauth-token-exchange.spec.ts
index 55e61d4611..3019889192 100644
--- a/backend/e2e-test/routes/v1/oauth-token-exchange.spec.ts
+++ b/backend/e2e-test/routes/v1/oauth-token-exchange.spec.ts
@@ -116,6 +116,24 @@ describe("OAuth client grant type registration", async () => {
expect(res.payload).toContain("audience only applies");
});
+ // Duplicates used to be silently accepted below the array bound and reported as "too many items" above
+ // it, so the same mistake failed differently depending on how many times it was repeated.
+ test("reports duplicate grant types as duplicates, however many there are", async () => {
+ const res = await createClient({
+ name: "e2e-duplicate-grants",
+ grantTypes: [
+ OauthGrantType.AuthorizationCode,
+ OauthGrantType.AuthorizationCode,
+ OauthGrantType.AuthorizationCode,
+ OauthGrantType.RefreshToken
+ ],
+ redirectUris: ["https://app.example.com/callback"]
+ });
+
+ expect(res.statusCode).toBe(422);
+ expect(res.payload).toContain("duplicate");
+ });
+
// Rotation on a token exchange application needs SSO edit permission on top of OauthClients edit, but
// it must stay a plain OauthClients operation for every other application. The seed actor holds both
// permissions, so this pins the non-exchange path rather than the denial.
diff --git a/backend/src/server/routes/v1/oauth-router.ts b/backend/src/server/routes/v1/oauth-router.ts
index de2a96888c..425f9bbd23 100644
--- a/backend/src/server/routes/v1/oauth-router.ts
+++ b/backend/src/server/routes/v1/oauth-router.ts
@@ -28,7 +28,10 @@ const grantTypesSchema = z
.nativeEnum(OauthGrantType)
.array()
.min(1)
- .max(Object.keys(OauthGrantType).length)
+ .max(32)
+ .refine((grantTypes) => new Set(grantTypes).size === grantTypes.length, {
+ message: "Grant types must not contain duplicate values"
+ })
.describe(
"The OAuth grant types this application may use. Redirect URIs apply only to authorization_code; the token exchange audience applies only to the token-exchange grant."
);