Spring Security で同じ問題に再び直面しています:「パスワードが保存された値と一致しません」。
カスタム クラスを使用してグラフ (SpringData/Neo4J を使用) に 4 つのアカウントをインポートGraphPopulator
し、1 つ ("fbiville"/"s3cret") でログインしようとしています。
認証は次のように構成されます。
<beans:bean id="encoder" class="org.springframework.security.crypto.password.StandardPasswordEncoder">
<beans:constructor-arg value="******" />
</beans:bean>
<beans:bean id="userService" class="com.lateralthoughts.devinlove.service.LoginService" />
<authentication-manager>
<authentication-provider user-service-ref="userService">
<password-encoder ref="encoder" />
</authentication-provider>
</authentication-manager>
また、アカウントの永続化を担当するクラスは、部分的にカスタム SpringData リポジトリ実装に基づいています。
class PersonRepositoryImpl implements PersonRepositoryCustom {
private final PasswordEncoder passwordEncoder;
private final Neo4jOperations template;
@Autowired
public PersonRepositoryImpl(PasswordEncoder passwordEncoder,
Neo4jOperations template) {
this.passwordEncoder = passwordEncoder;
this.template = template;
}
@Override
@Transactional
public void persist(Person person) {
person.setPassword(passwordEncoder.encode(person.getPassword()));
template.save(person);
}
}
最後に、ログイン プロセスは次のように構成されます。
<http auto-config='true' use-expressions='true' realm="devinlove: love is just another algorithm">
<form-login login-page="/login"
default-target-url="/"
authentication-failure-url="/login" />
<intercept-url pattern="/login" access="isAnonymous()" />
<intercept-url pattern="/**" access="hasRole('USER')" />
</http>
アカウントの作成時とユーザーのログイン試行時に StandardPasswordEncoder をデバッグしたところ、明らかに認証エラーにつながるソルトが一致していないことに気付きました。
問題を再現したい場合は、リポジトリを複製できます。
前もって感謝します !
ロルフ