2016-07-24 2 views
-1

Spring Security PasswordEncoder(私が使用する実装は違いがある場合はBCryptPasswordEncoderです)は、パスワードをコード化する際に塩を生成することに驚いています。春のセキュリティでsaltを処理するPasswordEncoder

私には分かりませんが、ログインリクエストの検証時にこの塩をどのように取得する必要がありますか?私は自分の塩を使うことを意図していましたが、(おそらく)自動塩生成のために、同じパスワード+塩の組み合わせに対して異なるハッシュ値が得られます。

私はちょっと混乱しており、エンコーダーを正しく使用する方法がわかりません。

答えて

1

独自のパスワード検証機能を記述するのではなく、組み込み検証ロジックを使用する必要があります。したがって、Spring Securityが生成するソルトを取得する必要はありません。 PasswordEncoderのドキュメントを参照してください。

/** 
* Verify the encoded password obtained from storage matches the submitted raw 
* password after it too is encoded. Returns true if the passwords match, false if 
* they do not. The stored password itself is never decoded. 
* 
* @param rawPassword the raw password to encode and match 
* @param encodedPassword the encoded password from storage to compare with 
* @return true if the raw password, after encoding, matches the encoded password from 
* storage 
*/ 
boolean matches(CharSequence rawPassword, String encodedPassword); 
関連する問題