【问题标题】:How to populate the @Secured() annotation using values from a properties file?如何使用属性文件中的值填充 @Secured() 注释?
【发布时间】:2016-09-08 21:38:04
【问题描述】:

我总是可以做一个@Secured("ROLE_A", "ROLE_B")。但是有没有办法从属性文件中填充 @Secured 注释值?类似于@Secured({property_a}, {property_b})

谢谢。

【问题讨论】:

    标签: spring spring-mvc spring-security spring-annotations


    【解决方案1】:

    使用@PreAuthorize。您可以将 Spring EL 表达式与有限的 @Secured 进行比较。

    例子:

    @PreAuthorize("#n == authentication.name")
    Contact findContactByName(@Param("n") String name);
    

    参考:

    1)What's the difference between @Secured and @PreAuthorize in spring security 3

    2)Spring EL

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-16
      • 2019-01-10
      • 1970-01-01
      • 2015-02-06
      • 2018-07-20
      • 2019-05-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多