Order of Spring @Transactional and Spring Security @PreAuthorize

前端 未结 1 1782
面向向阳花
面向向阳花 2020-12-09 12:04

So I have something like the following:

public interface  MyService {

    @PreAuthorize(\"hasPermission(T(Name).OBJ, T(Action).GET)\")
    MyObj getObj(Stri         


        
相关标签:
1条回答
  • 2020-12-09 12:28

    You can use order attribute when configuring @Transactional:

    <tx:annotation-driven order="100"/>
    

    Experiment with lower values to move transaction aspect after the authorization one. Looks like <security:global-method-security/> also has this setting. The security aspect needs to have a higher value (lower priority) to be executed first.

    See also

    • Table 10.2. settings

    • 7.2.4.7 Advice ordering

    0 讨论(0)
提交回复
热议问题