我是 Spring Security 的新手,想更好地了解身份驗證程序
以下是我在 Internet 上找到的與該主題相關的內容,如果我對流程有誤,請告訴我:
- 身份驗證程序始于
Filter可能是FilterChain. 過濾器可能是 型別UsernamePasswordAuthenticationFilter。HTTP 請求被攔截,并嘗試創建一個Authentication Request(實作Authentication介面的類的物件,即UsernamePasswordAuthenticationToken)。 - 該
Authentication物件被授予的AuthenticationManager。 - 基于傳遞給
AuthenticationManager它的內容,它將它委托給適當的AuthenticationProvider(即DaoAuthenticationProvider)進行真實身份驗證的地方。 - 在
AuthenticationProvider完全驗證的發送Authentication物件的AuthenticationManager。 - 在被呼叫的
Filter地方,AuthenticationManager被呼叫SecurityContextHolder.getContext().setAuthentication(authResult);并完成身份驗證程序。
我的問題是關于Filter類的具體實作以及FilterChain與身份驗證相關的。
在我們的應用程式中,大多數身份驗證過濾器都會擴展AbstractAuthenticationProcessingFilter,并且 FilterChain 屬于 類CompositeFilter。這個介面的事實上的“正確”實作是什么?我提前為這樣一個愚蠢的問題道歉,但仍然需要學習這個概念。
uj5u.com熱心網友回復:
在SecurityFilterChain有一個實施DefaultSecurityFilterChain。
Filter對于一個實作來說,有太多的實作被認為是最常見的。在春季安全可用的身份驗證篩選器擴展AbstractAuthenticationProcessingFilter是UsernamePasswordAuthenticationFilter,OAuth2LoginAuthenticationFilter和Saml2WebSsoAuthenticationFilter。
要使用的“正確”過濾器很大程度上取決于您的用例。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/386255.html
