I'm using SpringBoot v2.4.2 to host a few JAX-RS (Jersey) based REST APIs. And these APIs are secured (BASIC auth) using Spring's in-memory authenticator i.e. by extending WebSecurityConfigurerAdapter
.
Below is the code snippet:
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
auth.inMemoryAuthentication()
.withUser(username)
.password(encoder.encode(passwd));
}
Now the question is, how do I update this in-memory authentication mechanism if a user (in this case an administrator) updates his/her password. I do allow user to update password after login with the default username/password (only known to administrators).
How do I get the code flow/event back to configure(AuthenticationManagerBuilder auth)
method to use the new password?
Thanks.