Chcę zdefiniować coś podobnego do tego XML w wiosennym Boot wykorzystaniem Java Config.Jak mogę określić http „security = 'none' w JavaConfig?
<http pattern="/webservices/**" security="none"/>
muszę inny sposób ich zabezpieczania i nie można tworzyć logowań formularza Zabezpieczanie ich nastąpi później .. Na razie chcę zatrzymać ich zabezpieczanie za pomocą metody http.formLogin().
Nadpisałem obiekt WebSecurityConfigurerAdapter.configure() jako taki. Nie mogę znaleźć interfejsu API do powiedzmy tak:
http.securityNone().antMatchers("/webservices")
Oto configure() Metoda mój teraz:
@Override
protected void configure(HttpSecurity http) throws Exception
http.csrf().disable();
http.headers().frameOptions().disable();
http.authorizeRequests()
.antMatchers("/resources/**",
//"/services/**", THIS LOGS IN AUTOMATICALLY AS 'ANONYMOUS'. NO GOOD!
//"/remoting/**", THIS LOGS IN AUTOMATICALLY AS 'ANONYMOUS'. NO GOOD!
"/pages/login",
"/pages/loginFailed").permitAll()
// Only authenticated can access these URLs and HTTP METHODs
.antMatchers("/secured/**").authenticated()
.antMatchers(HttpMethod.HEAD,"/**").authenticated()
.antMatchers(HttpMethod.GET,"/**").authenticated()
.antMatchers(HttpMethod.POST,"/**").authenticated()
.antMatchers(HttpMethod.PUT,"/**").authenticated()
.antMatchers(HttpMethod.DELETE,"/**").authenticated();
// Accept FORM-based authentication
http.formLogin()
.failureUrl("/pages/loginFailed")
.defaultSuccessUrl("/")
.loginPage("/pages/login")
.permitAll()
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/pages/logout"))
.logoutSuccessUrl("/pages/login")
.permitAll();
http.formLogin().successHandler(new AppLoginSuccessHandler());
}