Search code examples
javaspringspring-mvcspring-securityspring-java-config

What is Spring Security`secured-annotations="enabled"` analogue for Java Config?


Consider I use Java config for spring security:

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
...
}

How can I do analogue of XML configuration

<global-method-security secured-annotations="enabled" />?


Solution

  • You can use @EnableGlobalMethodSecurity annotation to configure that and set securedEnabled annotation attribute to true.

    @EnableGlobalMethodSecurity

    Enables Spring Security global method security similar to the <global-method-security> xml support.