From 29501487d6005ff105bc0aa90ea0bebc4dfc7992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Tue, 20 Mar 2018 09:15:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=80=80=E5=87=BA=E9=94=80?= =?UTF-8?q?=E6=AF=81token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/controller/AuthenticationController.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pig-auth/src/main/java/com/github/pig/auth/controller/AuthenticationController.java b/pig-auth/src/main/java/com/github/pig/auth/controller/AuthenticationController.java index bd3cf759..15a6661e 100644 --- a/pig-auth/src/main/java/com/github/pig/auth/controller/AuthenticationController.java +++ b/pig-auth/src/main/java/com/github/pig/auth/controller/AuthenticationController.java @@ -3,9 +3,11 @@ package com.github.pig.auth.controller; import com.github.pig.common.constant.SecurityConstants; import com.github.pig.common.util.R; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.cache.annotation.CacheEvict; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.security.core.Authentication; +import org.springframework.security.oauth2.provider.token.ConsumerTokenServices; import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -21,7 +23,8 @@ import org.springframework.web.servlet.ModelAndView; @RequestMapping("/authentication") public class AuthenticationController { @Autowired - private RedisConnectionFactory redisConnectionFactory; + @Qualifier("consumerTokenServices") + private ConsumerTokenServices consumerTokenServices; /** * 认证页面 @@ -46,15 +49,11 @@ public class AuthenticationController { * 清除Redis中 accesstoken refreshtoken * * @param accesstoken accesstoken - * @param refreshToken refreshToken * @return true/false */ @PostMapping("/removeToken") @CacheEvict(value = SecurityConstants.TOKEN_USER_DETAIL, key = "#accesstoken") - public R removeToken(String accesstoken, String refreshToken) { - RedisTokenStore tokenStore = new RedisTokenStore(redisConnectionFactory); - tokenStore.removeRefreshToken(refreshToken); - tokenStore.removeAccessToken(accesstoken); - return new R<>(Boolean.TRUE); + public R removeToken(String accesstoken) { + return new R<>( consumerTokenServices.revokeToken(accesstoken)); } } \ No newline at end of file