wiselyman / uaa-zuul

使用OAUTH2+Zuul实现认证和授权
770 stars 420 forks source link

关于注销的问题 #11

Open mzywtj opened 6 years ago

mzywtj commented 6 years ago

我发现注销有时候可以注销,有时候不能注销 @Controller public class UserController { @RequestMapping(value = "/user", produces = "application/json") @ResponseBody public Principal user(Principal user){ return user; }

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

@RequestMapping(value = "/loginOut")
@ResponseBody
public String revokeToken(String access_token) {
    try {
        if (consumerTokenServices.revokeToken(access_token)) {
            return "注销成功";
        } else {
            return "注销失败";
        }
    } catch (Exception e) {
        e.printStackTrace();
        return "异常";
    }

}

} 发现这样写就可以实现注销了,当然写个 .antMatchers("/loginOut").permitAll()