mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-12 21:49:01 +08:00
🐛 Fixing a bug. 配置属性错误导致对外暴露失效
This commit is contained in:
1 parent
30474f03e2
commit
69c49818fa
5 files changed
+10
-10
No files matched your search
+2
-2
@@ -893,7 +893,7 @@ CREATE TABLE `sys_tenant` (
|
||||
-- Records of sys_tenant
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `sys_tenant` VALUES (1, '北京分公司', '1', '', '2019-05-15 00:00:00', '2029-05-15 00:00:00', '0', '0', '', 'admin', '2019-05-15 15:44:57', '2022-12-09 15:27:50', 1601104338798153729);
|
||||
INSERT INTO `sys_tenant` VALUES (1, '北京分公司', '1', '', '2019-05-15 00:00:00', '2029-05-15 00:00:00', '0', '0', '', 'admin', '2019-05-15 15:44:57', '2022-12-09 15:27:50', 1);
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
@@ -916,7 +916,7 @@ CREATE TABLE `sys_tenant_menu` (
|
||||
-- ----------------------------
|
||||
-- Records of sys_tenant_menu
|
||||
-- ----------------------------
|
||||
INSERT INTO `sys_tenant_menu` VALUES (1601104338798153729, '1231', '1000,1100,1101,1102,1103,1104,1200,1201,1202,1203,1300,1301,1302,1303,1304,1305,1400,1401,1402,1403,1404,1500,1501,1502,1503,1600,1601,1602,1603,1604,1605,1601095373834067969,1601095530717814785,1601095569972305921,1601095611131011073', '0', '0', 'admin', ' ', '2022-12-09 14:39:56', '2022-12-09 06:39:56');
|
||||
INSERT INTO `sys_tenant_menu` VALUES (1, '默认租户套餐', '1000,1100,1101,1102,1103,1104,1200,1201,1202,1203,1300,1301,1302,1303,1304,1305,1400,1401,1402,1403,1404,1500,1501,1502,1503,1600,1601,1602,1603,1604,1605,1601095373834067969,1601095530717814785,1601095569972305921,1601095611131011073', '0', '0', 'admin', ' ', '2022-12-09 14:39:56', '2022-12-09 06:39:56');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_user
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 6060
|
||||
port: 7060
|
||||
|
||||
spring:
|
||||
application:
|
||||
|
||||
+5
-5
@@ -39,7 +39,7 @@ import java.util.regex.Pattern;
|
||||
* 资源服务器对外直接暴露URL,如果设置contex-path 要特殊处理
|
||||
*/
|
||||
@Slf4j
|
||||
@ConfigurationProperties(prefix = "security.oauth2.ignore")
|
||||
@ConfigurationProperties(prefix = "security.oauth2.client")
|
||||
public class PermitAllUrlProperties implements InitializingBean {
|
||||
|
||||
private static final Pattern PATTERN = Pattern.compile("\\{(.*?)\\}");
|
||||
@@ -48,11 +48,11 @@ public class PermitAllUrlProperties implements InitializingBean {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private List<String> urls = new ArrayList<>();
|
||||
private List<String> ignoreUrls = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
urls.addAll(Arrays.asList(DEFAULT_IGNORE_URLS));
|
||||
ignoreUrls.addAll(Arrays.asList(DEFAULT_IGNORE_URLS));
|
||||
RequestMappingHandlerMapping mapping = SpringContextHolder.getBean("requestMappingHandlerMapping");
|
||||
Map<RequestMappingInfo, HandlerMethod> map = mapping.getHandlerMethods();
|
||||
|
||||
@@ -62,12 +62,12 @@ public class PermitAllUrlProperties implements InitializingBean {
|
||||
// 获取方法上边的注解 替代path variable 为 *
|
||||
Inner method = AnnotationUtils.findAnnotation(handlerMethod.getMethod(), Inner.class);
|
||||
Optional.ofNullable(method).ifPresent(inner -> Objects.requireNonNull(info.getPathPatternsCondition())
|
||||
.getPatternValues().forEach(url -> urls.add(ReUtil.replaceAll(url, PATTERN, "*"))));
|
||||
.getPatternValues().forEach(url -> ignoreUrls.add(ReUtil.replaceAll(url, PATTERN, "*"))));
|
||||
|
||||
// 获取类上边的注解, 替代path variable 为 *
|
||||
Inner controller = AnnotationUtils.findAnnotation(handlerMethod.getBeanType(), Inner.class);
|
||||
Optional.ofNullable(controller).ifPresent(inner -> Objects.requireNonNull(info.getPathPatternsCondition())
|
||||
.getPatternValues().forEach(url -> urls.add(ReUtil.replaceAll(url, PATTERN, "*"))));
|
||||
.getPatternValues().forEach(url -> ignoreUrls.add(ReUtil.replaceAll(url, PATTERN, "*"))));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class PigBearerTokenExtractor implements BearerTokenResolver {
|
||||
|
||||
@Override
|
||||
public String resolve(HttpServletRequest request) {
|
||||
boolean match = urlProperties.getUrls().stream()
|
||||
boolean match = urlProperties.getIgnoreUrls().stream()
|
||||
.anyMatch(url -> pathMatcher.match(url, request.getRequestURI()));
|
||||
|
||||
if (match) {
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ public class PigResourceServerConfiguration {
|
||||
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
|
||||
http.authorizeHttpRequests(authorizeRequests -> authorizeRequests
|
||||
.antMatchers(ArrayUtil.toArray(permitAllUrl.getUrls(), String.class)).permitAll().anyRequest()
|
||||
.antMatchers(ArrayUtil.toArray(permitAllUrl.getIgnoreUrls(), String.class)).permitAll().anyRequest()
|
||||
.authenticated())
|
||||
.oauth2ResourceServer(
|
||||
oauth2 -> oauth2.opaqueToken(token -> token.introspector(customOpaqueTokenIntrospector))
|
||||
|
||||
Reference in new issue
Block a user