InternalAuthenticationServiceException
Closed this issue · 5 comments
whenever I try to login it throws this exception (org.springframework.security.authentication.InternalAuthenticationServiceException), and I don't know why.
That's because when you configured your authentication manager in your spring security configuration class you call userDetailsService
to set your service implementation, which returns a DaoAuthenticationConfigurer
, that means a DaoAuthenticationProvider
will be used to authenticate...
In short spring security is going to the database to check for username and password match without you having to directly fetch those coulmns so this line: final Authentication authentication=authenticationManager.authenticate
inside your authentication controller has to be inside a transaction.
@taherabdo1 is that fixing your problem?
InternalAuthenticationServiceException can happen in many cases. @taherabdo1 my first question to you did you make any changes in the project i.e custom alterations e.t.c if Yes please mention that.
Right now what I can suggest look into the database for in case if there is any inconsistency. I have faced similar problem before and figured it was related to data inconsistency.
@danielGz I think
authentication controller has to be inside a transaction
is not mandatory unless op using it in a production environment where thousands of users are performing CRUD operations on USER and ROLE table , it is simply fetching records from DB.
P.S I had alterations on default import.sql and forgot to put fill role names.
Hi guys, however danielGz's comment opened my eyes on the problem this was not the problem in my case, the issue resolved when I added ( @query("Select u From User u where u.username =:username") ) on "findByUsername" method in user repository.
so my problem was in the data access layer, and still I don't know why spring data doesn't work properly, as the method should work without this annotation in this case.
OK, that's really strange, but I'm glad to hear that you fixed your problem this way. Since the problem isn't related to this demo anymore I close this ticket.