Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore(sso): return 409 when config for domain already exists (#9975)

Marc Klingenb4d01573447e
diff --git a/.cursor/commands/review.md b/.cursor/commands/review.md
new file mode 100644
index 0000000000..0f8122c945
--- /dev/null
+++ b/.cursor/commands/review.md
@@ -0,0 +1,29 @@
+# Code Review Checklist
+
+## Overview
+
+Comprehensive checklist for conducting thorough code reviews to ensure quality, security, and maintainability.
+
+## Review Categories
+
+### Functionality
+
+- [ ] Code does what it's supposed to do
+- [ ] Edge cases are handled
+- [ ] Error handling is appropriate
+- [ ] No obvious bugs or logic errors
+
+### Code Quality
+
+- [ ] Code is readable and well-structured
+- [ ] Functions are small and focused
+- [ ] Variable names are descriptive
+- [ ] No code duplication
+- [ ] Follows project conventions
+
+### Security
+
+- [ ] No obvious security vulnerabilities
+- [ ] Input validation is present
+- [ ] Sensitive data is handled properly
+- [ ] No hardcoded secrets
diff --git a/web/src/ee/features/multi-tenant-sso/createNewSsoConfigHandler.ts b/web/src/ee/features/multi-tenant-sso/createNewSsoConfigHandler.ts
index 79f1f4cfbe..236e009d32 100644
--- a/web/src/ee/features/multi-tenant-sso/createNewSsoConfigHandler.ts
+++ b/web/src/ee/features/multi-tenant-sso/createNewSsoConfigHandler.ts
@@ -53,6 +53,20 @@ export async function createNewSsoConfigHandler(
const { domain, authProvider, authConfig } = body.data;
+ // Preemptive check: Verify that SSO config doesn't already exist for this domain
+ const existingConfig = await prisma.ssoConfig.findUnique({
+ where: { domain },
+ });
+ if (existingConfig) {
+ logger.info(
+ `Attempt to create duplicate SSO configuration for domain: ${domain}`,
+ );
+ res.status(409).json({
+ error: `An SSO configuration already exists for domain '${domain}'`,
+ });
+ return;
+ }
+
const encryptedClientSecret = authConfig
? {
...authConfig,