2021-02-23 01:11:03 +00:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
|
|
|
|
----
|
|
|
|
@Autowired
|
|
|
|
public void configureGlobal(AuthenticationManagerBuilder auth, DataSource dataSource) throws Exception {
|
|
|
|
auth.jdbcAuthentication()
|
|
|
|
.dataSource(dataSource)
|
|
|
|
.usersByUsernameQuery("SELECT * FROM users WHERE username = ?")
|
|
|
|
.passwordEncoder(new StandardPasswordEncoder()); // Noncompliant
|
|
|
|
|
|
|
|
// OR
|
|
|
|
auth.jdbcAuthentication()
|
|
|
|
.dataSource(dataSource)
|
|
|
|
.usersByUsernameQuery("SELECT * FROM users WHERE username = ?"); // Noncompliant; default uses plain-text
|
|
|
|
|
|
|
|
// OR
|
|
|
|
auth.userDetailsService(...); // Noncompliant; default uses plain-text
|
|
|
|
// OR
|
|
|
|
auth.userDetailsService(...).passwordEncoder(new StandardPasswordEncoder()); // Noncompliant
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
|
|
|
----
|
|
|
|
@Autowired
|
|
|
|
public void configureGlobal(AuthenticationManagerBuilder auth, DataSource dataSource) throws Exception {
|
|
|
|
auth.jdbcAuthentication()
|
|
|
|
.dataSource(dataSource)
|
|
|
|
.usersByUsernameQuery("Select * from users where username=?")
|
|
|
|
.passwordEncoder(new BCryptPasswordEncoder());
|
|
|
|
|
|
|
|
// or
|
|
|
|
auth.userDetailsService(null).passwordEncoder(new BCryptPasswordEncoder());
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
include::../see.adoc[]
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|