Announcement Announcement Module
No announcement yet.
How to custom(override) Spring security filter or provider? Page Title Module
Move Remove Collapse
This topic is closed
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to custom(override) Spring security filter or provider?

    Hi all
    I am using Spring security 3 with openID, there are something I want to use my own demand.

    1. use own filterProcessesUrl
    the default openid check url is j_spring_openid_security_check, but I want it to be openidlogin(e.g.), so it could be configured in filter, but what I did didn't work.
    My configuration is as follows:
    	<!-- custom filter -->
    	<b:bean id="openIdFilter"
    		<b:property name="authenticationManager" ref="authenticationManager" />
    		<b:property name="filterProcessesUrl" value="/openidlogin" />
    		<b:property name="defaultTargetUrl" value="/sso" />
    		<b:property name="alwaysUseDefaultTargetUrl" value="true" />
    		<b:property name="authenticationFailureUrl" value="/openid/login.jsp?login_error=true" />
    I also configured a entrypoint which it needed. I know we can custom a filter and use position adding it to FilterChainProxy, But I just override OpenIDAuthenticationFilter, how can I do?

    2. use own provider
    The default OpenIDAuthenticationProvider must use userDetailsService, but I didn't want to use it, so I need to override OpenIDAuthenticationProvider,
    <b:bean id="customAuthenticationProvider" class="com.dingfei.openid.provider.MyOpenIDProvider" />
    	<authentication-provider ref="customAuthenticationProvider" />
    but it doesn't work, the spec instruct me how to do like that. so how can I do?

    the http configuration is as follows:
            <intercept-url pattern="/**" access="ROLE_USER"/>
            <intercept-url pattern="/openidlogin.jsp*" filters="none"/>
            <openid-login login-page="/openidlogin.jsp" 
                    <openid-attribute name="email" type="" required="true" count="1"/>
                    <openid-attribute name="name" type="" />
            <remember-me token-repository-ref="tokenRepo"/>
    generally, could anyone can tell me how to custom(override) Spring security filter or provider?

    Best regards!

  • #2
    That is all explained in the reference guide.

    Filters need to be specified AND added to the security configuration simply putting them in there doesn't make them work. You will need to find the name of the filter. Although why make it so complex and not simply specify the 'login-processing-url' for the 'openid-login' element. That should work without redefining the filter.

    Just wondering about 2 why don't you want to use a UserDetailService implementation, which basically goes against the Spring Security architecture as it is needed in several locations.