Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问35.Spring-Security-Authentication这个模块中,自己实现的cc.mrbird.security.browser.UserDetailService类是如何被调用的呢? #36

Open
yaoliweb opened this issue Sep 15, 2020 · 2 comments

Comments

@yaoliweb
Copy link

如题,cc.mrbird.security.browser.UserDetailService这个类似乎没有在其他地方注册,如果自己复制一份这个类,那整个验证功能就不起作用了。烦请懂得人能够解释一下,不慎感激!

@Stan982314760
Copy link

看一下这个类AbstractUserDetailsAuthenticationProvider的authenticate()方法,里面调用了DaoAuthenticationProvider的retrieveUser()方法,这个里面就是用到了UserDetailService的loadUserByUsername()方法

@yaoliweb
Copy link
Author

yaoliweb commented Sep 15, 2020

@Stan982314760 谢谢,感谢指明了方向。
虽然我没有找到在没有注册的情况下,Spring Security是如何找到实现的子类的。但是经过查找相关资料,建议在BrowserSecurityConfig类下,增加如下代码,这样用户应该会知道是怎么配置了。
` @bean
public UserDetailsService userDetailsService() {
return new UserDetailService();
}

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(userDetailsService()).passwordEncoder(passwordEncoder());
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants