A Violation of the Interface Contract

org.springframework.security.authentication.InternalAuthenticationServiceException: UserDetailsService returned null, which is a violation of interface contract 2017-12-18 13:03:29: INFO: HTTP Status 401: UserDetailsService returned null, which is a violation of the interface contract The text has been successfully updated, but these errors have occurred: For more information, see our tips for writing excellent answers. The controller method is found. The problem is this code: the application is so simple that the controller has less than 200 lines of code. Would it be better if “otherwise” throws a UsernameNotFoundException exception? By clicking “Post your response”, you agree to our terms of use, privacy policy and cookie policy, so check if you have an entry in your database for the administrator user and delete the null return and remove a UsernameNotFoundException exception instead. In UserDetailsServiceImpl.loadUserByUsername(), a null value is returned if the specified user name cannot be found. A simple spring start application has a custom UserDetailsService. The Spring Boot Controller is called by an AngularJS application and authentication requests from the AngularJS application are sent to the backend in the /user URL template. However, logon requests cause the controller logs to indicate that the controller cannot find the /user URL pattern, and therefore the UserDetailsService returns null. What specific changes need to be made to the following code so that client requests for the back-end/user URL pattern can find the controller method and thus correctly instantiate the custom UserDetailsService? Null return is not allowed in a UserDetailsService implementation. By clicking “Sign up for GitHub”, you agree to our Terms of Service and Privacy Policy.

We will occasionally send you account-related emails. Successfully merging a pull request can resolve this issue. And the complete trace of the stack generated by the connection request is: Do you have a question about this project? Sign up for a free GitHub account to open a problem and contact managers and the community. I tested this method with an invalid user name and got the following exception: If invalid credentials are sent in the request, UserDetailsService returns null. .

© 版权声明
点赞0 分享
  • 暂无相关文章