0

Spring Security Integraton - popup modal login form -- Reload/redirect page after login

asked 2009-12-07 06:37:43 +0800

btakacs gravatar image btakacs
153 3 4

Hi

I wanted to use a popup modal login form.

After clicking a secured button with reload/redirect action, and successful authentication not the window itself, but the login popup will reload/redirect itself. Is there a way to reload/redirect the original page after succesfull login?

links in zul Page:
<button id="btn_login1" label="Login" onClick="sendRedirect("./admin/index.zul");"/>
<button id="btn_login2" label="Login" onClick="sendRedirect(null);"/>

applicationContext-security.xml:
<zksp:zk-event >
<zksp:form-login login-page="/login.zul" authentication-failure-url="/login.zul?login_error=1"/>
<zksp:intercept-event event="onClick" path="//**/btn_*" access="ROLE_SUPERVISOR"/>
<zksp:intercept-event path="/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
</zksp:zk-event>

maybe I should change the login.zul?
<h:form id="f" name="f" action="j_spring_security_check" method="POST"
xmlns:h="http://www.w3.org/1999/xhtml">
...
</h:form>
an add some kind of parent reload after spring login action?

Thanks:
Bence

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2009-12-07 08:35:57 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Have a try with this modified line.

<zksp:form-login login-page="/login.zul" authentication-failure-url="/login.zul?login_error=1" default-target-url="./admin/index.zul"/>

link publish delete flag offensive edit

answered 2009-12-14 09:29:44 +0800

btakacs gravatar image btakacs
153 3 4

Hi, Terry

Thanks for the quick reply.

If I write exactly what you wrote the application throw an exception in bootstrapping stage:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'defaultTargetUrl' threw exception; nested exception is java.lang.IllegalArgumentException: defaultTarget must start with '/' or with 'http(s)'

If I delete the '.', the result is a different browser error message (in grey popup window) after clicking the button:

Error creating bean with name 'self': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'self': Requested bean is currently in creation: Is there an unresolvable circular reference?

and then an apache-style error message after logging in:

HTTP Status 404 - /admin/~./zul/zkspring/security/loginOKTemplate.zul

it is displayed in the login popup window.

Any tips?

link publish delete flag offensive edit

answered 2010-04-22 01:45:09 +0800

JasonHao gravatar image JasonHao
12

the problem is that ZK spring resolve template file using a context path.

copy org.zkoss.spring.security.ui.ZkLoginOKFilter file to you source folder ,and replace the source below

original source:
------------------
if(loginOKTemplate == null)
loginOKTemplate = "ZKSPRING_SECURITY_LOGIN_OK_TEMPLATE";

replace with
--------------
if(loginOKTemplate == null) {
loginOKTemplate = "ZKSPRING_SECURITY_LOGIN_OK_TEMPLATE";
}else {
loginOKTemplate = "/"+loginOKTemplate;
}

link publish delete flag offensive edit

answered 2010-04-25 07:10:31 +0800

btakacs gravatar image btakacs
153 3 4

Hi

I don't understand why should I need any loginOkTemplate.

The only thing I want: if somebody want to go to a restricted area, and does not have rights to do that then it should get a modal popup window, and only if he/she can authenticate as an admin, then the modal disappears and the parent page redirects to the page he/she wanted to go. If he/she click X or Cancel then stays on the page where he/she was before. Is there an easy way to solve this with ZK + ZKSpring security?

JasonHao: your patch does not change anything. This only does not do the trick. If I click to that button:

<button id="btn_login1" label="Login" onClick="sendRedirect("./admin/index.zul");"/>

The login popup appear, and if I authenticate well, then it changes to an empty page.

If I try this one too:

<zksp:form-login login-page="/login.zul" authentication-failure-url="/login.zul?login_error=1" default-target-url="./admin/index.zul"/>

then it seems that something changed with the current version of ZKsecurity, since I get the following error message:
cvc-complex-type.3.2.2: Attribute 'default-target-url' is not allowed to appear in element 'zksp:form-login'.

What do you suggest? Forgot the fancy modal-popup concept, and use tomcat security, since it does something similar? (just does not have any integration with spring security)

Regards:
Bence

link publish delete flag offensive edit

answered 2010-04-26 04:21:12 +0800

JasonHao gravatar image JasonHao
12

as far as I know, the loginOKTemplate is called automatically when your authentication is succeed, which makes a delay before turn to your login succeed destination. and the delay period can be defined in <zksp:form-login section .

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

RSS

Stats

Asked: 2009-12-07 06:37:43 +0800

Seen: 4,336 times

Last updated: Apr 26 '10

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