【问题标题】:How to use spring acl with spring data rest with out defining custom methods如何在不定义自定义方法的情况下将 spring acl 与 spring data rest 一起使用
【发布时间】:2016-11-06 21:45:45
【问题描述】:

假设我有以下存储库

@RepositoryRestResource(path = "book")
public interface BookRepository extends CrudRepository<Book, Long> {
}

Spring data rest 将发布他自己的一些端点。 问题是我可以在不定义保存方法的情况下使用弹簧安全权限评估(例如:hasPermission WRITE)包装 POST 、 PUT /book 端点

【问题讨论】:

标签: spring-security acl spring-data-rest


【解决方案1】:

您可以在 Spring Security 配置中应用 HTTP 级别的安全性:

@Override
public void configure(HttpSecurity http) throws Exception {

    //other config

    http.authorizeRequests().antMatchers(HttpMethod.POST, 
           "/book").hasAuthority("MY_PERMISSION");
    http.authorizeRequests().antMatchers(HttpMethod.PUT, 
           "/book").hasAuthority("MY_PERMISSION");
}

【讨论】:

    猜你喜欢
    • 2016-08-15
    • 2014-12-20
    • 2017-03-06
    • 2016-06-08
    • 1970-01-01
    • 2016-08-31
    • 1970-01-01
    • 1970-01-01
    • 2018-03-17
    相关资源
    最近更新 更多