MySQLに登録されたデータを入力してもログインできない原因を知りたいです。

実現したいこと

作成中のアプリのログイン機能を完成させたい

発生している問題・分からないこと

MySQLに登録されたデータを入力したところ、アプリ側から不一致で弾かれてしまいます。
eclipse上では{Encoded password does not look like BCrypt}と表記されていますが、どのコードを修正すべきなのかわからず手詰まっております。

パスワードのハッシュ化においてエラーが発生していると考えておりますが、着眼点としてふさわしいかも不安です。
抽象度の高い質問で大変恐縮ですが、お力添えいただけると幸いです。

該当のソースコード

WebSecurityConfig.java

1package com.example.nagoyameshi.security; 2import org.springframework.context.annotation.Bean; 3import org.springframework.context.annotation.Configuration; 4import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; 5import org.springframework.security.config.annotation.web.builders.HttpSecurity; 6import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 7import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 8import org.springframework.security.crypto.password.PasswordEncoder; 9import org.springframework.security.web.SecurityFilterChain; 10 11@Configuration 12@EnableWebSecurity 13@EnableMethodSecurity 14public class WebSecurityConfig { 15 @Bean 16 public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { 17 http 18 .authorizeHttpRequests((requests) -> requests 19 .requestMatchers("/css/**", "/images/**", "/js/**", "/storage/**", "/","/signup/**").permitAll() // すべてのユーザーにアクセスを許可するURL 20 .requestMatchers("/admin/**").hasRole("ADMIN") // 管理者にのみアクセスを許可するURL 21 .anyRequest().authenticated() // 上記以外のURLはログインが必要(会員または管理者のどちらでもOK) 22 ) 23 .formLogin((form) -> form 24 .loginPage("/login") // ログインページのURL 25 .loginProcessingUrl("/login") // ログインフォームの送信先URL 26 .defaultSuccessUrl("/?loggedIn") // ログイン成功時のリダイレクト先URL 27 .failureUrl("/login?error") // ログイン失敗時のリダイレクト先URL 28 .permitAll() 29 ) 30 .logout((logout) -> logout 31 .logoutSuccessUrl("/?loggedOut") // ログアウト時のリダイレクト先URL 32 .permitAll() 33 ); 34 35 return http.build(); 36 } 37 38 @Bean 39 public PasswordEncoder passwordEncoder() { 40 return new BCryptPasswordEncoder(); 41 } 42}

試したこと・調べたこと

上記の詳細・結果

同様の質問をされている方の回答を拝見いたしましたが、自分のパターンとは異なっていたため参考にできませんでした。

補足

特になし

コメントを投稿

0 コメント