代码之家  ›  专栏  ›  技术社区  ›  Glains

Spring安全性禁用方法安全性

  •  0
  • Glains  · 技术社区  · 6 年前

    举个例子:

    @SpringBootApplication(
        exclude = SecurityAutoConfiguration.class
    )
    

    然而,这并不妨碍 MethodSecurityInterceptor 从踢进来,接着是 AuthenticationCredentialsNotFoundException .

    有没有一种方便的方法可以在不删除所有注释的情况下禁用方法安全性?

    编辑:

    我说的是

    @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
    

    然后

    @PreAuthorize("hasAuthority('SOME_AUTHORITY')")
    

    编辑2:

    Caused by: java.lang.IllegalStateException: In the composition of all global method 
    configuration, no annotation support was actually activated
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Glains    6 年前

    结果是在应用程序的某个地方 GlobalMethodSecurityConfiguration 已创建。当然,这是造成上述问题的原因。在移除它(或将它移到血清型)之后,问题就消失了。