Spring Security authentication failed, are the username and password correct or failed?

Why do I still get told that the username and password are incorrect after entering the correct username and password when logging in to the project?

There are several situations

The first is to enable caching. The encrypted password is stored in the database.

Second, check the source code. This sentence is the key. presentedPassword is the plain text password, and userDetails.getPassword() is the encrypted password. Compare it.

this.passwordEncoder.matches(presentedPassword, userDetails.getPassword())

protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
        if (authentication.getCredentials() == null) {
            this.logger.debug("Authentication failed: no credentials provided");
            throw new BadCredentialsException(this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credenti

Guess you like

Origin blog.csdn.net/y15201653575/article/details/130798762
Recommended