मैं बसंत सुरक्षा के साथ वसंत-बूट का उपयोग करके एक उदाहरण करने की कोशिश कर रहा हूं। मेरा विचार है कि एक वेब ऐप बनाना और एक एपीआई भी प्रदान करना है, मैं दोनों को सुरक्षा चाहिए; इसलिए मुझे एक बहु http वेब सुरक्षा कॉन्फ़िगरेशन बनाने की आवश्यकता है हालांकि यह काम नहीं कर रहा है।स्प्रिंग बूट + सुरक्षा + मल्टी HTTP वेब कॉन्फ़िगरेशन
मैंने इस लिंक का पालन किया http://docs.spring.io/spring-security/site/docs/3.2.x/reference/htmlsingle/#multiple-httpsecurity लेकिन कोई सफलता नहीं। और, मुझे यह त्रुटि मिल रही है
नाम 'वेब सुरक्षा सुरक्षा कॉन्फ़िगरेशन' नाम से बीन बनाने में त्रुटि: स्वत: निर्भरता की इंजेक्शन विफल रही; नेस्टेड अपवाद java.lang.IllegalStateException है:
: पहले से ही वस्तु का निर्माण करने के लिएविन्यास है कि मैं उपयोग कर रहा हूँ org.springframework.security.config.annotation.authentication.configurers.provisioning.InMemoryUserDetailsManagerConfigurer लागू नहीं कर सकता पीछा कर रहा है
@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
@EnableGlobalAuthentication
@EnableGlobalMethodSecurity(securedEnabled = true)
public class WebSecurityConfiguration {
@Autowired
protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("user").password("12345").roles("USER").and()
.withUser("admin").password("12345").roles("USER", "ADMIN");
}
@Configuration
@Order(1)
public static class ApiConfigurationAdapter extends
WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.antMatcher("/api/**")
.authorizeRequests()
.anyRequest().hasRole("ADMIN")
.and()
.httpBasic();
}
}
@Configuration
@Order(2)
public static class WebConfigurationAdapter extends
WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/resources/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/home").permitAll()
.anyRequest()
.authenticated()
.and()
.formLogin()
.loginPage("/login").permitAll()
.and()
.logout().permitAll();
}
}
}
अग्रिम