You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Krishnauprit18 (via GitHub)" <gi...@apache.org> on 2026/09/01 06:06:14 UTC

[PR] Improved: Align tenant resolution between LoginWorker and ContextFilter [ofbiz-framework]

Krishnauprit18 opened a new pull request, #1835:
URL: https://github.com/apache/ofbiz-framework/pull/1835

   `ContextFilter` and `LoginWorker` each resolve `userTenantId` for a request but use opposite precedence, and `ContextFilter` updates the session `delegatorName` in place when the resolved tenant changes. This makes the two consistent.
   
   - `LoginWorker.login(...)` now resolves `userTenantId` the same way
     `ContextFilter` already does: request attribute first, request parameter as
     fallback. Previously it read the parameter first, so the two could resolve
     different tenants for the same request.
   
   - `ContextFilter` now compares the tenant encoded in the session's existing
     `delegatorName` (`name#tenantId`) against the tenant resolved for the current
     request. When they differ it invalidates the session, so `dispatcher`,
     `security` and `userLogin` are rebuilt for the current tenant on the next
     request instead of `delegatorName` alone being overwritten. A warning is
     logged when this happens.
   
   No change for single-tenant deployments or when the session tenant and the request tenant already match.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improved: Align tenant resolution between LoginWorker and ContextFilter [ofbiz-framework]

Posted by "ashishvijaywargiya (via GitHub)" <gi...@apache.org>.
ashishvijaywargiya merged PR #1835:
URL: https://github.com/apache/ofbiz-framework/pull/1835


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improved: Align tenant resolution between LoginWorker and ContextFilter [ofbiz-framework]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #1835:
URL: https://github.com/apache/ofbiz-framework/pull/1835#discussion_r3901247980


##########
framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java:
##########
@@ -143,6 +143,24 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
                     tenantId = null;
                 }
                 if (UtilValidate.isNotEmpty(tenantId)) {
+                    // If the session already carries a delegatorName for a different tenant than
+                    // the one resolved for this request, invalidate it here rather than only
+                    // overwriting delegatorName below: dispatcher, security and userLogin stay
+                    // bound to the old tenant otherwise, so a clean session is rebuilt on the
+                    // next request instead.
+                    String existingDelegatorName = (String) httpRequest.getSession().getAttribute("delegatorName");
+                    if (UtilValidate.isNotEmpty(existingDelegatorName)) {
+                        int hashIndex = existingDelegatorName.indexOf('#');
+                        String existingTenantId = hashIndex > 0 ? existingDelegatorName.substring(hashIndex + 1).trim() : null;
+                        if (existingTenantId != null && !tenantId.equals(existingTenantId)) {
+                            Debug.logWarning("Session was established under tenant [" + existingTenantId
+                                    + "] but this request resolved tenant [" + tenantId + "] for host [" + serverName
+                                    + "]; invalidating the session rather than continuing with a mismatched tenant context",
+                                    MODULE);
+                            httpRequest.getSession().invalidate();
+                        }
+                    }

Review Comment:
   `httpRequest.getSession()` here will create a new session for requests that otherwise wouldn’t have one (and can even create+invalidate a brand-new session). That can increase session churn and resource usage. Use `getSession(false)` when reading/invalidating an existing session, and only create a session later when you actually need to set `delegatorName`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Improved: Align tenant resolution between LoginWorker and ContextFilter [ofbiz-framework]

Posted by "golja (via GitHub) via notifications" <no...@ofbiz.apache.org>.
golja commented on PR #1835:
URL: https://github.com/apache/ofbiz-framework/pull/1835#issuecomment-6637661289

   CVE-2026-84728


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org