(13) 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:


 

/**
	 * 用户注销
	 * @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);
	}
	//刪除OauthToken记录
	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 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 executing the operation.

 

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.

Sources of information and source code

 

Guess you like

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