[Spring Security] Spring Security authentication process source code analysis

Project begining

We learned earlier that the username and password can be configured in application.yml, so we can guess: it must be loaded when the project is started. We click on it with the mouse.

Entering SecurityProperties, we break the point on getName in User so that we can go here when the project starts.

Then we can go back and enter the following method by clicking: Drop Frame:

InMemoryUserDetailsManager

We enter this class and find the following method: loadUserByUsername is the actual method to query the account and password comparison when logging in.

Visit login

When we know the loadUserByUsername method, break the point to start the project and log in

You will find that this method is called, we still click Drop Frame to go back!

DaoAuthenticationProvider

AbstractUserDetailsAuthenticationProvider

ProviderManager

重要:UsernamePasswordAuthenticationFilter

AbstractAuthenticationProcessingFilter

FilterChainProxy

LogoutFilter

HeaderWriterFilter

Important: OncePerRequestFilter

WebSecurity

By querying FilterChainProxy, you can search for calls in the performBuild method of WebSecurity.

Guess you like

Origin blog.csdn.net/weixin_45481821/article/details/134231183