You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Lars Törner <la...@gmail.com> on 2016/10/14 12:48:06 UTC

Bookmarkable link doesn't become a https link

Hi,

we had a problem where a bookmarkable link didn't become a https link.

I found this:
https://cwiki.apache.org/confluence/display/WICKET/How+to+switch+to+SSL+mode

Which, with a warning,  states:

 "It is extemtely important that when setting the rootRequestMapper it is
done AFTER you have added any bookmarkable links otherwise they will not be
switched over to Secure mode."

I found that we in our Application.init() did the opposite, i.e. set the
rootRequestMapper before the page mounting. Problem solved, I thought.

Instead the problem was that the page wasn't mounted at all, and the only
thing that worked was to mount the page and keep the order we had, which,
according to the link and the warning above is bound to fail.

Please, can anyone tell me what I'm missing here?

Wicket version: 6.22.

Cheers
Lars

Re: Bookmarkable link doesn't become a https link

Posted by Lars Törner <la...@gmail.com>.
Hi Martin and thanks for your answer!

I think that what you say is that the documentation I found is correct.
  "It is extremely important that when setting the rootRequestMapper it
is done AFTER you have added any bookmarkable links otherwise they will not
be switched over to Secure mode".

I also understand why it's implemented like this. What I don't understand
is why it's now working in our code when we're mounting the bookmarkable
page after setting the requestmapper. I guess we have to take a deeper look
into it.

Once again, thank you for your effort!

Lars


lördag 15 oktober 2016 skrev Martin Grigorov <mg...@apache.org>:

> Hi Lars,
>
>
> mountPage("page2", Page2.class);
> setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new
> HttpsConfig(8080, 8443)));
> mountPage("page3", Page3.class);
>
> Now if I am at Page1 (http://localhost:8080/page1) and there I have
> add(new BookmarkablePageLink<Void>("page2", Page2.class));
> then the generated url is https://localhost:8443/page2 because the
> HttpsMapper wraps the old root mapper that knows about Page2.
>
> HttpsMapper doesn't
> implement org.apache.wicket.request.mapper.ICompoundRequestMapper so when
> mountPage(page3) is called Wicket creates a
> new org.apache.wicket.request.mapper.CompoundRequestMapper that adds the
> current root mapper (HttpsMapper) at position 1 and a MountedMapper for
> Page3 at position 2. So requests to Page3 are not handled by HttpsMapper
> and the generated urls are HTTP, not HTTPS.
>
> HttpsMapper intentionally doesn't implement ICompoundRequestMapper exactly
> for this reason - to make it possible to configure pages which should never
> be secured.
>
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Fri, Oct 14, 2016 at 2:48 PM, Lars Törner <lars.torner@gmail.com
> <javascript:;>> wrote:
>
> > Hi,
> >
> > we had a problem where a bookmarkable link didn't become a https link.
> >
> > I found this:
> > https://cwiki.apache.org/confluence/display/WICKET/How+
> > to+switch+to+SSL+mode
> >
> > Which, with a warning,  states:
> >
> >  "It is extemtely important that when setting the rootRequestMapper it is
> > done AFTER you have added any bookmarkable links otherwise they will not
> be
> > switched over to Secure mode."
> >
> > I found that we in our Application.init() did the opposite, i.e. set the
> > rootRequestMapper before the page mounting. Problem solved, I thought.
> >
> > Instead the problem was that the page wasn't mounted at all, and the only
> > thing that worked was to mount the page and keep the order we had, which,
> > according to the link and the warning above is bound to fail.
> >
> > Please, can anyone tell me what I'm missing here?
> >
> > Wicket version: 6.22.
> >
> > Cheers
> > Lars
> >
>

Re: Bookmarkable link doesn't become a https link

Posted by Martin Grigorov <mg...@apache.org>.
Hi Lars,


mountPage("page2", Page2.class);
setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new
HttpsConfig(8080, 8443)));
mountPage("page3", Page3.class);

Now if I am at Page1 (http://localhost:8080/page1) and there I have
add(new BookmarkablePageLink<Void>("page2", Page2.class));
then the generated url is https://localhost:8443/page2 because the
HttpsMapper wraps the old root mapper that knows about Page2.

HttpsMapper doesn't
implement org.apache.wicket.request.mapper.ICompoundRequestMapper so when
mountPage(page3) is called Wicket creates a
new org.apache.wicket.request.mapper.CompoundRequestMapper that adds the
current root mapper (HttpsMapper) at position 1 and a MountedMapper for
Page3 at position 2. So requests to Page3 are not handled by HttpsMapper
and the generated urls are HTTP, not HTTPS.

HttpsMapper intentionally doesn't implement ICompoundRequestMapper exactly
for this reason - to make it possible to configure pages which should never
be secured.


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Fri, Oct 14, 2016 at 2:48 PM, Lars Törner <la...@gmail.com> wrote:

> Hi,
>
> we had a problem where a bookmarkable link didn't become a https link.
>
> I found this:
> https://cwiki.apache.org/confluence/display/WICKET/How+
> to+switch+to+SSL+mode
>
> Which, with a warning,  states:
>
>  "It is extemtely important that when setting the rootRequestMapper it is
> done AFTER you have added any bookmarkable links otherwise they will not be
> switched over to Secure mode."
>
> I found that we in our Application.init() did the opposite, i.e. set the
> rootRequestMapper before the page mounting. Problem solved, I thought.
>
> Instead the problem was that the page wasn't mounted at all, and the only
> thing that worked was to mount the page and keep the order we had, which,
> according to the link and the warning above is bound to fail.
>
> Please, can anyone tell me what I'm missing here?
>
> Wicket version: 6.22.
>
> Cheers
> Lars
>