I use Wicket with the Wicket Auth project for my presentation level, and therefore I integrated it with Spring Security. This is the method that Wicket calls for authentication for me:
@Override public boolean authenticate(String username, String password) { try { Authentication request = new UsernamePasswordAuthenticationToken( username, password); Authentication result = authenticationManager.authenticate(request); SecurityContextHolder.getContext().setAuthentication(result); } catch (AuthenticationException e) { return false; } return true; }
The content (inside) of my Spring Security security configuration:
<http path-type="regex"> <form-login login-page="/signin"/> <logout logout-url="/logout" /> </http> <global-method-security secured-annotations="enabled" /> <authentication-manager alias="authenticationManager"/> <authentication-provider user-service-ref="userService"> <password-encoder ref="bcryptpasswordencoder" /> </authentication-provider>
Section 2.3.6. Fixing session attachment protection in the help documentation states:
Session fix attacks are a potential risk when it is possible for a malicious attacker to create a session by accessing the site, then convincing another user to log in from the same session (by sending them a link containing the session ID as a parameter, for example). Spring Security protects automatically by creating a new one when a user logs in. If you do not require such protection, or contradict some other requirements, you can control the behavior using the session-fixing attribute, which has three parameters:
- migrateSession - creates a new session and copies existing session attributes for a new session. This is the default value.
- none - do nothing. The original session will be saved.
- newSession - create a new "clean" session without copying existing session data.
Authentication works, but I, since I'm pretty new to Spring Security, I have some questions that I need answers to too:
- Normally, for login, I would set the POST authentication information in
j_spring_security_check and let Spring Security execute the actual authentication code. I would like to have protection against session fix attacks, will I get it when I execute the program login, just like me? And if not, what do I need to do to get it? - How to perform a program logout?
- How will I use programmatic login and logout, how to disable Spring from intercepting these URLs?
Update: To protect against session-fixing attacks, it seems that I need to call a method in the SessionUtils class with the signature startNewSessionIfRequired(HttpServletRequest request, boolean migrateAttributes, SessionRegistry sessionRegistry) .
How do I get the SessionRegistry instance that I need to pass? I cannot find a way to create an alias identifier for it or how to get its identifier or name.
java spring spring-security wicket
user14070 Jun 18 '09 at 14:40 2009-06-18 14:40
source share