You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.
The author hello!
I looked at the documentation on the website, and it says this:
@Configuration
public class ApplicationSecurity extends WebSecurityConfigurerAdapter {
@Autowired
DataSource dataSource;
... // web stuff here
@Override
public void configure(AuthenticationManagerBuilder builder) {
builder.jdbcAuthentication().dataSource(dataSource).withUser("dave")
.password("secret").roles("USER");
}
}
If we had used an @Override of a method in the configurer, the AuthenticationManagerBuilder would be used only to build a “local” AuthenticationManager, which would be a child of the global one. In a Spring Boot application, you can @Autowired the global one into another bean, but you cannot do that with the local one unless you explicitly expose it yourself.
If we rewrote the method (configure) ,WebSecurityConfigurerAdapter`s disableLocalConfigureAuthenticationBldr is not true.
But I was a little confused in the process of using it, and I think the end result is a global one.
configure(AuthenticationManagerBuilder auth) Not rewritten:
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//If we rewrote the method ,it is not true.
this.disableLocalConfigureAuthenticationBldr = true;
}
getHttp():
if (this.http != null) {
return this.http;
} else {
DefaultAuthenticationEventPublisher eventPublisher = (DefaultAuthenticationEventPublisher)this.objectPostProcessor.postProcess(new DefaultAuthenticationEventPublisher());
this.localConfigureAuthenticationBldr.authenticationEventPublisher(eventPublisher);
//fellow authenticationManager()
AuthenticationManager authenticationManager = this.authenticationManager();
// It is parentAuthenticationManager ()
this.authenticationBuilder.parentAuthenticationManager(authenticationManager);
.......
authenticationManager():
protected AuthenticationManager authenticationManager() throws Exception {
if (!this.authenticationManagerInitialized) {
// This is the method that we overwrote(configure)
this.configure(this.localConfigureAuthenticationBldr);
if (this.disableLocalConfigureAuthenticationBldr) {
this.authenticationManager = this.authenticationConfiguration.getAuthenticationManager();
} else {
//disableLocalConfigureAuthenticationBldr is not true
//Overridden methods(configure) are used for the localConfigureAuthenticationBldr
this.authenticationManager = (AuthenticationManager)this.localConfigureAuthenticationBldr.build();
}
this.authenticationManagerInitialized = true;
}
return this.authenticationManager;
}
So I think you end up with a global authenticationManager instead of a local authenticationManager.
Maybe my English is too poor to understand what the author says. I hope you can give me some advice. Thank you~
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The author hello!
I looked at the documentation on the website, and it says this:
But I was a little confused in the process of using it, and I think the end result is a global one.
configure(AuthenticationManagerBuilder auth) Not rewritten:
getHttp():
authenticationManager():
So I think you end up with a global authenticationManager instead of a local authenticationManager.
Maybe my English is too poor to understand what the author says. I hope you can give me some advice. Thank you~
The text was updated successfully, but these errors were encountered: