Home > Back-end >  Inquire of Spring Security for the custom user information, master
Inquire of Spring Security for the custom user information, master

Time:10-02


As shown above, I first through loadUserByUsername method returns a custom populated UserDetails object, this object contains the organization department, the extra information such as user ID; I think in the controller through Authentication object to get the information how to obtain, directly casts no, below

CodePudding user response:

The authentication directly. GetPricipal equivalent userdetail

CodePudding user response:

reference 1/f, el alamein regretless reply:
directly to the authentication. GetPricipal equivalent userdetail


Forced to turn is an error, the authentication. GetPrincipal returns the String type

CodePudding user response:

reference 1/f, el alamein regretless reply:
directly to the authentication. GetPricipal equivalent userdetail


refer to the second floor weixin_38840522 response:
Quote: refer to 1st floor el alamein regretless reply:

The authentication directly. GetPricipal equivalent userdetail


Forced to turn is an error, the authentication. GetPrincipal returns the type String


I think you don't have the certification success
 public class AuthenticationSuccessHandlerImpl implements AuthenticationSuccessHandler {

@ Override
Public void onAuthenticationSuccess (it request, HttpServletResponse response,
The Authentication Authentication) throws IOException, ServletException {

Populated UserDetails populated UserDetails=(populated UserDetails) authentication. GetPrincipal ();
}

See if you can program to here

CodePudding user response:

Should be a successful authentication, the authentication token is obtained, and other resources can be accessed through the token, but cannot get populated UserDetails object