spring-security icon indicating copy to clipboard operation
spring-security copied to clipboard

No introduction to CachingUserDetailsService in the documentation

Open linghengqian opened this issue 2 years ago • 5 comments

Expected Behavior

There should be a subsection in https://docs.spring.io/spring-security/reference/ describing org.springframework.security.authentication.CachingUserDetailsService .

Current Behavior

In fact there is no such text passage to mention this class.

image

Context

This class does not give too much description in the javadoc, and some people use outdated information to judge the role of this class in the closed issues, for example https://github.com/spring-projects/spring-security/issues/2837 .

According to the discussion on Stack Overflow (refer to https://stackoverflow.com/questions/40766098/springcachebasedusercache-is-null ), it seems that many people have the need to cache authentication information, but the official website documentation is not mentioned this class. Should it be mentioned if possible?

Because the function of this class is relatively intuitive and simple, is it the opinion of the community that it is not recommended to use this class? If so, then I think it should be explained in the documentation.

linghengqian avatar Feb 27 '22 17:02 linghengqian

@linghengqian, thanks for the suggestion. I think many don't know of this class, and personally I have always used Spring's @Cacheable annotation for this case. However, the class has been modified as recently as 2018 and is not deprecated, so including a brief description in the documentation should be just fine. Would you like to submit a PR?

sjohnr avatar Mar 01 '22 18:03 sjohnr

Would you like to submit a PR?

I just realized @Cacheable exists. Because I am not familiar with this area, I do not expect me to submit this PR.

linghengqian avatar Mar 01 '22 23:03 linghengqian

@linghengqian, no problem, thanks for the update.

sjohnr avatar Mar 02 '22 18:03 sjohnr

Hello, may I take this task, please?

ghost avatar Mar 10 '22 20:03 ghost

Sure!

sjohnr avatar Mar 11 '22 04:03 sjohnr

@timofeli Any updates?

linghengqian avatar Dec 30 '22 10:12 linghengqian

Hello,

I'd like to take this issue, if it's ok for you.

According to the discussion in this thread, the idea is to recommend using @Cacheable instead of a bean of this class? If so, makes sense to deprecate this class?

FdHerrera avatar Nov 21 '23 17:11 FdHerrera

@FdHerrera

I'd like to take this issue, if it's ok for you.

Thanks!

According to the discussion in this thread, the idea is to recommend using @Cacheable instead of a bean of this class? If so, makes sense to deprecate this class?

I don't think we need to deprecate this class. However, the documentation could show an example of how to use it (declare it as a @Bean wrapping another concrete UserDetailsService) in addition to demonstrating or recommending an alternative using @Cacheable. I think both options would be good for readers to know about.

sjohnr avatar Nov 28 '23 18:11 sjohnr