diff --git a/README.md b/README.md index 2e995722..5c34b28e 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,3 @@ pig
+ * 动态路由配置表 + *
+ * + * @author lengleng + * @since 2018-05-15 + */ +@Data +@TableName("sys_zuul_route") +public class SysZuulRoute extends Model
+ * 1. properties 配置。
+ * 2. eureka 默认配置。
+ * 3. DB数据库配置。
+ *
+ * @return 路由表
+ */
+ @Override
+ protected LinkedHashMap
+ * security.validate.code.enabled 默认 为false,开启需要设置为true
*/
@Slf4j
@RefreshScope
-@Component("validateCodeFilter")
+@Configuration("validateCodeFilter")
+@ConditionalOnProperty(value = "security.validate.code", havingValue = "true")
public class ValidateCodeFilter extends ZuulFilter {
private static final String EXPIRED_CAPTCHA_ERROR = "验证码已过期,请重新获取";
- @Value("${security.validate.code:true}")
- private boolean isValidate;
@Autowired
private RedisTemplate redisTemplate;
+ @Autowired
+ private FilterIgnorePropertiesConfig filterIgnorePropertiesConfig;
@Override
public String filterType() {
@@ -45,14 +50,33 @@ public class ValidateCodeFilter extends ZuulFilter {
return FilterConstants.SEND_ERROR_FILTER_ORDER + 1;
}
+ /**
+ * 是否校验验证码
+ * 1. 判断验证码开关是否开启
+ * 2. 判断请求是否登录请求
+ * 3. 判断终端是否支持
+ *
+ * @return true/false
+ */
@Override
public boolean shouldFilter() {
HttpServletRequest request = RequestContext.getCurrentContext().getRequest();
- if (isValidate && (StrUtil.containsIgnoreCase(request.getRequestURI(), SecurityConstants.OAUTH_TOKEN_URL)
- || StrUtil.containsIgnoreCase(request.getRequestURI(), SecurityConstants.MOBILE_TOKEN_URL))) {
- return true;
+
+ if (!StrUtil.containsAnyIgnoreCase(request.getRequestURI(),
+ SecurityConstants.OAUTH_TOKEN_URL, SecurityConstants.MOBILE_TOKEN_URL)) {
+ return false;
}
- return false;
+
+ try {
+ String[] clientInfos = AuthUtils.extractAndDecodeHeader(request);
+ if (CollUtil.containsAny(filterIgnorePropertiesConfig.getClients(), Arrays.asList(clientInfos))) {
+ return false;
+ }
+ } catch (IOException e) {
+ log.error("解析终端信息失败", e);
+ }
+
+ return true;
}
@Override
@@ -63,7 +87,6 @@ public class ValidateCodeFilter extends ZuulFilter {
RequestContext ctx = RequestContext.getCurrentContext();
R
+ * 前端控制器 + *
+ * + * @author lengleng + * @since 2018-05-15 + */ +@RestController +@RequestMapping("/client") +public class OauthClientDetailsController extends BaseController { + @Autowired + private SysOauthClientDetailsService sysOauthClientDetailsService; + + /** + * 通过ID查询 + * + * @param id ID + * @return SysOauthClientDetails + */ + @GetMapping("/{id}") + public SysOauthClientDetails get(@PathVariable Integer id) { + return sysOauthClientDetailsService.selectById(id); + } + + + /** + * 分页查询信息 + * + * @param params 分页对象 + * @return 分页对象 + */ + @RequestMapping("/page") + public Page page(@RequestParam Map+ * 动态路由配置表 前端控制器 + *
+ * + * @author lengleng + * @since 2018-05-15 + */ +@RestController +@RequestMapping("/route") +public class ZuulRouteController extends BaseController { + @Autowired + private SysZuulRouteService sysZuulRouteService; + /** + * 通过ID查询 + * + * @param id ID + * @return SysZuulRoute + */ + @GetMapping("/{id}") + public SysZuulRoute get(@PathVariable Integer id) { + return sysZuulRouteService.selectById(id); + } + + /** + * 分页查询信息 + * + * @param params 分页对象 + * @return 分页对象 + */ + @RequestMapping("/page") + public Page page(@RequestParam Map+ * Mapper 接口 + *
+ * + * @author lengleng + * @since 2018-05-15 + */ +public interface SysOauthClientDetailsMapper extends BaseMapper+ * 动态路由配置表 Mapper 接口 + *
+ * + * @author lengleng + * @since 2018-05-15 + */ +public interface SysZuulRouteMapper extends BaseMapper+ * + *
+ * + * @author lengleng + * @since 2018-05-15 + */ +@TableName("sys_oauth_client_details") +public class SysOauthClientDetails extends Model+ * 服务类 + *
+ * + * @author lengleng + * @since 2018-05-15 + */ +public interface SysOauthClientDetailsService extends IService+ * 动态路由配置表 服务类 + *
+ * + * @author lengleng + * @since 2018-05-15 + */ +public interface SysZuulRouteService extends IService
@@ -94,12 +92,13 @@ public class SysMenuServiceImpl extends ServiceImpl
+ * 服务实现类
+ *
+ * 动态路由配置表 服务实现类
+ *