From 956761ee76eeee93bcf533cb345402fdd5a52481 Mon Sep 17 00:00:00 2001 From: sadilchamishka Date: Sun, 29 Oct 2023 16:26:15 +0530 Subject: [PATCH] Improve tenant context rewrite regex patterns --- .../identity/context/rewrite/bean/RewriteContext.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/org.wso2.carbon.identity.context.rewrite.valve/src/main/java/org/wso2/carbon/identity/context/rewrite/bean/RewriteContext.java b/components/org.wso2.carbon.identity.context.rewrite.valve/src/main/java/org/wso2/carbon/identity/context/rewrite/bean/RewriteContext.java index d0ec0f41..31babb4c 100644 --- a/components/org.wso2.carbon.identity.context.rewrite.valve/src/main/java/org/wso2/carbon/identity/context/rewrite/bean/RewriteContext.java +++ b/components/org.wso2.carbon.identity.context.rewrite.valve/src/main/java/org/wso2/carbon/identity/context/rewrite/bean/RewriteContext.java @@ -29,11 +29,16 @@ public class RewriteContext { private Pattern baseContextPattern; + private static final String CONSOLE_CONTEXT = "/console/"; + public RewriteContext(boolean isWebApp, String context) { this.isWebApp = isWebApp; this.context = context; - this.tenantContextPattern = Pattern.compile("^/t/([^/]+(?:/o)?)" + context); + this.tenantContextPattern = this.isWebApp ? CONSOLE_CONTEXT.equals(context) + ? Pattern.compile("^/t/([^/]+)(/o|/o/([^/]+))?" + context) + : Pattern.compile("^/t/([^/]+)(/o)?" + context) + : Pattern.compile("^/t/([^/]+)" + context); this.baseContextPattern = Pattern.compile("^" + context); }