File tree Expand file tree Collapse file tree
src/main/java/de/rwth/idsg/steve Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import de .rwth .idsg .steve .utils .PropertiesFileLoader ;
66import lombok .Builder ;
77import lombok .Getter ;
8+ import org .springframework .security .crypto .bcrypt .BCryptPasswordEncoder ;
9+ import org .springframework .security .crypto .password .PasswordEncoder ;
810
911/**
1012 * @author Sevket Goekay <goekay@dbis.rwth-aachen.de>
@@ -66,9 +68,12 @@ public enum SteveConfiguration {
6668 .sqlLogging (p .getBoolean ("db.sql.logging" ))
6769 .build ();
6870
71+ PasswordEncoder encoder = new BCryptPasswordEncoder ();
72+
6973 auth = Auth .builder ()
74+ .passwordEncoder (encoder )
7075 .userName (p .getString ("auth.user" ))
71- .password ( p .getString ("auth.password" ))
76+ .encodedPassword ( encoder . encode ( p .getString ("auth.password" ) ))
7277 .build ();
7378
7479 ocpp = Ocpp .builder ()
@@ -154,8 +159,9 @@ public static class DB {
154159 // Credentials for Web interface access
155160 @ Builder @ Getter
156161 public static class Auth {
162+ private final PasswordEncoder passwordEncoder ;
157163 private final String userName ;
158- private final String password ;
164+ private final String encodedPassword ;
159165 }
160166
161167 // OCPP-related configuration
Original file line number Diff line number Diff line change @@ -27,18 +27,16 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
2727 /**
2828 * Password encoding changed with spring-security 5.0.0. We either have to use a prefix before the password to
2929 * indicate which actual encoder {@link DelegatingPasswordEncoder} should use [1, 2] or specify the encoder as we do.
30- * {@link NoOpPasswordEncoder} is deprecated because it is not secure since it is not a one way hash function and
31- * uses plain text matching, but is good enough for our simple user management and login authorization case.
3230 *
3331 * [1] https://spring.io/blog/2017/11/01/spring-security-5-0-0-rc1-released#password-storage-format
3432 * [2] {@link PasswordEncoderFactories#createDelegatingPasswordEncoder()}
3533 */
3634 @ Autowired
3735 public void configureGlobal (AuthenticationManagerBuilder auth ) throws Exception {
3836 auth .inMemoryAuthentication ()
39- .passwordEncoder (NoOpPasswordEncoder . getInstance ())
37+ .passwordEncoder (CONFIG . getAuth (). getPasswordEncoder ())
4038 .withUser (CONFIG .getAuth ().getUserName ())
41- .password (CONFIG .getAuth ().getPassword ())
39+ .password (CONFIG .getAuth ().getEncodedPassword ())
4240 .roles ("ADMIN" );
4341 }
4442
You can’t perform that action at this time.
0 commit comments