0

How to secure included pages with Spring Security 2.0.3

asked 2008-07-30 07:42:07 +0800

okgago gravatar image okgago
99

Hi all,

I am using ZK 3.0.6 and trying to secure my pages with Spring Security 2.0.3.

Here's my security scenario:

I want to a specific page (named XXX.zul) to be accessed only by administrators (ROLE_ADMIN). And the rest of the pages will be accessed by all users (ROLE_USER).

To achieve this, I make the configuration (security.xml) as follows:

<sec:http auto-config="true">
	<sec:intercept-url pattern="/XXX.zul" access="ROLE_ADMIN" />
	<sec:intercept-url pattern="/**" access="ROLE_USER" />
	<sec:http-basic />
</sec:http>


If I call the specific page (XXX.zul) directly (i.e. http://<host>:<port>/<contextRoot>/XXX.zul), everything works fine and an ordinary user (ROLE_USER) cannot access the page.

However, if I embed the same page in an include component (in another page, say YYY.zul), the security does not work. Here's the YYY.zul page:
<window title="Another Page">
	<include src="/XXX.zul" />
</window>


So if I call this other page (YYY.zul) with an ordinary user (ROLE_USER), I can see the contents of XXX.zul (of course within the YYY.zul page).

How can I overcome this issue?

Thanks

delete flag offensive retag edit

13 Replies

Sort by ยป oldest newest

answered 2008-07-30 14:14:24 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Check if you config web.xml properly so the servlet include pass thru your SpingSecurity filter.

link publish delete flag offensive edit

answered 2008-07-30 15:06:50 +0800

okgago gravatar image okgago
99

Hey Henrichen,

Actually my Spring Security configuration is fine. I don't have any problems if I call the pages directly (e.g. if page XXX.zul is only visible to ROLE_ADMIN it is so. A user with a different role -like ROLE_USER- cannot access that page).

However if I include the very same page (XXX.zul) in another page (YYY.zul) by using the <include> tag, the authorization settings for the included page does not work any more (i.e. although a user with the ROLE_USER should not access the page -XXX.zul- he can see it by calling YYY.zul).

I don't know if I could explain it properly.

Thanks

link publish delete flag offensive edit

answered 2008-07-30 21:38:36 +0800

sousa1981 gravatar image sousa1981
573 4

updated 2008-07-30 21:38:52 +0800

Hi,

I think it will not work with include!!! ZK use event based like desktop not traditional url based like jsp, etc.

Well, let's hear other contribuitors.

link publish delete flag offensive edit

answered 2008-07-31 06:39:07 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

zk <include> component go thru the same servlet include mechanism. Did you specify

<dispatcher>INCLUDE</dispatcher>

in your security filter-mapping in web.xml?

link publish delete flag offensive edit

answered 2008-07-31 15:19:40 +0800

okgago gravatar image okgago
99

Hi Henrichen,

Sorry that I couldn't get what you meant in your previous post.

I have added the INCLUDE dispatcher in my filter configuration but it had no effect.

<filter-mapping>
	<filter-name>springSecurityFilterChain</filter-name>
	<url-pattern>/*</url-pattern>
	<dispatcher>REQUEST</dispatcher>
	<dispatcher>INCLUDE</dispatcher>
	<dispatcher>FORWARD</dispatcher>
</filter-mapping>

link publish delete flag offensive edit

answered 2008-08-01 01:15:36 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Check first if the included page request pass thru your filter. Can you "println" something in the filter to prove or disprove it?
If not passed, then we shall check the ZK <include> component. If yes, then it is something more complicated related to ZK + Spring security.

link publish delete flag offensive edit

answered 2008-08-01 13:08:18 +0800

okgago gravatar image okgago
99

Well, it's not easy to understand for which request it comes to the filter (DelegatingFilterProxy). I could not find a way to say 'OK, now it came to the filter for this included page'. But here's what I did:

I put a breakpoint to the filter and called the page YYY.zul -that includes XXX.zul with an <include> tag (check out my previous post)- for each scenario:

Scenario-1) Filter with no dispatchers defined (only REQUEST by default, I suppose)

<filter-mapping>
	<filter-name>springSecurityFilterChain</filter-name>
	<url-pattern>/*</url-pattern>
</filter-mapping>


Scenario-2) Filter with REQUEST and INCLUDE dispatchers
<filter-mapping>
	<filter-name>springSecurityFilterChain</filter-name>
	<url-pattern>/*</url-pattern>
	<dispatcher>REQUEST</dispatcher>
	<dispatcher>INCLUDE</dispatcher>
</filter-mapping>


So guess what happened? It came to the breakpoint only once for the first scenario, and twice for the second scenario. So I believe it's proved that the included page request passes through the filter!

So what's next? :(

link publish delete flag offensive edit

answered 2008-08-20 10:46:24 +0800

okgago gravatar image okgago
99

I've posted the bug in SourceForge with number 2062084

link publish delete flag offensive edit

answered 2013-08-28 03:08:36 +0800

pandukish gravatar image pandukish
68 1 1 4

Hi All,

I am also facing same issue. Do you have any update on this thread?

Regards, Pandukish

link publish delete flag offensive edit

answered 2014-03-19 17:22:46 +0800

awltux gravatar image awltux
0

I've just come across the same issue in a project created using the zk maven archetype

  • zk-6.5.2
  • zkspring-security-3.1.1

The defect mentioned above is no longer available (as the zk bug db has been moved), but I can't seem to find a relevant defect in the new system either.

I guess an obvious work-around would be to not embed the content page in another page and include the common headers/footers/sidebars into the main page. But that means lots of copies of the page structure code.

Any other ideas?

Regards, Chris

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2008-07-30 07:42:07 +0800

Seen: 300 times

Last updated: Oct 05 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More