簡體   English   中英

使用AspectJ的Spring啟動+ Spring安全性無法正常工作

[英]Spring boot + Spring security with AspectJ not working

我正在嘗試使用AspectJ建議模式配置spring全局方法安全性,因此我可以在所有@Configurable注釋類中使用@PreAuthorize注釋。 這是我的java配置:

@Configuration
@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true, mode = AdviceMode.ASPECTJ)
public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration

和:

@EnableCaching
@SpringBootApplication
@EnableSpringConfigured
@EnableTransactionManagement(mode = AdviceMode.ASPECTJ)
@EnableLoadTimeWeaving(aspectjWeaving = EnableLoadTimeWeaving.AspectJWeaving.ENABLED)
public class WebApplication extends WebMvcConfigurerAdapter 

這是我的@Configurable類:

@Configurable
public class Entity {
    @PreAuthorize("hasPermission(this, 'publish')")
    public void method() { }
}

我還添加了spring-security-aspects作為依賴。 從AspectJ日志中我可以清楚地看到Spring安全相關​​的方面應用於我的@Configurable類,但是一旦我創建了這些類的實例,我就會遇到這個異常:

Post-processor tried to replace bean instance of type [com.example.Entity] with (proxy) object of type [com.sun.proxy.$Proxy130] - not supported for aspect-configured classes!

我使用的是spring boot 1.2.1版本,因此Spring安全版本為3.2.5。 這似乎是這里討論的錯誤: Spring安全AspectJMode與@EnableGlobalMethodSecurity無法正常工作

但是這個bug不應該影響我的彈簧安全版本......這個問題是否有解決方法?

好的我已經解決了這個問題 這是spring boot的SecurityAutoConfiguration類的問題。 我不得不將它從自動配置中排除並手動配置彈簧安全 - 不是很大,但無論如何......

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM