你能解釋在哪裏處理@PreAuthorize(「hasRole('ADMIN')」)的通知在Reactive應用程序中檢索SecurityContext?@PreAuthorize如何在反應式應用程序中工作或者如何在沒有ThreadLocal的情況下工作?
下Spring Security的例子是這種用法的一個很好的例子:https://github.com/spring-projects/spring-security/tree/5.0.0.M4/samples/javaconfig/hellowebflux-method
檢查春季安全Webflux源代碼後,我發現SecurityContextRepository的一些實現,但load方法需要ServerWebExchange作爲參數。我試圖瞭解如何替換標準服務中的SecurityContextHolder.getContext()。getAuthentication()調用(因爲ThreadLocal不再是一個反應式應用程序中的選項),但我不明白如何替換這是通過調用SecurityContextRepository而不是在ServerWebExchange上引用。