How to get Spring Boot and OAuth2 example to use password grant credentials other than the default How to get Spring Boot and OAuth2 example to use password grant credentials other than the default spring spring

How to get Spring Boot and OAuth2 example to use password grant credentials other than the default


As I'm still on 2.0.3, I tried a few more things and this appears to be working:

@Configuration@EnableWebSecurity@EnableGlobalMethodSecurity(prePostEnabled = true)protected static class WebSecurityConfig extends WebSecurityConfigurerAdapter {    @Override    protected void configure(AuthenticationManagerBuilder authManagerBuilder) throws Exception {        authManagerBuilder            .inMemoryAuthentication()                .withUser("user1").password("password1").roles("USER").and()                .withUser("admin1").password("password1").roles("ADMIN");    }    @Bean    @Override    public AuthenticationManager authenticationManager() throws Exception {        return super.authenticationManager();    }}

By explicitly defining the authenticationManager bean, the built-in user authentication went away and it started relying on my own inMemoryAuthentication. When 2.0.4 is released, I'll re-evaluate the solution that Dave posted above as it looks like it will be more elegant.


@Configurationprotected static class AuthenticationManagerConfiguration extends GlobalAuthenticationConfigurerAdapter {        @Override        public void init(AuthenticationManagerBuilder auth) throws Exception {            auth.inMemoryAuthentication().withUser("min").password("min").roles("USER");        }    }