Spring Security - multiple authentication-providers

后端 未结 2 1151
说谎
说谎 2020-12-19 21:11

My web app has multiple authentication managers (one for API one for WEB access). The api should have a basic auth service only - configured via the spring security markup a

相关标签:
2条回答
  • 2020-12-19 21:56

    Please keep in mind that this Spring Security XML namespace is just a neat way of organizing your XML. You could achieve exactly the same solution with plain <bean> config. That way you will be able to use ID, as usual. This blog post might be helpful for you.

    0 讨论(0)
  • 2020-12-19 22:07

    In namespace the name can be add it in the java with the @Service("userDetailsService") with a name.

    You can also define beans and add them to the chain.

    <bean id="myFilter" class="a.b.c.myFilter">
        <security:custom-filter before="BASIC_PROCESSING_FILTER" />
        <property name="authenticationManager" ref="_authenticationManager" />
    </bean>
    <bean id="myProvider" class="a.b.c.myProvider">
        <security:custom-authentication-provider />
        <property name="userDetailsService" ref="userDetailsService" />
    </bean>
    
    <security:http>
        [...]
    </security:http>
    

    the _authenticationManager is the name of the bean that is registered in namespace.

    This would be executed before the basic auth.

    0 讨论(0)
提交回复
热议问题