So you’ve got Spring Security up and running. Great! Now you’ve got a login page, and you just added a form on the global page menu to allow users to Login from any public page. There’s just one problem. When they log-in from a public page, they’re redirected to the default-login-url! Your users will have to re-navigate to the page they were already viewing when they logged in, or maybe they’ll just use the much dreaded “Back” button. That’s not a good interaction, but we have a solution.
A correction has been made to the post: http://ocpsoft.com/java/acegi-spring-security-jsf-login-page/
, fixing an issue where FacesMessages were not being displayed on failed authentications.
We’ve gotten a good number of comments from Lincoln’s
latest post on Spring Security and JSF
. A few comments have asked for further code samples on how to get this example working.
We created a runnable project for this example, and it can be downloaded here
Tutorials – What a nightmare
Everyone seems to be going through hell to get a fully functional JSF login page working with Spring Security (formerly Acegi,) and yes, I did too, but there’s an EASY
way to make this happen. And get this:
- It takes just five clear and well written lines of Java code.
First, the solution. Afterwards, the dirty details. (Spring 2.5.2 was used for this example, but this documentation is still relevant for Spring 3.x)
You can find a downloadable working example here
. There is also a followup article on post-authentication redirecting, here