admin
2024-06-30 b6fdf185c7e8fb1f06da0e609e39aecaef6b66f5
src/main/java/com/taoke/autopay/config/WebSecurityConfig.java
@@ -14,6 +14,7 @@
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@@ -182,7 +183,7 @@
     * @param: httpServletRequest
     **/
    private void verificationCode(HttpServletRequest httpServletRequest) throws VerificationCodeException {
        String requestCode = httpServletRequest.getParameter("captcha");
        String requestCode = httpServletRequest.getParameter("code");
        HttpSession httpSession = httpServletRequest.getSession();
        String captcha = httpSession.getAttribute("captcha") + "";
        httpSession.removeAttribute("captcha");
@@ -250,6 +251,23 @@
        // http.addFilterBefore(new PreRequestVerifyFilter(), UsernamePasswordAuthenticationFilter.class);
    }
    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(new MyAuthenticationProvider(new MyUserDetailsService(), new PasswordEncoder() {
            @Override
            public String encode(CharSequence charSequence) {
                return charSequence.toString();
            }
            @Override
            public boolean matches(CharSequence charSequence, String s) {
                return s.equalsIgnoreCase(charSequence.toString());
            }
        }));
    }
    class MyUserDetailsService implements UserDetailsService {
        @Override