Skip to content

Commit

Permalink
修改删除Token的接口
Browse files Browse the repository at this point in the history
  • Loading branch information
leecho committed Apr 19, 2018
1 parent 6afaa6f commit 9e94bab
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
import org.springframework.security.oauth2.provider.endpoint.FrameworkEndpoint;
import org.springframework.security.oauth2.provider.token.ConsumerTokenServices;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;
Expand All @@ -18,20 +21,18 @@
* @author LIQIU
* @date 2018-3-26
**/
@RestController
@FrameworkEndpoint
@Api(tags = "登出接口")
public class TokenRevokeEndpoint {

@Autowired
@Qualifier("consumerTokenServices")
private ConsumerTokenServices tokenServices;

@PostMapping("/oauth/logout")
@DeleteMapping("/oauth/token")
@ApiOperation("退出登录")
public Result<String> deleteAccessToken(Principal principal){
OAuth2Authentication auth2Authentication = (OAuth2Authentication)principal;
OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails)auth2Authentication.getDetails();
tokenServices.revokeToken(details.getTokenValue());
public Result<String> deleteAccessToken(@RequestParam("access_token") String accessToken){
tokenServices.revokeToken(accessToken);
return Result.buildSuccess("");
}

Expand Down

0 comments on commit 9e94bab

Please sign in to comment.