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

Issues regarding the creator of DaoAuthenticationProvider #15973

Open
siwan9 opened this issue Oct 22, 2024 · 0 comments · May be fixed by #15984
Open

Issues regarding the creator of DaoAuthenticationProvider #15973

siwan9 opened this issue Oct 22, 2024 · 0 comments · May be fixed by #15984
Assignees
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement
Milestone

Comments

@siwan9
Copy link

siwan9 commented Oct 22, 2024

Expected Behavior

Add a constructor with AuthenticationProvider as a factor to the DaoAuthenticationProvider class

Current Behavior

DaoAuthenticationProvider has a constructor with a passwordEncoder as a factor and a generator with a basic password encoder in a member variable without having anything as a factor.
code

Context
Hello 👋

The official document guides the invocation of DaoAuthenticationProvider's authenticate method through ProviderManager for basic login using an ID password for Spring Security-supported logins. docs
Since these classes provide the necessary functions for basic login, I think they can be used well when customizing logins.

Although the filter may be in charge of logging in, I created and customized a controller in charge of logging in because I valued the hierarchical structure of controllers, services, and repository.

When using DaoAuthenticationProvider, I think the part that should be customized is UserDetailsService. Because the developer must access the space of the desired path and bring user information, UserDetailsService plays this role.
Although there is a built implementation, DB access technology exists only in JDBC in the implementation that accesses the database, and applications accessing the database through ORM technology such as JPA must be customized for the UserDetails Service to use ORM.

Therefore, what I suggest is to add a generator with UserDetailsService as a factor to the creator of DaoAuthenticationProvider.
There is a setUserDetailsService method, but using it creates a situation in which the empty declaration unit has to violate DIP among SOLID principles.
This is because there is no setUserDetailsService method in the AuthenticationProvider interface, so when declaring a type, the implementation, DaoAuthenticationProvider, must be established as a type and started.

  • Current code violating DIP principles
    image

  • I hope it passes
    image

  • Code I want to add
    image

@siwan9 siwan9 added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Oct 22, 2024
jzheaux added a commit to jzheaux/spring-security that referenced this issue Oct 24, 2024
@jzheaux jzheaux self-assigned this Oct 24, 2024
@jzheaux jzheaux added in: core An issue in spring-security-core and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 24, 2024
@jzheaux jzheaux added this to the 6.5.x milestone Oct 24, 2024
@jzheaux jzheaux linked a pull request Oct 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants