स्प्रिंग सुरक्षा में जावा कॉन्फ़िग के लिए वसंत सुरक्षा एक्सएमएल विन्यास से आगे बढ़ पर कार्य करना।स्प्रिंग बूट, वसंत सुरक्षा ओवरराइड UserDetailsService
मेरी कक्षा SecurityConfiguration कि WebSecurityConfigurerAdapter फैली में। हालांकि, समस्या यह है कि उपयोगकर्ता डिस्प्ले सेवा का उपयोग सुरक्षा फ़िल्टर द्वारा विशेष रूप से उपयोगकर्ता नाम पासवर्ड उपयोगकर्ता प्रमाणीकरण फ़िल्टर द्वारा नहीं किया जा रहा है। मैंने स्टार्टअप को देखा और ऐसा लगता है कि यह वसंत बूट डिफ़ॉल्ट रूप से InMemoryUserDetailsManager बनाता है इससे पहले नहीं बनाया गया है।
@Configuration
@EnableWebMvcSecurity
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http)
throws Exception {
http.userDetailsService(userDetailsService);
}
}
मैं भी कस्टम इंजेक्शन ApplicationUserDetailsService का उपयोग कर इस वर्ग में userDetailsServiceBean और userDetailsService ओवरराइड करने के लिए कोशिश की है।
@Bean(name="myUserDetailsBean")
@Override
public UserDetailsService userDetailsServiceBean() {
return userDetailsService;
}
@Override
public UserDetailsService userDetailsService() {
return userDetailsService;
}
हालांकि, जब मैं authenticationManagerBean ओवरराइड करने के लिए कोशिश यह लग रहा है कि यह मेरे विन्यास का आह्वान तरह से पहले वसंत बूट विन्यास initializes लेकिन यह (नीचे) एक परिपत्र संदर्भ है कि वहाँ जब UsernamePasswordAuthenticationFilter प्रारंभ करने में त्रुटि फेंकता है। क्या मुझे वास्तव में प्रमाणीकरण को ओवरराइड करने की ज़रूरत है मैनेजरबीन क्योंकि मुझे परिभाषित करने की आवश्यकता है कि उपयोगकर्ता नाम PasswordAuthenticationFilter में क्या है।
@Bean(name="myAuthenticationManager")
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
..
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter]: Circular reference involving containing bean 'securityBeansConfiguration' - consider declaring the factory method as static for independence from its containing instance. Factory method 'usernamePasswordAuthenticationFilter' threw exception; nested exception is java.lang.IllegalArgumentException: successHandler cannot be null
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
... 70 common frames omitted
विचार?