Implementation example of oau2logout in Spring Cloud, cloudoau22.
Next, we will implement the oau2's logout Function Based on Spring Cloud based on the implementation of oau2's authentication and authorization.
1. added a custom logout Endpoint.
The so-called deregistration only needs to invalidate access_token and refresh_token. We mimic org. springframework. security. oauth2.provider. endpoint. TokenEndpoint to write an Endpoint that invalidates access_token and refresh_token:
@ FrameworkEndpointpublic class RevokeTokenEndpoint {@ Autowired @ Qualifier ("consumerTokenServices") ConsumerTokenServices consumerTokenServices; @ RequestMapping (method = RequestMethod. DELETE, value = "/oauth/token") @ ResponseBody public String revokeToken (String access_token) {if (consumerTokenServices. revokeToken (access_token) {return "logout successful" ;}else {return "logout failed ";}}}
2. logout Request Method
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.