Spring Security custom filter registration with Java config -


i trying setup pre-authentication authorisation using spring security, similar site minder external system authentication , saves login information in cookie. happen need redirect external url.

i tried doing implementation of abstractpreauthenticatedprocessingfilter doesn't work because httpservletresponse object not available.

a more appropriate way seems to add custom filter checks cookie , redirection , once cookies available passes control forward spring security filter. how can register custom filter in java configuration based spring security application? appreciated.

the common way redirect user external authentication interface using authenticationentrypoint, example loginurlauthenticationentrypoint. entry point automatically invoked spring security whenever determines user needs authenticated.

once user returns application, should hit custom filter extends abstractpreauthenticatedprocessingfilter , extracts username cookie/header/token (after perhaps validity , integrity checks) in method getpreauthenticatedprincipal.

the spring configuration similar to:

<security:http entry-point-ref="externalauthentication">     <security:custom-filter after="basic_auth_filter" ref="cookieauthentication"/>     <security:intercept-url pattern="/**" access="is_authenticated_fully"/> </security:http>  <bean id="externalauthentication" class="org.springframework.security.web.authentication.loginurlauthenticationentrypoint">     <constructor-arg value="http://server.local/authenticationservice"/> </bean>  <bean id="cookieauthentication" class="custom class extending org.springframework.security.web.authentication.preauth.abstractpreauthenticatedprocessingfilter">     ... </bean> 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -