I have configured spring boot security, by adding the dependency in pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
And the following class:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(final HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers(HttpMethod.GET, "/api").authenticated().and().httpBasic();
http.csrf().disable();
}
}
I have also added These properties in yml:
security:
user: user
Password: user
And am using postman, my URL to secure is:
http://localhost:8080/api
and am adding authorization : type is Basic Auth and username is user and Password is user are also added
But everytime i do Get on this URL, i get 401 unauthorized error.
Please any help is great