paultuckey / urlrewritefilter

A Java Web Filter with functionality like Apache's mod_rewrite
http://tuckey.org/urlrewrite/
Other
335 stars 144 forks source link

How to match jsessionid from URL ? #232

Open mevb opened 6 years ago

mevb commented 6 years ago

Hi Paul, hi people,

First of all big thanx for URLRewriteFilter... ...you really saved my time (my ass too) !

I use it from many years without any problem.

But now I am unable to achieve a rule to match requests URLs with a path part containing ";jsessionid=whatever".

I tried some test rules as : `

^(.*)(?:\;jsessionid=[A-Za-z0-9]+)(.*)$ null ` and ` ^(.*);jsessionid=[A-Za-z0-9]+)(.*)$ null ` , but it never works :( Im my web app request log I can see the jsessionid as : `HTTPS [serverIP] ([remoteHost]) [11/Oct/2018:17:28:41 +0100] ([userAgent]) "www.mydomain.com:443 GET /somepage.jsp;jsessionid=ABCDEFGHIJKL?lan=en HTTP/1.1" 3230 [200] ` Am I missing something ? I am using urlrewritefilter-4.0.3.jar with an oc4j servlet container. My webapp is compiled with jdk1.6.0_45 (for compatibility reasons) and running under jdk1.8.0_144. The webapp config has session cookies enabled as : ``` ... ... ``` I am stucked in and I will really appreciate some help, Cordially, Manuel
gasttor commented 6 years ago

Hi Manuel,

I tested your rule with version 4.0.3 und 5.0.0 on a tomcat8 and it works just fine for me. So IMO it could be a problem with your container-setup.

Have you tried to set the loglevel of class org.tuckey.web.filters.urlrewrite.RuleBase to DEBUG. Then you could find out, which exact URL is handled by the rule.

Regards

Thorsten

mevb commented 6 years ago

Hi Thorsten,

Thank you for your opinion.

Yes, I've tried logLevel sysout:DEBUG and no more infos about processed URLs.

For test request :

/somepage.jsp;jsessionid=ABCDEFGHIJKL?lan=en

and rule (the only one!) :

<rule> <from>^(.*);jsessionid=[A-Za-z0-9]+)(.*)$</from> <to>null</to> </rule>

I see URLRewriteFileter log as :

org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: starting conf reload check
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter INFO: conf file modified since last load, reloading
org.tuckey.web.filters.urlrewrite.Conf DEBUG: XML builder factory is: org.apache.crimson.jaxp.DocumentBuilderFactoryImpl
org.tuckey.web.filters.urlrewrite.Conf DEBUG: XML Parser: org.apache.crimson.jaxp.DocumentBuilderImpl
org.tuckey.web.filters.urlrewrite.Conf DEBUG: about to parse conf
org.tuckey.web.filters.urlrewrite.ConfHandler DEBUG: Resolving to DTD /org/tuckey/web/filters/urlrewrite/dtds/urlrewrite4.0.dtd
org.tuckey.web.filters.urlrewrite.Conf DEBUG: now initialising conf
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: loaded rule Rule 0 (^(.*)(?:\;jsessionid=[A-Za-z0-9]+)(.*)$, null 1)
org.tuckey.web.filters.urlrewrite.NormalRule DEBUG: loaded rule Rule 0 (^(.*)(?:\;jsessionid=[A-Za-z0-9]+)(.*)$, null 1)
org.tuckey.web.filters.urlrewrite.Conf DEBUG: conf status true
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: inited with 1 rules
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: conf is ok
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter INFO: loaded (conf ok)
org.tuckey.web.filters.urlrewrite.utils.ServerNameMatcher DEBUG: looking for hostname match on current server name www.mydomain.com
org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: processing request for /somepage.jsp
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Rule 0 run called with /somepage.jsp

No ";jsessionid" and no parameter ?!

I am still stucked and DEBUG didn't help me much.

One more thing, I've tried to see some infos from my Filter class MyFilter.java and I saw this output :

MyFilter.doFilter() : New session = ABCDEFGHIJKLM
MyFilter.doFilter() : request.isRequestedSessionIdValid() = false
MyFilter.doFilter() : request.isRequestedSessionIdFromURL() = false
MyFilter.doFilter() : request.isRequestedSessionIdFromCookie() = false

Does this make sense to someone ?

Thanks for your help

mevb commented 5 years ago

Hi Manuel,

I tested your rule with version 4.0.3 und 5.0.0 on a tomcat8 and it works just fine for me. So IMO it could be a problem with your container-setup.

Have you tried to set the loglevel of class org.tuckey.web.filters.urlrewrite.RuleBase to DEBUG. Then you could find out, which exact URL is handled by the rule.

Regards

Thorsten

How do you achieved your tests with urlrewritefilter "version 4.0.3 und 5.0.0 " as version 5.0.0 does not already exist, AFAIK ?

Regards,

Manuel

gasttor commented 5 years ago

Hi Manuel,

I built the master branch by myself and used this artefact. According to the pom.xml this is version 5.0.

But I agree that there is no official release of this version.

Regards

Thorsten