samedi 4 avril 2015

Spring boot ServeletInitializer and Spring Security

I have 2 configuration files. One is the Spring Boot application



@SpringBootApplication
public class Application extends SpringBootServletInitializer {

public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(Application.class, args);
}

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
...
}


And the Spring Security Config. it appears it isn't working. whenever I access localhost:8080 it asks for my username and password. Which I believe I configured in the auth.inMemoryAuthentication().withUser("user").password("password").roles("USER")



@Configuration
@EnableWebSecurity
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter{
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
}
}


but it displays invalid credentials, is there anyway to validate this?


Aucun commentaire:

Enregistrer un commentaire