I based on the framework of the use of OAuth2.0 summary, drawing a user name + password to achieve OAuth2.0 login certification flowchart, today we look at the logout process:
/** * User logoff * @param accesstoken * @return */@RequestMapping (value = "/user/logout", Metho D = requestmethod.post) public Responsevo userlogout (@RequestHeader (value = "Accesstoken", required = true) String access Token, @RequestHeader (value = "userid", required = True) Long userId) throws exception{Oauthaccesstoken Oauthac Cesstoken = Usermgrservice.getoauthaccesstoken (Accesstoken); if (null = = Oauthaccesstoken) {return Userresponsecode.buildenumresponsevo (Userresponsecode.response_code_oauth_ac Cesstoken_empty, NULL); }//Delete oauthtoken record Boolean result = Usermgrservice.revokeoauthtoken (Oauthaccesstoken); if (result) {return Userresponsecode.buildenumresponsevo (userresponsecode.response_return_code_success, NULL); } return Userresponsecode.buildenumresponsevo (Userresponsecode.response_code_system_error, NULL); }
I'm just writing some of the code out here, and we'll post all the code in detail for your reference, from creating a database to every process that executes it.
Integrated Spring Cloud architecture-SSO Single Sign-on OAuth2.0 logout process