(12) Integrate spring cloud architecture - OAuth2.0 logout process for SSO single sign-on (3)

In the last article, I drew a flowchart of OAuth2.0 login authentication based on username + password based on the summary of the use of OAuth2.0 in the framework. Today, let's take a look at the logout process:


 

/**
	 * User logout
	 * @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 the 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 just simply wrote some logout codes here. We will post all the codes in detail in the following articles for your reference, and will record every process from creating the database to performing operations.

 

From now on, I will record the construction process and essence of the recently developed spring cloud microservice cloud architecture to help more friends who are interested in developing the spring cloud framework. Let's discuss the construction process and how of the spring cloud architecture together. Used in enterprise projects.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326182806&siteId=291194637
Recommended