| | |
| | | package com.doumee.config; |
| | | |
| | | import com.doumee.config.GatewayFilterProperties; |
| | | import com.doumee.config.jwt.JwtTokenUtil; |
| | | import com.doumee.core.utils.Constants; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.server.reactive.ServerHttpResponse; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.util.AntPathMatcher; |
| | | import org.springframework.util.PathMatcher; |
| | |
| | | String token = exchange.getRequest().getHeaders().getFirst(Constants.HEADER_USER_TOKEN); |
| | | if (token == null || token.isEmpty()) { |
| | | return unAuthorize(exchange); |
| | | |
| | | } |
| | | String userInfo =(String) stringRedisTemplate.opsForValue().get(Constants.REDIS_TOKEN_KEY + token); |
| | | if (StringUtils.isBlank(userInfo)) { |
| | | return unAuthorize(exchange); |
| | | } |
| | | jwtTokenUtil.refreshTokenTime(token,userInfo); |
| | | jwtTokenUtil.refreshTokenTime(token); |
| | | //把新的 exchange放回到过滤链 |
| | | ServerHttpRequest request = exchange.getRequest().mutate().header(Constants.HEADER_USER_TOKEN, token).build(); |
| | | ServerWebExchange newExchange = exchange.mutate().request(request).build(); |