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:
Java code
- /**
- * User logoff
- * @param accesstoken
- * @return
- */
- @RequestMapping (value = "/user/logout", method = Requestmethod.post)
- Public Responsevo userlogout (@RequestHeader (value = "Accesstoken", required = true) String Accesstoken,
- @RequestHeader (value = "userid", required = true) Long userId) throws exception{
- Oauthaccesstoken Oauthaccesstoken = Usermgrservice.getoauthaccesstoken (Accesstoken);
- if (null = = Oauthaccesstoken) {
- return Userresponsecode.buildenumresponsevo (userresponsecode.response_code_oauth_accesstoken_empty, null );
- }
- //delete Oauthtoken records
- 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.
From now on, I will be documenting the process and essence of the recent development of the spring cloud micro-service cloud architecture to help more friends who are interested in developing the Spring cloud framework to explore the process of building the spring cloud architecture and how to use it in enterprise projects. Source Source
Spring Cloud Cloud architecture-SSO Single Sign-on OAuth2.0 logout process (3)