| | |
| | | import org.springframework.http.server.reactive.ServerHttpResponse; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.AntPathMatcher; |
| | | import org.springframework.util.Base64Utils; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import reactor.core.publisher.Flux; |
| | | import reactor.core.publisher.Mono; |
| | |
| | | return chain.filter(exchange); |
| | | } |
| | | |
| | | |
| | | |
| | | //校验 Token 合法性 |
| | | ServerHttpResponse resp = exchange.getResponse(); |
| | | String headerToken = exchange.getRequest().getHeaders().getFirst(AuthProvider.AUTH_KEY); |
| | |
| | | String token = new String(decoded); |
| | | int index = token.indexOf(":"); |
| | | |
| | | String [] tokens = new String[]{token.substring(0, index), token.substring(index + 1)}; |
| | | String[] tokens = new String[]{token.substring(0, index), token.substring(index + 1)}; |
| | | if (tokens.length <= 0) { |
| | | return unAuth(resp, "缺失令牌,鉴权失败"); |
| | | } |
| | |
| | | private boolean isSkip(String path) { |
| | | return AuthProvider.getDefaultSkipUrl().stream().anyMatch(pattern -> antPathMatcher.match(pattern, path)) |
| | | || authProperties.getSkipUrl().stream().anyMatch(pattern -> antPathMatcher.match(pattern, path)) |
| | | || authProperties.getAuth().stream().anyMatch(auth -> antPathMatcher.match(auth.getPattern(), path)) |
| | | || authProperties.getBasic().stream().anyMatch(basic -> antPathMatcher.match(basic.getPattern(), path)) |
| | | || authProperties.getAuth().stream().anyMatch(auth -> antPathMatcher.match(auth.getPattern(), path)) |
| | | || authProperties.getBasic().stream().anyMatch(basic -> antPathMatcher.match(basic.getPattern(), path)) |
| | | || authProperties.getSign().stream().anyMatch(sign -> antPathMatcher.match(sign.getPattern(), path)); |
| | | } |
| | | |