Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed regular expressions to be able to handle prefixed pathes. #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

k-oliver
Copy link

Hi,
I'm using cosmo embedded in an OSGi enviroment where all servlets and filters are prefixed with pathes like /calendar. When using tickets the given path is used to find resources. This results in errors like this:
TicketedItemNotFoundException: Resource at /calendar/dav/item/99a0533b-0035-47f0-a6d1-acb96218811e not found

I tried different Spring solutions like adding Springs ForwardedHeaderFilter. But none worked because the finally the TicketProcessingFilter uses httpRequest.getPathInfo() which always gets the full path.

With this PR i suggest to make the path parsing using the resource pathes more tollerant by allowing prefixed pathes. This make tickets work again for me.

The regular expressions now can handle pathes like:
/something/item/...
/item/...
/another/user/...
/user
/any/prefix/path/collection/..

The regular expressions now can handle pathes like:
/something/item/...
/item/...
/another/user/...
/user
/any/prefix/path/collection/..
@danielgrigore
Copy link
Collaborator

Hi @k-oliver

I had a look at your comments and also checked our application.
(It is true that our application is not running in an OSGI environment)
I understand that you run your application in an OSGI environment and you have to prefix your contexts/servlets but in the example shown it seems that you have a different problem.
The path given as example is this one: /calendar/dav/item/99a0533b-0035-47f0-a6d1-acb96218811e

If I assume correctly :

  • /calendar is the application context
  • /dav is the servlet context
  • /item/99a0533b-0035-47f0-a6d1-acb96218811e is path info.

You say that you always get the full path in TicketProcessingFilter, but according to Servlet API the method getPathInfo from HttpServletRequest

Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string and will start with a "/" character.

How is it possible that you get the full path including application context and servlet context ?
What container/servlet version are you using ?

Thanks.

@k-oliver
Copy link
Author

Hi @danielgrigore ,
servlet context is /calendar/dav. I'm using Jetty 9.x with servlet 3.1.

@danielgrigore
Copy link
Collaborator

Hi @k-oliver

I modified the demo cosmo-webapp to use jetty (9.4.19) instead of tomcat and decreased the Servlet API version from 4.0.1 to 3.10.
Then I created a collection, an item and a ticket and tried to access the item using the newly generated ticket.
Everything worked fine. The curl command looked like
curl -i -XGET -H"Ticket: ..." http://localhost:8080/cosmo/dav/item/f12946ee-b50d-4c0b-96e5-3404bb82df5b

In your situation is it possible to use an incorrect URL for getting the event ? From your message it seems that the incorrect URL might be something like
http://localhost:8080/calendar/dav/calendar/dav/item/f12946ee-b50d-4c0b-96e5-3404bb82df5b
Cheers,

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.

2 participants