मैं विभिन्न यूआरएल पैटर्न के लिए दो अलग-अलग सुरक्षा कॉन्फ़िगरेशन को परिभाषित करने की कोशिश कर रहा हूं, उनमें से एक फॉर्म लॉगिन का उपयोग कर रहा है और दूसरा एक एपीआई के लिए मूल प्रमाणीकरण का उपयोग कर रहा है।स्प्रिंग सुरक्षा के साथ मूल और फॉर्म आधारित प्रमाणीकरण Javaconfig
मैं जो समाधान ढूंढ रहा हूं वह http://meera-subbarao.blogspot.co.uk/2010/11/spring-security-combining-basic-and.html समझाया गया है, लेकिन मैं इसे जावा कॉन्फ़िगरेशन का उपयोग करके करना चाहता हूं।
अग्रिम धन्यवाद।
@Configuration
@EnableWebSecurity
public class AppSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserService userService;
@Override
protected void registerAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userService);
}
@Override
public void configure(WebSecurity web) throws Exception {
// Ignore any request that starts with "/resources/".
web.ignoring().antMatchers("/resources/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeUrls().antMatchers("/", "/index", "/user/**", "/about").permitAll()
.antMatchers("/admin/**").hasRole("ADMIN")
.anyRequest().authenticated()
.and().formLogin()
.loginUrl("/login")
.failureUrl("/login-error")
.loginProcessingUrl("/security_check")
.usernameParameter("j_username").passwordParameter("j_password")
.permitAll();
http.logout().logoutUrl("/logout");
http.rememberMe().rememberMeServices(rememberMeServices()).key("password");
}
@Bean
public RememberMeServices rememberMeServices() {
TokenBasedRememberMeServices rememberMeServices = new TokenBasedRememberMeServices("password", userService);
rememberMeServices.setCookieName("cookieName");
rememberMeServices.setParameter("rememberMe");
return rememberMeServices;
}
}
आप क्या परिणाम देख रहे हैं? – Taylor
वर्तमान में मेरे पास इसके साथ फॉर्म प्रमाणीकरण है और मुझे यह नहीं पता कि यूआरएल पैटर्न में मूल एथ जोड़ने के लिए/api/* –