[英]Spring Security without the WebSecurityConfigurerAdapter
[英]Spring security: difference between WebSecurityConfigurerAdapter and GlobalAuthenticationConfigurerAdapter
這兩個類:
WebSecurityConfigurerAdapter
GlobalAuthenticationConfigurerAdapter
似乎對我做同樣的事情。 它們都提供了不同的方法configure(...)
來定制WebSecurity,例如配置UserDetailsService
。 在互聯網上找到的一些例子中,我看到兩個類都被擴展了(比如這個, http : //ryanjbaxter.com/2015/01/06/securing-rest-apis-with-spring-boot/ ):
@Configuration
class WebSecurityConfiguration extends GlobalAuthenticationConfigurerAdapter {...}
和
@EnableWebSecurity
@Configuration
class WebSecurityConfig extends WebSecurityConfigurerAdapter {...}
但在某些示例中,只需要(擴展) WebSecurityConfigurerAdapter
。
我不確定兩者之間的區別? 另一個人不能做什么? 或者如果它們都需要,那么它們中的哪一個是針對Spring安全性的哪個方面?
我見過的唯一的區別是@EnableWebSecurity
往往是上面的注釋,擴展類WebSecurityConfigurerAdapter
,但不是在擴展類GlobalAuthenticationConfigurerAdapter
============= 實驗 ==================
我試圖刪除擴展類GlobalAuthenticationConfigurerAdapter
,並攜帶相關的UserDetailsService擴展類的代碼WebSecurityConfigurerAdapter
(見上面的實際代碼的鏈接),它仍然有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.