繁体   English   中英

批注安全性Spring文件属性

[英]annotation security spring file properties

我想在春季在我的应用程序中使用注解@PreAuthorized和@PostAuthorized,但是我使用并且它什么也不做。 我需要在application.properties中激活“某物”,但是我不知道。 我读到放这是servlet.xl

 <global-method-security pre-post-annotations="enabled" />

但是在文件属性上呢? 我使用Java批注,但尚未激活它。

我建议只使用这样的配置:

@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableWebSecurity
public class AuthenticationConfiguration extends WebSecurityConfigurerAdapter {
    // Your authorisation service, you need to provide one
    @Autowired
    private UserAuthenticationService userDetailsService;

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailsService);
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().anyRequest().fullyAuthenticated();
        http.httpBasic();
        http.csrf().disable();
    }
}

这里有一个非常不错的教程,您应该阅读并尝试逐步进行复制,有关此主题的更多信息,可以放在这里: 使用Spring Data REST和Java 8构建安全的REST API

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM