Skip to content

Release 2025-25-07 - #416

Merged
maxtechera merged 25 commits into
productionfrom
staging
Jul 25, 2025
Merged

Release 2025-25-07#416
maxtechera merged 25 commits into
productionfrom
staging

Conversation

@bradtaylorsf

@bradtaylorsf bradtaylorsf commented Jul 21, 2025

Copy link
Copy Markdown
Collaborator

Release Notes

Bug Fixes

  • Homepage Navigation: Fixed critical issues with homepage chat redirect handler to ensure proper user navigation (AAI-489)
  • Resolved infinite redirect loops and unnecessary API calls
  • Moved redirect logic to homepage component for better architecture
  • Improved error handling and timeout protection
  • Fixed JSX element issues in Homepage component
  • Enhanced user onboarding flow by ensuring correct destination redirects
  • Sidekicks Loading in Chat Views (Fix Sidekicks Loading Issues and Enhance UI Navigation #405)
  • Fixed sidekick fetching to handle errors gracefully
  • Added proper variable initialization to prevent undefined sidekicks
  • Enhanced error logging for better debugging
  • Implemented fallback mechanism to ensure sidekicks display even when errors occur
  • Authentication Configuration (replaced API_BASE_URL with API_HOST in passport #414)
  • Replaced API_BASE_URL with API_HOST in passport configuration
  • Standardized environment variable usage for better consistency
  • Improved authentication service reliability

User Interface & Experience

  • Navigation Enhancements (Fix Sidekicks Loading Issues and Enhance UI Navigation #405)
  • Reorganized menu structure for improved information architecture
  • Added descriptive tooltips to all menu items
  • Moved "Sidekick Store" to top level for greater visibility
  • Regrouped menu items into logical categories (Studio, Account)
  • Improved button and navigation styling
  • Apps Page Redesign (Fix Sidekicks Loading Issues and Enhance UI Navigation #405)
  • Implemented modern UI card design
  • Added detailed app descriptions, categories, and feature lists
  • Added "coming soon" indicators for future applications
  • Created consultation request flow for enterprise deployments
  • Sidekick Selection Improvements (Fix Sidekicks Loading Issues and Enhance UI Navigation #405)
  • Simplified selection UI with better organization
  • Grouped sidekicks logically (personal, recent, popular)
  • Enhanced visual hierarchy and information density
  • Improved error handling in selection process
  • Credential Deep Linking (added deep linking to creds #407)
  • Added ability to deep link directly to credential configuration
  • Implemented URL parameter support using cred=[apiName] or cred=[id]
  • Enabled direct access to new credential modal or existing credential editing
  • Improved workflow for managing API connections

Documentation & Developer Experience

  • Local Development Instructions: Enhanced clarity and structure of setup documentation
  • Added detailed steps for repository cloning
  • Improved environment variables setup instructions
  • Added git submodules initialization guidance
  • Included clear application startup procedures
  • Added optional steps for faster startup and database tool installation

DevOps & Infrastructure

  • Docker Optimization: Streamlined application container setup (chore: remove outdated Docker entrypoint script #404)
  • Removed unnecessary update_ui_env.sh script from Dockerfile
  • Updated ENTRYPOINT configuration to use default CMD for application startup
  • Simplified container initialization process
  • Native PostgreSQL Vector Integration (Feeature/aai vector postgres #401, AAIO-5)
  • Added native Postgres/pgvector integration with automatic setup
  • Created new AAIPostgres vector store node for Flowise
  • Included helper scripts for pgvector installation and diagnostics
  • Swapped Postgres image to pgvector/pgvector:pg16 in docker-compose files
  • Added database migration to auto-enable pgvector where possible
  • Updated deployment instructions for multi-environment support
  • Enhanced Redis configuration options for better scalability
  • Implemented out-of-the-box deduplication, embeddings, and metadata filtering

Features

  • Multi-Tenant Template System (feat: implement organization-scoped custom templates #403, AAI-487)
  • Implemented organization-scoped templates with proper sharing controls
  • Added template lineage tracking with parent-child relationships
  • Introduced Answer Agent framework detection for better categorization
  • Created dedicated organization templates tab in UI
  • Added template sharing toggle for organization members
  • Improved template export with enhanced metadata handling

Security

  • Critical Security Enhancements (feat: implement organization-scoped custom templates #403)
  • Implemented mandatory authentication for all marketplace endpoints
  • Added proper ownership validation and role-based access controls
  • Fixed authorization logic in chatflow deletion
  • Removed vulnerable API routes
  • Added transaction safety to critical operations
  • Improved data integrity with soft delete implementation

Content

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.

Copilot Autofix

AI about 1 year ago

The best way to fix this problem is to apply a rate limiting middleware to the sensitive route(s) – in this case, the DELETE route at /:id. This can be done by installing and importing the popular express-rate-limit package, defining a rate limiter (for example, limiting to 10 DELETE requests per 15 minutes per IP), and applying it to the DELETE route.

To implement this:

  • Add an import for express-rate-limit at the top of the file.
  • Define a rate limiter instance, e.g., const deleteLimiter = rateLimit({...}).
  • Apply this rate limiter as middleware to the DELETE route.
  • Only edit the shown code in packages/server/src/routes/chatflows/index.ts.

Suggested changeset 1
packages/server/src/routes/chatflows/index.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/server/src/routes/chatflows/index.ts b/packages/server/src/routes/chatflows/index.ts
--- a/packages/server/src/routes/chatflows/index.ts
+++ b/packages/server/src/routes/chatflows/index.ts
@@ -1,6 +1,7 @@
 import express from 'express'
 import chatflowsController from '../../controllers/chatflows'
 import enforceAbility from '../../middlewares/authentication/enforceAbility'
+import rateLimit from 'express-rate-limit'
 const router = express.Router()
 
 // CREATE
@@ -16,6 +17,17 @@
 router.put(['/', '/:id'], enforceAbility('ChatFlow'), chatflowsController.updateChatflow)
 
 // DELETE
-router.delete('/:id', enforceAbility('ChatFlow'), chatflowsController.deleteChatflow)
+// DELETE route replaced below with rate limiter
 
+
 export default router
+
+// Rate limiter for DELETE requests (10 per 15 minutes per IP)
+const deleteLimiter = rateLimit({
+    windowMs: 15 * 60 * 1000, // 15 minutes
+    max: 10, // limit each IP to 10 delete requests per windowMs
+    message: 'Too many delete requests from this IP, please try again later.'
+})
+
+// Re-define DELETE route with rate limiter
+router.delete('/:id', deleteLimiter, enforceAbility('ChatFlow'), chatflowsController.deleteChatflow)
EOF
@@ -1,6 +1,7 @@
import express from 'express'
import chatflowsController from '../../controllers/chatflows'
import enforceAbility from '../../middlewares/authentication/enforceAbility'
import rateLimit from 'express-rate-limit'
const router = express.Router()

// CREATE
@@ -16,6 +17,17 @@
router.put(['/', '/:id'], enforceAbility('ChatFlow'), chatflowsController.updateChatflow)

// DELETE
router.delete('/:id', enforceAbility('ChatFlow'), chatflowsController.deleteChatflow)
// DELETE route replaced below with rate limiter


export default router

// Rate limiter for DELETE requests (10 per 15 minutes per IP)
const deleteLimiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 10, // limit each IP to 10 delete requests per windowMs
message: 'Too many delete requests from this IP, please try again later.'
})

// Re-define DELETE route with rate limiter
router.delete('/:id', deleteLimiter, enforceAbility('ChatFlow'), chatflowsController.deleteChatflow)
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
router.get('/templates', marketplacesController.getAllTemplates)
router.get('/templates/:id', marketplacesController.getMarketplaceTemplate)

router.post('/custom', enforceAbility('CustomTemplate'), marketplacesController.saveCustomTemplate)
// READ - Custom templates (req authentication)
router.get('/custom', enforceAbility('Marketplace'), marketplacesController.getAllCustomTemplates)

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.

Copilot Autofix

AI about 1 year ago

To fix this problem, we should add rate-limiting middleware to the affected route (and optionally to other routes handling sensitive or expensive operations). The most common and robust approach in Express is to use the express-rate-limit package. Specifically, we should:

  • Import express-rate-limit at the beginning of the file.
  • Define a rate limiter instance (e.g., allowing 100 requests per 15 minutes per IP).
  • Plug the rate limiter into the /custom route (and optionally similar routes) by inserting it between the route path and the controller.
  • Only edit the code within the file shown, adding the import and the necessary rate limiter setup within this file.

Suggested changeset 1
packages/server/src/routes/marketplaces/index.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/server/src/routes/marketplaces/index.ts b/packages/server/src/routes/marketplaces/index.ts
--- a/packages/server/src/routes/marketplaces/index.ts
+++ b/packages/server/src/routes/marketplaces/index.ts
@@ -1,14 +1,23 @@
 import express from 'express'
 import marketplacesController from '../../controllers/marketplaces'
 import enforceAbility from '../../middlewares/authentication/enforceAbility'
+import rateLimit from 'express-rate-limit'
 const router = express.Router()
 
+// Rate limiter for sensitive routes
+const customTemplatesLimiter = rateLimit({
+  windowMs: 15 * 60 * 1000, // 15 minutes
+  max: 100, // limit each IP to 100 requests per windowMs
+  standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
+  legacyHeaders: false, // Disable the `X-RateLimit-*` headers
+})
+
 // READ - Templates del marketplace (public)
 router.get('/templates', marketplacesController.getAllTemplates)
 router.get('/templates/:id', marketplacesController.getMarketplaceTemplate)
 
 // READ - Custom templates (req authentication)
-router.get('/custom', enforceAbility('Marketplace'), marketplacesController.getAllCustomTemplates)
+router.get('/custom', customTemplatesLimiter, enforceAbility('Marketplace'), marketplacesController.getAllCustomTemplates)
 
 // 🆕 Add - Organization templates
 router.get('/organization', enforceAbility('Marketplace'), marketplacesController.getOrganizationTemplates)
EOF
@@ -1,14 +1,23 @@
import express from 'express'
import marketplacesController from '../../controllers/marketplaces'
import enforceAbility from '../../middlewares/authentication/enforceAbility'
import rateLimit from 'express-rate-limit'
const router = express.Router()

// Rate limiter for sensitive routes
const customTemplatesLimiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // limit each IP to 100 requests per windowMs
standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
legacyHeaders: false, // Disable the `X-RateLimit-*` headers
})

// READ - Templates del marketplace (public)
router.get('/templates', marketplacesController.getAllTemplates)
router.get('/templates/:id', marketplacesController.getMarketplaceTemplate)

// READ - Custom templates (req authentication)
router.get('/custom', enforceAbility('Marketplace'), marketplacesController.getAllCustomTemplates)
router.get('/custom', customTemplatesLimiter, enforceAbility('Marketplace'), marketplacesController.getAllCustomTemplates)

// 🆕 Add - Organization templates
router.get('/organization', enforceAbility('Marketplace'), marketplacesController.getOrganizationTemplates)
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
// READ
router.get('/custom', marketplacesController.getAllCustomTemplates)
// 🆕 Add - Organization templates
router.get('/organization', enforceAbility('Marketplace'), marketplacesController.getOrganizationTemplates)

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.

Copilot Autofix

AI about 1 year ago

To fix this issue, we should add a rate-limiting middleware to the /organization route (and, ideally, to all routes performing expensive operations unless rate limiting is already handled at a higher level). The best way is to use the express-rate-limit package, which is a well-maintained and widely used library for Express applications. We will import and configure the rate limiter and apply it specifically to the /organization route in this file. This approach avoids altering existing route logic or interfering with authentication/authorization functionality. The changes should be made at the top of the file for imports and just before the /organization route definition for the middleware application.


Suggested changeset 1
packages/server/src/routes/marketplaces/index.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/server/src/routes/marketplaces/index.ts b/packages/server/src/routes/marketplaces/index.ts
--- a/packages/server/src/routes/marketplaces/index.ts
+++ b/packages/server/src/routes/marketplaces/index.ts
@@ -1,6 +1,7 @@
 import express from 'express'
 import marketplacesController from '../../controllers/marketplaces'
 import enforceAbility from '../../middlewares/authentication/enforceAbility'
+import rateLimit from 'express-rate-limit'
 const router = express.Router()
 
 // READ - Templates del marketplace (public)
@@ -11,7 +12,12 @@
 router.get('/custom', enforceAbility('Marketplace'), marketplacesController.getAllCustomTemplates)
 
 // 🆕 Add - Organization templates
-router.get('/organization', enforceAbility('Marketplace'), marketplacesController.getOrganizationTemplates)
+router.get(
+  '/organization',
+  organizationRateLimiter,
+  enforceAbility('Marketplace'),
+  marketplacesController.getOrganizationTemplates
+)
 // CREATE - Create custom template
 router.post('/custom', enforceAbility('Marketplace'), marketplacesController.saveCustomTemplate)
 
EOF
@@ -1,6 +1,7 @@
import express from 'express'
import marketplacesController from '../../controllers/marketplaces'
import enforceAbility from '../../middlewares/authentication/enforceAbility'
import rateLimit from 'express-rate-limit'
const router = express.Router()

// READ - Templates del marketplace (public)
@@ -11,7 +12,12 @@
router.get('/custom', enforceAbility('Marketplace'), marketplacesController.getAllCustomTemplates)

// 🆕 Add - Organization templates
router.get('/organization', enforceAbility('Marketplace'), marketplacesController.getOrganizationTemplates)
router.get(
'/organization',
organizationRateLimiter,
enforceAbility('Marketplace'),
marketplacesController.getOrganizationTemplates
)
// CREATE - Create custom template
router.post('/custom', enforceAbility('Marketplace'), marketplacesController.saveCustomTemplate)

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
// 🆕 Add - Organization templates
router.get('/organization', enforceAbility('Marketplace'), marketplacesController.getOrganizationTemplates)
// CREATE - Create custom template
router.post('/custom', enforceAbility('Marketplace'), marketplacesController.saveCustomTemplate)

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.

Copilot Autofix

AI about 1 year ago

To address this issue, we will implement rate limiting for the /custom route using the express-rate-limit package. This ensures that the creation of custom templates is protected against excessive requests. Specifically:

  1. Import the express-rate-limit package.
  2. Configure a rate limiter middleware with an appropriate maximum number of requests and time window.
  3. Apply the rate limiter to the specific /custom route to limit the requests.

The fix will not alter the existing functionality of the route, as it only adds a middleware.


Suggested changeset 1
packages/server/src/routes/marketplaces/index.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/server/src/routes/marketplaces/index.ts b/packages/server/src/routes/marketplaces/index.ts
--- a/packages/server/src/routes/marketplaces/index.ts
+++ b/packages/server/src/routes/marketplaces/index.ts
@@ -1,8 +1,14 @@
 import express from 'express'
 import marketplacesController from '../../controllers/marketplaces'
 import enforceAbility from '../../middlewares/authentication/enforceAbility'
+import rateLimit from 'express-rate-limit'
 const router = express.Router()
 
+const customTemplateRateLimiter = rateLimit({
+  windowMs: 15 * 60 * 1000, // 15 minutes
+  max: 100, // Limit each IP to 100 requests per windowMs
+})
+
 // READ - Templates del marketplace (public)
 router.get('/templates', marketplacesController.getAllTemplates)
 router.get('/templates/:id', marketplacesController.getMarketplaceTemplate)
@@ -13,7 +17,7 @@
 // 🆕 Add - Organization templates
 router.get('/organization', enforceAbility('Marketplace'), marketplacesController.getOrganizationTemplates)
 // CREATE - Create custom template
-router.post('/custom', enforceAbility('Marketplace'), marketplacesController.saveCustomTemplate)
+router.post('/custom', customTemplateRateLimiter, enforceAbility('Marketplace'), marketplacesController.saveCustomTemplate)
 
 // DELETE - Delete custom template
 router.delete('/custom/:id', enforceAbility('Marketplace'), marketplacesController.deleteCustomTemplate)
EOF
@@ -1,8 +1,14 @@
import express from 'express'
import marketplacesController from '../../controllers/marketplaces'
import enforceAbility from '../../middlewares/authentication/enforceAbility'
import rateLimit from 'express-rate-limit'
const router = express.Router()

const customTemplateRateLimiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // Limit each IP to 100 requests per windowMs
})

// READ - Templates del marketplace (public)
router.get('/templates', marketplacesController.getAllTemplates)
router.get('/templates/:id', marketplacesController.getMarketplaceTemplate)
@@ -13,7 +17,7 @@
// 🆕 Add - Organization templates
router.get('/organization', enforceAbility('Marketplace'), marketplacesController.getOrganizationTemplates)
// CREATE - Create custom template
router.post('/custom', enforceAbility('Marketplace'), marketplacesController.saveCustomTemplate)
router.post('/custom', customTemplateRateLimiter, enforceAbility('Marketplace'), marketplacesController.saveCustomTemplate)

// DELETE - Delete custom template
router.delete('/custom/:id', enforceAbility('Marketplace'), marketplacesController.deleteCustomTemplate)
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
// DELETE
router.delete(['/', '/custom/:id'], marketplacesController.deleteCustomTemplate)
// DELETE - Delete custom template
router.delete('/custom/:id', enforceAbility('Marketplace'), marketplacesController.deleteCustomTemplate)

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.

Copilot Autofix

AI about 1 year ago

To fix the problem, we need to add a rate-limiting middleware to the DELETE /custom/:id route. The best way to do this is to use a well-known package, such as express-rate-limit. We should import the package at the top of the file, define a suitable rate limiter instance (e.g., limit to 10 deletes per 15 minutes per IP), and apply it to the route in question. The fix should be made in packages/server/src/routes/marketplaces/index.ts:

  • Add the import for express-rate-limit.
  • Define a rate limiter instance.
  • Add the rate limiter as a middleware to the route on line 19 (router.delete(...)).
    No changes to controller logic or existing authentication middleware are needed.

Suggested changeset 1
packages/server/src/routes/marketplaces/index.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/server/src/routes/marketplaces/index.ts b/packages/server/src/routes/marketplaces/index.ts
--- a/packages/server/src/routes/marketplaces/index.ts
+++ b/packages/server/src/routes/marketplaces/index.ts
@@ -1,8 +1,16 @@
 import express from 'express'
 import marketplacesController from '../../controllers/marketplaces'
 import enforceAbility from '../../middlewares/authentication/enforceAbility'
+import rateLimit from 'express-rate-limit'
 const router = express.Router()
 
+// Limit DELETE requests to 10 per 15 minutes per IP
+const deleteLimiter = rateLimit({
+  windowMs: 15 * 60 * 1000, // 15 minutes
+ max: 10, // limit each IP to 10 delete requests per windowMs
+ standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
+ legacyHeaders: false, // Disable the `X-RateLimit-*` headers
+})
 // READ - Templates del marketplace (public)
 router.get('/templates', marketplacesController.getAllTemplates)
 router.get('/templates/:id', marketplacesController.getMarketplaceTemplate)
@@ -16,6 +22,6 @@
 router.post('/custom', enforceAbility('Marketplace'), marketplacesController.saveCustomTemplate)
 
 // DELETE - Delete custom template
-router.delete('/custom/:id', enforceAbility('Marketplace'), marketplacesController.deleteCustomTemplate)
+router.delete('/custom/:id', enforceAbility('Marketplace'), deleteLimiter, marketplacesController.deleteCustomTemplate)
 
 export default router
EOF
@@ -1,8 +1,16 @@
import express from 'express'
import marketplacesController from '../../controllers/marketplaces'
import enforceAbility from '../../middlewares/authentication/enforceAbility'
import rateLimit from 'express-rate-limit'
const router = express.Router()

// Limit DELETE requests to 10 per 15 minutes per IP
const deleteLimiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 10, // limit each IP to 10 delete requests per windowMs
standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
legacyHeaders: false, // Disable the `X-RateLimit-*` headers
})
// READ - Templates del marketplace (public)
router.get('/templates', marketplacesController.getAllTemplates)
router.get('/templates/:id', marketplacesController.getMarketplaceTemplate)
@@ -16,6 +22,6 @@
router.post('/custom', enforceAbility('Marketplace'), marketplacesController.saveCustomTemplate)

// DELETE - Delete custom template
router.delete('/custom/:id', enforceAbility('Marketplace'), marketplacesController.deleteCustomTemplate)
router.delete('/custom/:id', enforceAbility('Marketplace'), deleteLimiter, marketplacesController.deleteCustomTemplate)

export default router
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@vercel

vercel Bot commented Jul 21, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
answerai-docs ✅ Ready (Inspect) Visit Preview Jul 21, 2025 5:24pm
the-answerai ✅ Ready (Inspect) Visit Preview Jul 21, 2025 5:24pm

passport.authenticate('salesforce-dynamic', { failureRedirect: '/' }),
salesforceAuthController.salesforceAuthCallback
)
router.get('/', salesforceAuthController.authenticate)

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.

Copilot Autofix

AI about 1 year ago

To address the missing rate limiting on the / route, a rate-limiting middleware should be applied to this route within packages/server/src/routes/salesforce-auth/index.ts. The best practice is to use a well-known and maintained package such as express-rate-limit. Since the codebase uses TypeScript and ES module-style imports, and only changes within the shown file are allowed, the fix involves:

  1. Importing express-rate-limit.
  2. Creating a rate limiter instance with reasonable defaults (e.g., 100 requests per 15 minutes).
  3. Applying the rate limiter specifically to the / route by passing it as middleware to router.get('/', ...).

All changes are to be made within packages/server/src/routes/salesforce-auth/index.ts.


Suggested changeset 1
packages/server/src/routes/salesforce-auth/index.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/server/src/routes/salesforce-auth/index.ts b/packages/server/src/routes/salesforce-auth/index.ts
--- a/packages/server/src/routes/salesforce-auth/index.ts
+++ b/packages/server/src/routes/salesforce-auth/index.ts
@@ -1,11 +1,20 @@
 /* eslint-disable no-console */
 import express from 'express'
 import salesforceAuthController from '../../controllers/salesforce-auth'
+import rateLimit from 'express-rate-limit'
 import passport from 'passport'
 
 const router = express.Router()
 
-router.get('/', salesforceAuthController.authenticate)
+// Rate limiter: max 100 requests per 15 minutes per IP for auth endpoint
+const authRateLimiter = rateLimit({
+    windowMs: 15 * 60 * 1000, // 15 minutes
+    max: 100, // limit each IP to 100 requests per windowMs
+    standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
+    legacyHeaders: false, // Disable the `X-RateLimit-*` headers
+})
+
+router.get('/', authRateLimiter, salesforceAuthController.authenticate)
 router.get('/error', (req, res) => {
     const messages = (req.session as any)?.messages || []
     const errorMessage = messages.length > 0 ? messages[messages.length - 1] : req.query.error
EOF
@@ -1,11 +1,20 @@
/* eslint-disable no-console */
import express from 'express'
import salesforceAuthController from '../../controllers/salesforce-auth'
import rateLimit from 'express-rate-limit'
import passport from 'passport'

const router = express.Router()

router.get('/', salesforceAuthController.authenticate)
// Rate limiter: max 100 requests per 15 minutes per IP for auth endpoint
const authRateLimiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // limit each IP to 100 requests per windowMs
standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
legacyHeaders: false, // Disable the `X-RateLimit-*` headers
})

router.get('/', authRateLimiter, salesforceAuthController.authenticate)
router.get('/error', (req, res) => {
const messages = (req.session as any)?.messages || []
const errorMessage = messages.length > 0 ? messages[messages.length - 1] : req.query.error
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +14 to +28
router.get('/callback', (req, res, next) => {
passport.authenticate('salesforce-dynamic', (err: any, user: any, info: any) => {
console.log('Error:', err)
console.log('User:', user)
console.log('Info:', info)

if (err || !user) {
const errorMsg = err?.message || info?.message || 'Authentication failed'
return res.redirect(`/api/v1/salesforce-auth/error?error=${encodeURIComponent(errorMsg)}`)
}

req.user = user
salesforceAuthController.salesforceAuthCallback(req, res)
})(req, res, next)
})

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.
diecoscai and others added 11 commits July 25, 2025 14:55
- Fix JSX element return in homepage component
- Remove path restriction from redirect hook
- Add timeout protection and enhanced error handling
- Ensure all error scenarios fallback to /chat

Resolves AAI-489
- Fix JSX element return in homepage component
- Remove path restriction from redirect hook
- Add timeout protection and enhanced error handling
- Update related page components for consistency
- Ensure all error scenarios fallback to /chat

Resolves AAI-489
…rovements

This comprehensive update addresses GitHub issue #391 and Jira ticket AAI-487 by implementing multi-tenant template management with proper organization scoping and critical security fixes.

## 🆕 New Features

### Multi-Tenant Template System
- **Organization Scoping**: Templates now belong to specific organizations
- **Template Sharing**: Option to share templates within organization
- **Template Lineage**: Track parent-child relationships and template origins
- **Answer Agent Framework**: Added support for Answer Agent framework detection

### Enhanced UI Experience
- **Organization Templates Tab**: New tab showing organization-shared templates
- **Template Segregation**: Answer Agent templates filtered from Example Templates
- **Share Toggle**: UI option to share templates with organization members
- **Improved Template Export**: Better framework detection and metadata handling

## 🔧 Database Schema Updates

### New Migrations
- `AddOrganizationToCustomTemplate`: Adds organization and user scoping
- `AddParentIdToCustomTemplate`: Enables template lineage tracking
- `AddTemplateIdToChatFlow`: Links chatflows to their template origins

### Enhanced Entities
- **CustomTemplate**: Added userId, organizationId, shareWithOrg, parentId fields
- **ChatFlow**: Added templateId field for template tracking
- **Soft Delete**: Implemented for data integrity and audit trails

## 🛡️ Critical Security Fixes

### Authentication & Authorization
- **Mandatory Authentication**: All marketplace endpoints now require authentication
- **Ownership Validation**: Proper user/organization ownership checks
- **Permission System**: Role-based access control for templates

### Chatflow Deletion Security
- **Authorization Logic**: Fixed flawed permission checking in deleteChatflow
- **Route Security**: Removed vulnerable DELETE pattern allowing deletion without ID
- **Transaction Safety**: Wrapped deletion operations in database transactions

### Migration Resilience
- **No-Organization Handling**: Migration handles environments without organizations
- **System Templates**: Orphaned templates become system-wide instead of failing

## 🎯 API Improvements

### New Endpoints
- `GET /marketplaces/organization`: Retrieve organization-shared templates
- Enhanced marketplace endpoints with proper authentication middleware

### Enhanced Services
- **Template Service**: Improved filtering, validation, and framework detection
- **Chatflow Service**: Better authorization and cleanup procedures
- **Error Handling**: Consistent error responses and proper status codes

## 📊 Frontend Enhancements

### Template Management
- **Filtered Views**: Answer Agent templates excluded from Example Templates
- **Organization Tab**: Dedicated view for organization-shared templates
- **Enhanced Metadata**: Better template information display and searching

### User Experience
- **Template Sharing**: Easy organization sharing toggle
- **Framework Detection**: Automatic framework classification
- **Improved Navigation**: Better template organization and discovery

## 🔍 Technical Details

### Framework Detection
- Automatic detection of Answer Agent templates based on MCP Tools usage
- Enhanced framework categorization (Langchain, LlamaIndex, Answer Agent)
- Better template metadata extraction and processing

### Data Integrity
- Soft delete implementation across all related entities
- Proper cleanup of chatflow dependencies (messages, feedback, history)
- Transaction-safe operations with rollback capabilities

### Performance Optimizations
- Efficient query patterns with proper indexing
- Optimized filtering and search operations
- Reduced database roundtrips through better query design

## 🚀 New MCP Sidekick Templates
- Answer Agent MCP Sidekick
- BraveSearch MCP Sidekick
- Confluence MCP Sidekick
- Contentful MCP Sidekick
- Jira MCP Sidekick
- PostgreSQL MCP Sidekick
- Salesforce MCP Sidekick
- Slack MCP Sidekick
- YouTube MCP Sidekick

Fixes: #391
Jira: AAI-487
- Fixed orphaned object literals after commented console.log statements
- Properly commented out object properties in MarketplaceCanvas.jsx
- Properly commented out object properties in MarketplaceLanding.jsx
- Properly commented out object properties in canvas/index.jsx
- Resolves build errors while preserving debug information for future use
- Enhance clarity and structure of local development instructions
- Add steps for cloning the repository, setting up environment variables, initializing git submodules, and running the application
- Include optional steps for faster startup and database tool installation
- Add step for installing Docker Desktop and ensuring it is running
- Reorder steps for clarity, including building and migrating the initial database
- Update instructions for running the application and accessing it
- Enhance guidance for development with fast reload instructions
- Removed the `update_ui_env.sh` script from the Dockerfile as it is no longer needed for application startup.
- Updated the ENTRYPOINT to use the default CMD for starting the application.
prceasar and others added 5 commits July 25, 2025 15:06
* error handling in salesforce route

* some better logging

---------

Co-authored-by: Jaime Morales <jaime@lastrev.com>
- Removed empty PRODUCTION_URL from copilot._environment_.env.template
- Set NODE_ENV in Dockerfile to production using the correct syntax
- Added stickiness to the health check configuration in manifest.yml
- Introduced NUMBER_OF_PROXIES variable in manifest.yml
- Specified cookie domain in server index.ts for production environment
maxtechera
maxtechera previously approved these changes Jul 25, 2025

@maxtechera maxtechera left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@maxtechera maxtechera left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@maxtechera
maxtechera merged commit 6ef48e4 into production Jul 25, 2025
15 of 17 checks passed
@maxtechera
maxtechera temporarily deployed to staging - theanswer-iek0 July 25, 2025 18:56 — with Render Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants