Skip to content
Advertisement

Spring security application giving No AuthenticationProvider found for org.springframework.security.authentication.UsernamePasswordAuthenticationToken

I am new to spring boot. I am trying to implement a simple spring boot security with userdetailsservice in Spring Tool Suite(STS).

Below is the controller I used:

JavaScript

And the Web security configuration code:

JavaScript

I gave all the required dependencies in pom.xml.

So, I have added below line in application.propperties file, and now system is not generating security password.

JavaScript

And I have included user details Service for credentials. Below is user detail service class

JavaScript

and userPrincipal class

JavaScript

now, when I ran the application using http://localhost:8081/ url, it is giving “No AuthenticationProvider found for org.springframework.security.authentication.UsernamePasswordAuthenticationToken“.

I am using Spring tool suite(STS) to run this project. Can some one point out what am I doing wrong here?

Advertisement

Answer

Do not exclude the entire SecurityAutoConfiguration, instead if you want you should just exclude the org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration.

Alternatively, you can expose a UserDetailsService bean that will do the same for you, and you can get rid of the configureGlobal method, like so:

JavaScript
Advertisement