title: Getting multiple users for basic auth, spring boot security
body: <p>I have a list of users, and I want to use them in my basic auth.</p>
  
  <p>MY code currently looks like this:</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  public class BasicAuthConfig extends WebSecurityConfigurerAdapter {
  
    @Bean
    public PasswordEncoder passwordEncoder(){return new BCryptPasswordEncoder();}
    @Autowired
    private ConfigService configService;
    // Authentication : User --&gt; Roles
    // NoOpPasswordEncoder has been deprecated in Spring security so {noop} is being used to avoid errors
    protected void configure(AuthenticationManagerBuilder auth)
      throws Exception {
      auth.inMemoryAuthentication().passwordEncoder(passwordEncoder())
        .withUser("someuser")
          .password("somepassword")
          .roles("USER");
    }
  
    // Authorization : Role -&gt; Access
    protected void configure(HttpSecurity http) throws Exception {
      http
        .httpBasic()
          .and().authorizeRequests()
            .antMatchers("/actuator/**")
              .permitAll()
            .antMatchers("/tokenservice/**")
              .hasRole("USER")
            .antMatchers("/")
              .permitAll()
          .and().csrf()
          .disable()
            .headers()
            .frameOptions()
          .and().disable()
            .sessionManagement()
            .sessionCreationPolicy(SessionCreationPolicy.STATELESS);
    }}
  </code></pre>
  
  <p>I want to replace "someuser" and "somepassword" with usernames and passwords from my list of users. Currently I can get the list with <code>configService.getCOnfigurations().getUsers()</code>.
  A user just has a username and a password, both strings. How do I go about getting all the usernames and all the passwords into <code>.withUser()</code>?</p>
  
  <p>**EDIT
  I made a simple for loop in the configure, that should do it, but whenever i try to post to my API, it says <code>org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder:99 - Encoded password does not look like BCrypt</code></p>
  
  <p>I used an online bcrypt generator to generate the passwords, and they look like this </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Configurations&gt;
      &lt;Port&gt;8007&lt;/Port&gt;
      &lt;EnableHttps&gt;true&lt;/EnableHttps&gt;
      &lt;KeyStorePath&gt;classpath:ssl-server.jks&lt;/KeyStorePath&gt;
      &lt;KeyPass&gt;changeit&lt;/KeyPass&gt;
      &lt;TokenTtlMillis&gt;15000&lt;/TokenTtlMillis&gt;
    &lt;Users Username="user1"&gt;
        &lt;Password&gt;$2y$10$.8VQR6tJub5uVdVLByItQO8QYGZVuWPhLuBUTQSDJAvVpLAUmuqZ2&lt;/Password&gt;
    &lt;/Users&gt;
    &lt;Users Username="user2"&gt;
      &lt;Password&gt;$2y$10$r/CQz7PZp5banmSzr9OiDe2Kxrda4BhXIBXvvouRnm1w3M72wLQj.&lt;/Password&gt;
    &lt;/Users&gt;
  &lt;/Configurations&gt;
  </code></pre>
  
  <p>the passwords are in plain just password and password2</p>