Reputation: 86687
I'd like intregrate spring-security in an application that is completely configured with spring annotations, no xml is present. How would the following have to look like in pure java code?
<http auto-config="true">
<intercept-url pattern="/*" access="ROLE_ANONYMOUS"/>
</http>
I cannot find any documentation on spring-security with annotations. Is it not supported so far? If not, how can I integrate a security.xml in an annotation based configuration class?
@Configuration
public AppConfig {
}
Upvotes: 1
Views: 413
Reputation: 10017
It is pretty easy. do something like this, important is only to extend WebSecurityConfigurerAdapter
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/*").hasRole("ROLE_ANONYMOUS")
}
}
Upvotes: 1