Programmatic use of Spring Security

前端 未结 6 1226
情话喂你
情话喂你 2020-12-23 09:47

I am using Wicket with the Wicket Auth Project for my presentation layer and I have therefore integrated it with Spring Security. This is the method which is called by Wicke

6条回答
  •  一整个雨季
    2020-12-23 10:25

    You will indeed be open to session fixations attacks. To remedy this you could again be "inspired" by the Spring code. To create a new session you'll obviously need access to the httpsession so you may have to do some refactoring.

    If you see the method SessionUtils.startNewSessionIfRequired.

    This will migrate the authentication to a new session. You might be able to call this method directly or else just refactor the code a little.

    As for programmatic logout you can't go too far wrong by simply calling session.invalidate() when you need to log the person out. This will do everything necessary from a general security perspective but bear in mind though you might need to cleanup some things on the session. If you have a very complicated set of filters etc. and you need to ensure that that the user is logged out for the rest of the request then you could add:

    SecurityContextHolder.getContext().setAuthentication(null);
    

    As for interception of the url's you could just set them to something unused and ignore it! I'm not sure if you can turn off the interception in configuration - if you really want to remove it then have a look at the AuthenticationProcessingFilter - you could customise this. If you do this then you'll have to manually setup the spring security xml and not use the provided namespaces. It's not too hard though - look at some older documentation and you'll see how to do this.

    Hope this helps!

提交回复
热议问题