| | |
| | | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiSort; |
| | | import com.wf.captcha.SpecCaptcha; |
| | | import io.jsonwebtoken.Claims; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.launch.constant.TokenConstant; |
| | | import org.springblade.core.log.annotation.ApiLog; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.core.tool.utils.WebUtil; |
| | | import org.springblade.modules.auth.provider.ITokenGranter; |
| | | import org.springblade.modules.auth.provider.TokenGranterBuilder; |
| | |
| | | if (Func.isEmpty(userInfo.getRoles())) { |
| | | return authInfo.set("error_code", HttpServletResponse.SC_BAD_REQUEST).set("error_description", "未获得用户的角色信息"); |
| | | } |
| | | |
| | | Kv authInfo1 = TokenUtil.createAuthInfo(userInfo); |
| | | String access_token = authInfo1.get("access_token").toString(); |
| | | // 存入redis并设置过期时间为30分钟 |
| | | bladeRedis.setEx(access_token, access_token, Duration.ofMinutes(1)); |
| | | return TokenUtil.createAuthInfo(userInfo); |
| | | } |
| | | |
| | |
| | | CacheUtil.clear(PARAM_CACHE, Boolean.FALSE); |
| | | return Kv.create().set("success", "true").set("msg", "success"); |
| | | } |
| | | |
| | | @GetMapping("/oauth/judgeRefreshToken") |
| | | @ApiOperation(value = "token认证时效") |
| | | public String judgeRefreshToken(String refreshToken) { |
| | | Object o = bladeRedis.get(refreshToken); |
| | | if (o == null) { |
| | | return "token令牌已失效"; |
| | | } else { |
| | | return "token令牌有效"; |
| | | } |
| | | } |
| | | |
| | | } |