if (!it.isPresent) {
throw JoseException("JWT has not been register")
}
+ // token 已被设为黑名单
if (it.get().status != TradeDict.JWT_STATUS_NORMAL) {
throw JoseException("JWT status error : ${it.get().status}")
}
} catch (e: InvalidJwtException) {
SecurityContextHolder.clearContext()
if (e.hasExpired()) {
+ // jwt 过期后返回 401
apiJwtRepository.deleteById(e.jwtContext.jwtClaims.jwtId)
response.sendError(HttpStatus.UNAUTHORIZED.value(), e.message)
} else {
}
} catch (e: JoseException) {
SecurityContextHolder.clearContext()
- response.sendError(HttpStatus.BAD_REQUEST.value(), e.message)
+ // jwt 失效后返回 401
+ response.sendError(HttpStatus.UNAUTHORIZED.value(), e.message)
}
}
filterChain.doFilter(request, response)