Open IgorBalog-Eng opened 6 months ago
Current implementation is not optimal. It creates UserProvider per user, instead creating one user provider containing all users.
Possible improvements:
@Bean public UserDetailsService users() { UserDetails user = User.builder() .username("idsUser") .password("$2a$10$MQ5grDaIqDpBjMlG78PFduv.AMRe9cs0CNm/V4cgUubrqdGTFCH3m") .roles("PROXY") .build(); UserDetails admin = User.builder() .username("bob") .password("$2a$12$8ngZQYUF9pATTwNRmLiYeu6XGlLd79eb4FIgr5ezzuAA6tGLxuAyy") .roles("PROXY") .build(); return new InMemoryUserDetailsManager(user, admin); }
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> builder = auth.inMemoryAuthentication();
userProperties.getUserCredentials().keySet().forEach(user -> { String password = userProperties.getPasswordForUser(user); if (password != null) { try { builder.withUser(user).password(password).roles("PROXY"); } catch (Exception e) { logger.error("Error configuring authentication for user " + user, e.getMessage()); } } }); }
Before starting investigate which solution will be optimal and check if both implementations does not create providers per user
Current implementation is not optimal. It creates UserProvider per user, instead creating one user provider containing all users.
Possible improvements:
userProperties.getUserCredentials().keySet().forEach(user -> { String password = userProperties.getPasswordForUser(user); if (password != null) { try { builder.withUser(user).password(password).roles("PROXY"); } catch (Exception e) { logger.error("Error configuring authentication for user " + user, e.getMessage()); } } }); }