diff --git a/hsweb-authorization/hsweb-authorization-api/pom.xml b/hsweb-authorization/hsweb-authorization-api/pom.xml index 9862aafaa..203c990db 100644 --- a/hsweb-authorization/hsweb-authorization-api/pom.xml +++ b/hsweb-authorization/hsweb-authorization-api/pom.xml @@ -5,10 +5,11 @@ hsweb-authorization org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 + ${artifactId} 授权,权限管理API hsweb-authorization-api diff --git a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/Authorize.java b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/Authorize.java index 6921ea32c..c8e647c08 100644 --- a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/Authorize.java +++ b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/Authorize.java @@ -44,6 +44,14 @@ Dimension[] dimension() default {}; + /** + * 是否运行匿名访问,匿名访问时,直接允许执行,否则将进行权限验证. + * + * @return 是否允许匿名访问 + * @since 4.0.19 + */ + boolean anonymous() default false; + /** * 验证失败时返回的消息 * diff --git a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/define/AuthorizeDefinition.java b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/define/AuthorizeDefinition.java index b1c4e8b00..8ab805bd1 100644 --- a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/define/AuthorizeDefinition.java +++ b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/define/AuthorizeDefinition.java @@ -21,6 +21,10 @@ public interface AuthorizeDefinition { boolean isEmpty(); + default boolean allowAnonymous() { + return false; + } + default String getDescription() { ResourcesDefinition res = getResources(); StringJoiner joiner = new StringJoiner(";"); diff --git a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/token/UserTokenBeforeCreateEvent.java b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/token/UserTokenBeforeCreateEvent.java new file mode 100644 index 000000000..ddcaa8967 --- /dev/null +++ b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/token/UserTokenBeforeCreateEvent.java @@ -0,0 +1,19 @@ +package org.hswebframework.web.authorization.token; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import org.hswebframework.web.event.DefaultAsyncEvent; + +@Getter +@Setter +@AllArgsConstructor +public class UserTokenBeforeCreateEvent extends DefaultAsyncEvent { + private final UserToken token; + + /** + * 过期时间,单位毫秒,-1为不过期. + */ + private long expires; + +} diff --git a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/token/redis/RedisUserTokenManager.java b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/token/redis/RedisUserTokenManager.java index 4e7af72a2..ff2f00b89 100644 --- a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/token/redis/RedisUserTokenManager.java +++ b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/token/redis/RedisUserTokenManager.java @@ -9,6 +9,7 @@ import org.hswebframework.web.authorization.token.event.UserTokenCreatedEvent; import org.hswebframework.web.authorization.token.event.UserTokenRemovedEvent; import org.hswebframework.web.bean.FastBeanCopier; +import org.hswebframework.web.event.AsyncEvent; import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory; import org.springframework.data.redis.core.*; @@ -44,21 +45,21 @@ public RedisUserTokenManager(ReactiveRedisOperations operations) this.userTokenStore = operations.opsForHash(); this.userTokenMapping = operations.opsForSet(); this.operations - .listenToChannel("_user_token_removed") - .subscribe(msg -> localCache.remove(String.valueOf(msg.getMessage()))); + .listenToChannel("_user_token_removed") + .subscribe(msg -> localCache.remove(String.valueOf(msg.getMessage()))); Flux.create(sink -> this.touchSink = sink) .buffer(Flux.interval(Duration.ofSeconds(10)), HashSet::new) .flatMap(list -> Flux - .fromIterable(list) - .flatMap(token -> { - String key = getTokenRedisKey(token.getToken()); - return Mono - .zip(this.userTokenStore.put(key, "lastRequestTime", token.getLastRequestTime()), - this.operations.expire(key, Duration.ofMillis(token.getMaxInactiveInterval()))) - .then(); - }) - .onErrorResume(err -> Mono.empty())) + .fromIterable(list) + .flatMap(token -> { + String key = getTokenRedisKey(token.getToken()); + return Mono + .zip(this.userTokenStore.put(key, "lastRequestTime", token.getLastRequestTime()), + this.operations.expire(key, Duration.ofMillis(token.getMaxInactiveInterval()))) + .then(); + }) + .onErrorResume(err -> Mono.empty())) .subscribe(); } @@ -67,12 +68,12 @@ public RedisUserTokenManager(ReactiveRedisOperations operations) public RedisUserTokenManager(ReactiveRedisConnectionFactory connectionFactory) { this(new ReactiveRedisTemplate<>(connectionFactory, RedisSerializationContext - .newSerializationContext() - .key((RedisSerializer) RedisSerializer.string()) - .value(RedisSerializer.java()) - .hashKey(RedisSerializer.string()) - .hashValue(RedisSerializer.java()) - .build() + .newSerializationContext() + .key((RedisSerializer) RedisSerializer.string()) + .value(RedisSerializer.java()) + .hashKey(RedisSerializer.string()) + .hashValue(RedisSerializer.java()) + .build() )); } @@ -107,82 +108,82 @@ public Mono getByToken(String token) { return Mono.just(inCache); } return userTokenStore - .entries(getTokenRedisKey(token)) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)) - .filter(map -> !map.isEmpty() && map.containsKey("token") && map.containsKey("userId")) - .map(SimpleUserToken::of) - .doOnNext(userToken -> localCache.put(userToken.getToken(), userToken)) - .cast(UserToken.class); + .entries(getTokenRedisKey(token)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)) + .filter(map -> !map.isEmpty() && map.containsKey("token") && map.containsKey("userId")) + .map(SimpleUserToken::of) + .doOnNext(userToken -> localCache.put(userToken.getToken(), userToken)) + .cast(UserToken.class); } @Override public Flux getByUserId(String userId) { String redisKey = getUserRedisKey(userId); return userTokenMapping - .members(redisKey) - .map(String::valueOf) - .flatMap(token -> getByToken(token) - .switchIfEmpty(Mono.defer(() -> userTokenMapping - .remove(redisKey, token) - .then(Mono.empty())))); + .members(redisKey) + .map(String::valueOf) + .flatMap(token -> getByToken(token) + .switchIfEmpty(Mono.defer(() -> userTokenMapping + .remove(redisKey, token) + .then(Mono.empty())))); } @Override public Mono userIsLoggedIn(String userId) { return getByUserId(userId) - .any(UserToken::isNormal); + .any(UserToken::isNormal); } @Override public Mono tokenIsLoggedIn(String token) { return getByToken(token) - .map(UserToken::isNormal) - .defaultIfEmpty(false); + .map(UserToken::isNormal) + .defaultIfEmpty(false); } @Override public Mono totalUser() { return operations - .scan(ScanOptions - .scanOptions() - .match("*user-token-user:*") - .build()) - .count() - .map(Long::intValue); + .scan(ScanOptions + .scanOptions() + .match("*user-token-user:*") + .build()) + .count() + .map(Long::intValue); } @Override public Mono totalToken() { return operations - .scan(ScanOptions - .scanOptions() - .match("*user-token:*") - .build()) - .count() - .map(Long::intValue); + .scan(ScanOptions + .scanOptions() + .match("*user-token:*") + .build()) + .count() + .map(Long::intValue); } @Override public Flux allLoggedUser() { return operations - .scan(ScanOptions - .scanOptions() - .match("*user-token:*") - .build()) - .map(val -> String.valueOf(val).substring(11)) - .flatMap(this::getByToken); + .scan(ScanOptions + .scanOptions() + .match("*user-token:*") + .build()) + .map(val -> String.valueOf(val).substring(11)) + .flatMap(this::getByToken); } @Override public Mono signOutByUserId(String userId) { return this - .getByUserId(userId) - .flatMap(userToken -> operations - .delete(getTokenRedisKey(userToken.getToken())) - .then(onTokenRemoved(userToken))) - .then(operations.delete(getUserRedisKey(userId))) - .then(); + .getByUserId(userId) + .flatMap(userToken -> operations + .delete(getTokenRedisKey(userToken.getToken())) + .then(onTokenRemoved(userToken))) + .then(operations.delete(getUserRedisKey(userId))) + .then(); } @Override @@ -190,96 +191,124 @@ public Mono signOutByToken(String token) { //delete token //srem user token return getByToken(token) - .flatMap(t -> operations - .delete(getTokenRedisKey(t.getToken())) - .then(userTokenMapping.remove(getUserRedisKey(t.getUserId()), token)) - .then(onTokenRemoved(t)) - ) - .then(); + .flatMap(t -> operations + .delete(getTokenRedisKey(t.getToken())) + .then(userTokenMapping.remove(getUserRedisKey(t.getUserId()), token)) + .then(onTokenRemoved(t)) + ) + .then(); } @Override public Mono changeUserState(String userId, TokenState state) { return getByUserId(userId) - .flatMap(token -> changeTokenState(token.getToken(), state)) - .then(); + .flatMap(token -> changeTokenState(token.getToken(), state)) + .then(); } @Override public Mono changeTokenState(String token, TokenState state) { return getByToken(token) - .flatMap(old -> { - SimpleUserToken newToken = FastBeanCopier.copy(old, new SimpleUserToken()); - newToken.setState(state); - return userTokenStore - .put(getTokenRedisKey(token), "state", state.getValue()) - .then(onTokenChanged(old, newToken)); - }); + .flatMap(old -> { + SimpleUserToken newToken = FastBeanCopier.copy(old, new SimpleUserToken()); + newToken.setState(state); + return userTokenStore + .put(getTokenRedisKey(token), "state", state.getValue()) + .then(onTokenChanged(old, newToken)); + }); + } + + protected Mono sign0(String token, + String type, + String userId, + long expires, + boolean ignoreAllopatricLoginMode, + Consumer> cacheBuilder) { + return Mono.defer(() -> { + Map map = new HashMap<>(); + map.put("token", token); + map.put("type", type); + map.put("userId", userId); + map.put("maxInactiveInterval", expires); + map.put("state", TokenState.normal.getValue()); + map.put("signInTime", System.currentTimeMillis()); + map.put("lastRequestTime", System.currentTimeMillis()); + cacheBuilder.accept(map); + String key = getTokenRedisKey(token); + SimpleUserToken userToken = SimpleUserToken.of(map); + + // 推送事件,自定义过期时间等场景 + UserTokenBeforeCreateEvent event = new UserTokenBeforeCreateEvent(userToken, expires); + + return this + .publishEvent(event) + .then(Mono.defer(() -> { + map.put("maxInactiveInterval", event.getExpires()); + if (event.getExpires() > 0) { + return userTokenStore + .putAll(key, map) + .then(operations.expire(key, Duration.ofMillis(event.getExpires()))); + } + return userTokenStore.putAll(key, map); + })) + .then(userTokenMapping.add(getUserRedisKey(userId), token)) + .thenReturn(userToken); + }); } private Mono signIn(String token, String type, String userId, long maxInactiveInterval, + boolean ignoreAllopatricLoginMode, Consumer> cacheBuilder) { long expires = maxTokenExpires.isNegative() ? maxInactiveInterval : Math.min(maxInactiveInterval, maxTokenExpires.toMillis()); return Mono - .defer(() -> { - Mono doSign = Mono.defer(() -> { - Map map = new HashMap<>(); - map.put("token", token); - map.put("type", type); - map.put("userId", userId); - map.put("maxInactiveInterval", expires); - map.put("state", TokenState.normal.getValue()); - map.put("signInTime", System.currentTimeMillis()); - map.put("lastRequestTime", System.currentTimeMillis()); - cacheBuilder.accept(map); - String key = getTokenRedisKey(token); - return userTokenStore - .putAll(key, map) - .then(Mono.defer(() -> { - if (expires > 0) { - return operations.expire(key, Duration.ofMillis(expires)); - } - return Mono.empty(); - })) - .then(userTokenMapping.add(getUserRedisKey(userId), token)) - .thenReturn(SimpleUserToken.of(map)); - }); - - AllopatricLoginMode mode = allopatricLoginModes.getOrDefault(type, allopatricLoginMode); - if (mode == AllopatricLoginMode.deny) { - return userIsLoggedIn(userId) - .flatMap(r -> { - if (r) { - return Mono.error(new AccessDenyException("error.logged_in_elsewhere", TokenState.deny.getValue())); - } - return doSign; - }); - - } else if (mode == AllopatricLoginMode.offlineOther) { - return getByUserId(userId) - .flatMap(userToken -> { - if (type.equals(userToken.getType())) { - return this.changeTokenState(userToken.getToken(), TokenState.offline); - } - return Mono.empty(); - }) - .then(doSign); - } - + .defer(() -> { + Mono doSign = sign0( + token, + type, + userId, + expires, + ignoreAllopatricLoginMode, + cacheBuilder + ); + + if (ignoreAllopatricLoginMode) { return doSign; - }) - .flatMap(this::onUserTokenCreated); + } + AllopatricLoginMode mode = allopatricLoginModes.getOrDefault(type, allopatricLoginMode); + if (mode == AllopatricLoginMode.deny) { + return userIsLoggedIn(userId) + .flatMap(r -> { + if (r) { + return Mono.error(new AccessDenyException("error.logged_in_elsewhere", TokenState.deny.getValue())); + } + return doSign; + }); + + } else if (mode == AllopatricLoginMode.offlineOther) { + return getByUserId(userId) + .flatMap(userToken -> { + if (type.equals(userToken.getType())) { + return this.changeTokenState(userToken.getToken(), TokenState.offline); + } + return Mono.empty(); + }) + .then(doSign); + } + + return doSign; + }) + .flatMap(this::onUserTokenCreated); } @Override public Mono signIn(String token, String type, String userId, long maxInactiveInterval) { - return signIn(token, type, userId, maxInactiveInterval, ignore -> { + return signIn(token, type, userId, maxInactiveInterval, false, ignore -> { }); } @@ -290,9 +319,10 @@ public Mono signIn(String token, long maxInactiveInterval, Authentication authentication) { return this - .signIn(token, type, userId, maxInactiveInterval, - cache -> cache.put("authentication", authentication)) - .cast(AuthenticationUserToken.class); + .signIn(token, type, userId, maxInactiveInterval, + true, + cache -> cache.put("authentication", authentication)) + .cast(AuthenticationUserToken.class); } @Override @@ -307,32 +337,32 @@ public Mono touch(String token) { return Mono.empty(); } return getByToken(token) - .flatMap(userToken -> { - if (userToken.getMaxInactiveInterval() > 0) { - touchSink.next(userToken); - } - return Mono.empty(); - }); + .flatMap(userToken -> { + if (userToken.getMaxInactiveInterval() > 0) { + touchSink.next(userToken); + } + return Mono.empty(); + }); } @Override public Mono checkExpiredToken() { return operations - .scan(ScanOptions.scanOptions().match("*user-token-user:*").build()) + .scan(ScanOptions.scanOptions().match("*user-token-user:*").build()) + .map(String::valueOf) + .flatMap(key -> userTokenMapping + .members(key) .map(String::valueOf) - .flatMap(key -> userTokenMapping - .members(key) - .map(String::valueOf) - .flatMap(token -> operations - .hasKey(getTokenRedisKey(token)) - .flatMap(exists -> { - if (!exists) { - return userTokenMapping.remove(key, token); - } - return Mono.empty(); - }))) - .then(); + .flatMap(token -> operations + .hasKey(getTokenRedisKey(token)) + .flatMap(exists -> { + if (!exists) { + return userTokenMapping.remove(key, token); + } + return Mono.empty(); + }))) + .then(); } private Mono notifyTokenRemoved(String token) { @@ -360,11 +390,18 @@ private Mono onTokenChanged(UserToken old, SimpleUserToken newToken) { .then(notifyTokenRemoved(newToken.getToken())); } + private Mono publishEvent(AsyncEvent event) { + if (eventPublisher != null) { + return event.publish(eventPublisher); + } + return Mono.empty(); + } + private Mono onUserTokenCreated(SimpleUserToken token) { localCache.put(token.getToken(), token); if (eventPublisher == null) { return notifyTokenRemoved(token.getToken()) - .thenReturn(token); + .thenReturn(token); } return new UserTokenCreatedEvent(token) .publish(eventPublisher) diff --git a/hsweb-authorization/hsweb-authorization-basic/pom.xml b/hsweb-authorization/hsweb-authorization-basic/pom.xml index 440c32d40..4ec16b01c 100644 --- a/hsweb-authorization/hsweb-authorization-basic/pom.xml +++ b/hsweb-authorization/hsweb-authorization-basic/pom.xml @@ -5,10 +5,11 @@ hsweb-authorization org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 + ${artifactId} hsweb-authorization-basic 实现hsweb-authorization-api的相关接口以及使用aop实现RBAC和数据权限的控制 diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/aop/AopAuthorizingController.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/aop/AopAuthorizingController.java index 32a6cf48b..de642d936 100644 --- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/aop/AopAuthorizingController.java +++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/aop/AopAuthorizingController.java @@ -70,7 +70,10 @@ protected Publisher handleReactive0(AuthorizeDefinition definition, .invokeReactive( Authentication .currentReactive() - .switchIfEmpty(Mono.error(UnAuthorizedException.NoStackTrace::new)) + .switchIfEmpty( + context.getDefinition().allowAnonymous() + ? Mono.empty() + : Mono.error(UnAuthorizedException.NoStackTrace::new)) .flatMap(auth -> { context.setAuthentication(auth); //响应式不再支持数据权限控制 @@ -124,7 +127,7 @@ public Object invoke(MethodInvocation methodInvocation) throws Throwable { Class returnType = methodInvocation.getMethod().getReturnType(); //handle reactive method if (Publisher.class.isAssignableFrom(returnType)) { - return handleReactive0(definition, holder, context, () -> invokeReactive(methodInvocation)); + return handleReactive0(definition, holder, context, () -> invokeReactive(methodInvocation)); } Authentication authentication = Authentication diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/AuthorizingHandlerAutoConfiguration.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/AuthorizingHandlerAutoConfiguration.java index 618c5068a..83dd6e592 100644 --- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/AuthorizingHandlerAutoConfiguration.java +++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/AuthorizingHandlerAutoConfiguration.java @@ -3,34 +3,20 @@ import org.hswebframework.web.authorization.AuthenticationManager; import org.hswebframework.web.authorization.ReactiveAuthenticationManagerProvider; import org.hswebframework.web.authorization.access.DataAccessController; -import org.hswebframework.web.authorization.access.DataAccessHandler; -import org.hswebframework.web.authorization.basic.aop.AopMethodAuthorizeDefinitionParser; import org.hswebframework.web.authorization.basic.embed.EmbedAuthenticationProperties; import org.hswebframework.web.authorization.basic.embed.EmbedReactiveAuthenticationManager; import org.hswebframework.web.authorization.basic.handler.AuthorizationLoginLoggerInfoHandler; import org.hswebframework.web.authorization.basic.handler.DefaultAuthorizingHandler; import org.hswebframework.web.authorization.basic.handler.UserAllowPermissionHandler; import org.hswebframework.web.authorization.basic.handler.access.DefaultDataAccessController; -import org.hswebframework.web.authorization.basic.twofactor.TwoFactorHandlerInterceptorAdapter; import org.hswebframework.web.authorization.basic.web.*; import org.hswebframework.web.authorization.token.UserTokenManager; -import org.hswebframework.web.authorization.twofactor.TwoFactorValidatorManager; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.*; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -import javax.annotation.Nonnull; -import java.util.List; /** * 权限控制自动配置类 @@ -94,26 +80,6 @@ public BearerTokenParser bearerTokenParser() { return new BearerTokenParser(); } - @Configuration - public static class DataAccessHandlerProcessor implements BeanPostProcessor { - - @Autowired - private DefaultDataAccessController defaultDataAccessController; - - @Override - public Object postProcessBeforeInitialization(Object bean, String beanName) { - return bean; - } - - @Override - public Object postProcessAfterInitialization(Object bean, String beanName) { - if (bean instanceof DataAccessHandler) { - defaultDataAccessController.addHandler(((DataAccessHandler) bean)); - } - return bean; - } - } - @Configuration @ConditionalOnProperty(prefix = "hsweb.authorize", name = "basic-authorization", havingValue = "true") diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/define/DefaultBasicAuthorizeDefinition.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/define/DefaultBasicAuthorizeDefinition.java index 624261eee..d41ce68c6 100644 --- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/define/DefaultBasicAuthorizeDefinition.java +++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/define/DefaultBasicAuthorizeDefinition.java @@ -41,18 +41,25 @@ public class DefaultBasicAuthorizeDefinition implements AopAuthorizeDefinition { private Phased phased = Phased.before; + private boolean allowAnonymous = false; + @Override public boolean isEmpty() { return false; } + @Override + public boolean allowAnonymous() { + return allowAnonymous; + } + private static final Set> types = new HashSet<>(Arrays.asList( - Authorize.class, - DataAccess.class, - Dimension.class, - Resource.class, - ResourceAction.class, - DataAccessType.class + Authorize.class, + DataAccess.class, + Dimension.class, + Resource.class, + ResourceAction.class, + DataAccessType.class )); public static AopAuthorizeDefinition from(Class targetClass, Method method) { @@ -74,6 +81,9 @@ public void putAnnotation(Authorize ann) { for (Dimension dimension : ann.dimension()) { putAnnotation(dimension); } + if (ann.anonymous()) { + allowAnonymous = true; + } } public void putAnnotation(Dimension ann) { diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/UserTokenWebFilter.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/UserTokenWebFilter.java index 711b32d73..82c9bd134 100644 --- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/UserTokenWebFilter.java +++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/UserTokenWebFilter.java @@ -11,6 +11,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.event.EventListener; +import org.springframework.core.annotation.Order; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; @@ -29,6 +30,7 @@ @Component @Slf4j +@Order(1) public class UserTokenWebFilter implements WebFilter, BeanPostProcessor { private final List parsers = new ArrayList<>(); @@ -43,41 +45,46 @@ public class UserTokenWebFilter implements WebFilter, BeanPostProcessor { public Mono filter(@NonNull ServerWebExchange exchange, WebFilterChain chain) { return Flux - .fromIterable(parsers) - .flatMap(parser -> parser.parseToken(exchange)) - .next() - .map(token -> chain - .filter(exchange) - .contextWrite(Context.of(ParsedToken.class, token))) - .defaultIfEmpty(chain.filter(exchange)) - .flatMap(Function.identity()) - .contextWrite(ReactiveLogger.start("requestId", exchange.getRequest().getId())); + .fromIterable(parsers) + .flatMap(parser -> parser.parseToken(exchange)) + .next() + .map(token -> chain + .filter(exchange) + .contextWrite(Context.of(ParsedToken.class, token))) + .defaultIfEmpty(chain.filter(exchange)) + .flatMap(Function.identity()) + .contextWrite(ReactiveLogger.start("requestId", exchange.getRequest().getId())); } @EventListener public void handleUserSign(AuthorizationSuccessEvent event) { ReactiveUserTokenGenerator generator = event - .getParameter("tokenType") - .map(tokenGeneratorMap::get) - .orElseGet(() -> tokenGeneratorMap.get("default")); + .getParameter("tokenType") + .map(tokenGeneratorMap::get) + .orElseGet(() -> tokenGeneratorMap.get("default")); if (generator != null) { GeneratedToken token = generator.generate(event.getAuthentication()); event.getResult().putAll(token.getResponse()); if (StringUtils.hasText(token.getToken())) { event.getResult().put("token", token.getToken()); - long expires = event.getParameter("expires") - .map(String::valueOf) - .map(Long::parseLong) - .orElse(token.getTimeout()); - event.getResult().put("expires", expires); - event.async(userTokenManager - .signIn(token.getToken(), token.getType(), event - .getAuthentication() - .getUser() - .getId(), expires) - .doOnNext(t -> log.debug("user [{}] sign in", t.getUserId())) - .then()); + long expires = event + .getParameter("expires") + .map(String::valueOf) + .map(Long::parseLong) + .orElse(token.getTimeout()); + + event.async( + userTokenManager + .signIn(token.getToken(), token.getType(), event + .getAuthentication() + .getUser() + .getId(), expires) + .doOnNext(t -> { + event.getResult().put("expires", t.getMaxInactiveInterval()); + log.debug("user [{}] sign in", t.getUserId()); + }) + .then()); } } diff --git a/hsweb-authorization/hsweb-authorization-oauth2/pom.xml b/hsweb-authorization/hsweb-authorization-oauth2/pom.xml index 6e4c486ab..11c0bb8ca 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/pom.xml +++ b/hsweb-authorization/hsweb-authorization-oauth2/pom.xml @@ -5,10 +5,11 @@ hsweb-authorization org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 + ${artifactId} hsweb-authorization-oauth2 diff --git a/hsweb-authorization/pom.xml b/hsweb-authorization/pom.xml index c1e77eee2..ad5db2179 100644 --- a/hsweb-authorization/pom.xml +++ b/hsweb-authorization/pom.xml @@ -5,10 +5,11 @@ hsweb-framework org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 + ${artifactId} hsweb-authorization pom diff --git a/hsweb-commons/hsweb-commons-api/pom.xml b/hsweb-commons/hsweb-commons-api/pom.xml index 677aa0619..968bb8bb7 100644 --- a/hsweb-commons/hsweb-commons-api/pom.xml +++ b/hsweb-commons/hsweb-commons-api/pom.xml @@ -5,11 +5,12 @@ hsweb-commons org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 hsweb-commons-api + ${artifactId} diff --git a/hsweb-commons/hsweb-commons-crud/pom.xml b/hsweb-commons/hsweb-commons-crud/pom.xml index b47b32830..295c5d57a 100644 --- a/hsweb-commons/hsweb-commons-crud/pom.xml +++ b/hsweb-commons/hsweb-commons-crud/pom.xml @@ -5,11 +5,12 @@ hsweb-commons org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 hsweb-commons-crud + ${artifactId} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/GenericReactiveTreeSupportCrudService.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/GenericReactiveTreeSupportCrudService.java index 708cdf490..684d511c0 100644 --- a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/GenericReactiveTreeSupportCrudService.java +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/GenericReactiveTreeSupportCrudService.java @@ -6,6 +6,8 @@ public abstract class GenericReactiveTreeSupportCrudService, K> implements ReactiveTreeSortEntityService { + private static final int SAVE_BUFFER_SIZE = Integer.getInteger("tree.save.buffer.size", 200); + @Autowired private ReactiveRepository repository; @@ -14,4 +16,8 @@ public ReactiveRepository getRepository() { return repository; } + @Override + public int getBufferSize() { + return SAVE_BUFFER_SIZE; + } } diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/ReactiveTreeSortEntityService.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/ReactiveTreeSortEntityService.java index ed2f20783..97bd0187a 100644 --- a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/ReactiveTreeSortEntityService.java +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/ReactiveTreeSortEntityService.java @@ -303,7 +303,7 @@ default Mono save(Publisher entityPublisher) { .prepare(Flux.from(entityPublisher)) // .doOnNext(e -> e.tryValidate(CreateGroup.class)) .buffer(getBufferSize()) - .flatMap(this.getRepository()::save) + .concatMap(this.getRepository()::save) .reduce(SaveResult::merge); } diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/TreeSortServiceHelper.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/TreeSortServiceHelper.java index 3088b0ef5..0da90387b 100644 --- a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/TreeSortServiceHelper.java +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/TreeSortServiceHelper.java @@ -190,7 +190,7 @@ private void refactorPath() { if (old != null) { PK newParentId = data.getParentId(); //父节点发生变化,更新所有子节点path - if (!Objects.equals(parentId, newParentId)) { + if (newParentId != null && !newParentId.equals(parentId)) { Consumer childConsumer = child -> { //更新了父节点,但是同时也传入的对应的子节点 E readyToUpdate = thisTime.get(child.getId()); diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/sql/DefaultR2dbcExecutor.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/sql/DefaultR2dbcExecutor.java index f1247026b..166d0645b 100644 --- a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/sql/DefaultR2dbcExecutor.java +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/sql/DefaultR2dbcExecutor.java @@ -28,6 +28,7 @@ public class DefaultR2dbcExecutor extends R2dbcReactiveSqlExecutor { @Autowired + @Setter private ConnectionFactory defaultFactory; @Setter diff --git a/hsweb-commons/pom.xml b/hsweb-commons/pom.xml index afd4fd02c..7c478dd31 100644 --- a/hsweb-commons/pom.xml +++ b/hsweb-commons/pom.xml @@ -23,9 +23,10 @@ hsweb-framework org.hswebframework.web - 4.0.18 + 4.0.19 ../pom.xml + ${artifactId} 4.0.0 通用模块 diff --git a/hsweb-concurrent/hsweb-concurrent-cache/pom.xml b/hsweb-concurrent/hsweb-concurrent-cache/pom.xml index ecf183cba..60380b23b 100644 --- a/hsweb-concurrent/hsweb-concurrent-cache/pom.xml +++ b/hsweb-concurrent/hsweb-concurrent-cache/pom.xml @@ -5,11 +5,12 @@ hsweb-concurrent org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 hsweb-concurrent-cache + ${artifactId} diff --git a/hsweb-concurrent/pom.xml b/hsweb-concurrent/pom.xml index 71647ddac..c2058abe3 100644 --- a/hsweb-concurrent/pom.xml +++ b/hsweb-concurrent/pom.xml @@ -5,11 +5,12 @@ hsweb-framework org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 hsweb-concurrent + ${artifactId} pom hsweb-concurrent-cache diff --git a/hsweb-core/pom.xml b/hsweb-core/pom.xml index f5c562521..c3e7d0fa2 100644 --- a/hsweb-core/pom.xml +++ b/hsweb-core/pom.xml @@ -5,12 +5,13 @@ hsweb-framework org.hswebframework.web - 4.0.18 + 4.0.19 ../pom.xml 4.0.0 hsweb-core + ${artifactId} 核心包 diff --git a/hsweb-datasource/hsweb-datasource-api/pom.xml b/hsweb-datasource/hsweb-datasource-api/pom.xml index 18b2d1bd3..e55056f8b 100644 --- a/hsweb-datasource/hsweb-datasource-api/pom.xml +++ b/hsweb-datasource/hsweb-datasource-api/pom.xml @@ -5,13 +5,14 @@ hsweb-datasource org.hswebframework.web - 4.0.18 + 4.0.19 ../pom.xml 4.0.0 hsweb-datasource-api + ${artifactId} 数据源管理API,以及简单的多数据源实现,支持aop,表达式等多种方式切换数据源 diff --git a/hsweb-datasource/hsweb-datasource-jta/pom.xml b/hsweb-datasource/hsweb-datasource-jta/pom.xml index 3f957055b..2725460df 100644 --- a/hsweb-datasource/hsweb-datasource-jta/pom.xml +++ b/hsweb-datasource/hsweb-datasource-jta/pom.xml @@ -5,13 +5,14 @@ hsweb-datasource org.hswebframework.web - 4.0.18 + 4.0.19 ../pom.xml 4.0.0 hsweb-datasource-jta + ${artifactId} 基于atomikos的多数据源实现,支持事务中切换数据源 diff --git a/hsweb-datasource/hsweb-datasource-web/pom.xml b/hsweb-datasource/hsweb-datasource-web/pom.xml index 433fbd6bb..3336b9a56 100644 --- a/hsweb-datasource/hsweb-datasource-web/pom.xml +++ b/hsweb-datasource/hsweb-datasource-web/pom.xml @@ -5,13 +5,14 @@ hsweb-datasource org.hswebframework.web - 4.0.18 + 4.0.19 ../pom.xml 4.0.0 hsweb-datasource-web + ${artifactId} 暴露多数据源的web接口 diff --git a/hsweb-datasource/pom.xml b/hsweb-datasource/pom.xml index e545ac575..55a97d809 100644 --- a/hsweb-datasource/pom.xml +++ b/hsweb-datasource/pom.xml @@ -5,7 +5,7 @@ hsweb-framework org.hswebframework.web - 4.0.18 + 4.0.19 ../pom.xml @@ -14,6 +14,7 @@ 数据源,多数据源,动态数据源 hsweb-datasource + ${artifactId} pom hsweb-datasource-api diff --git a/hsweb-logging/hsweb-access-logging-aop/pom.xml b/hsweb-logging/hsweb-access-logging-aop/pom.xml index edb2060c2..13f8e8030 100644 --- a/hsweb-logging/hsweb-access-logging-aop/pom.xml +++ b/hsweb-logging/hsweb-access-logging-aop/pom.xml @@ -5,12 +5,13 @@ hsweb-logging org.hswebframework.web - 4.0.18 + 4.0.19 ../pom.xml 4.0.0 hsweb-access-logging-aop + ${artifactId} 基于AOP实现访问日志解析,使用spring event发布日志事件. diff --git a/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/AopAccessLoggerSupport.java b/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/AopAccessLoggerSupport.java index 307bfeaa5..87ce9fa69 100644 --- a/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/AopAccessLoggerSupport.java +++ b/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/AopAccessLoggerSupport.java @@ -14,7 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.core.Ordered; +import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.util.ClassUtils; +import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpServletRequest; import java.lang.reflect.Method; @@ -107,6 +109,9 @@ public int getOrder() { @Override public boolean matches(Method method, Class aClass) { + if(null == AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class)){ + return false; + } return loggerParsers.stream().anyMatch(parser -> parser.support(aClass, method)); } } diff --git a/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/ReactiveAopAccessLoggerSupport.java b/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/ReactiveAopAccessLoggerSupport.java index e93b52225..e5060fb7a 100644 --- a/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/ReactiveAopAccessLoggerSupport.java +++ b/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/ReactiveAopAccessLoggerSupport.java @@ -16,10 +16,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.core.Ordered; +import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.util.ClassUtils; import org.springframework.util.ConcurrentReferenceHashMap; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebFilter; import org.springframework.web.server.WebFilterChain; @@ -209,7 +211,10 @@ public boolean matches(@Nonnull Method method, @Nonnull Class aClass) { if (!Publisher.class.isAssignableFrom(method.getReturnType())) { return false; } - + // 只记录API请求 + if(null == AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class)){ + return false; + } AccessLogger ann = AnnotationUtils.findAnnotation(method, AccessLogger.class); if (ann != null && ann.ignore()) { return false; diff --git a/hsweb-logging/hsweb-access-logging-api/pom.xml b/hsweb-logging/hsweb-access-logging-api/pom.xml index c085d49e0..0bf9ae345 100644 --- a/hsweb-logging/hsweb-access-logging-api/pom.xml +++ b/hsweb-logging/hsweb-access-logging-api/pom.xml @@ -5,12 +5,13 @@ hsweb-logging org.hswebframework.web - 4.0.18 + 4.0.19 ../pom.xml 4.0.0 hsweb-access-logging-api + ${artifactId} 访问日志API模块 diff --git a/hsweb-logging/pom.xml b/hsweb-logging/pom.xml index 8dde6c8df..af0447827 100644 --- a/hsweb-logging/pom.xml +++ b/hsweb-logging/pom.xml @@ -23,7 +23,7 @@ hsweb-framework org.hswebframework.web - 4.0.18 + 4.0.19 ../pom.xml 4.0.0 @@ -31,6 +31,7 @@ 日志模块 hsweb-logging + ${artifactId} pom hsweb-access-logging-api diff --git a/hsweb-starter/pom.xml b/hsweb-starter/pom.xml index e3cf55b77..ed904894d 100644 --- a/hsweb-starter/pom.xml +++ b/hsweb-starter/pom.xml @@ -5,11 +5,12 @@ hsweb-framework org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 hsweb-starter + ${artifactId} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/pom.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/pom.xml index 32cba3fcb..ff8006429 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/pom.xml +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/pom.xml @@ -5,11 +5,12 @@ hsweb-system-authorization org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 hsweb-system-authorization-api + ${artifactId} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/event/UserModifiedEvent.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/event/UserModifiedEvent.java index 0d1f0de61..858e06ebe 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/event/UserModifiedEvent.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/event/UserModifiedEvent.java @@ -24,4 +24,7 @@ public class UserModifiedEvent extends DefaultAsyncEvent { //用户是否修改了密码 private boolean passwordModified; + + //新密码原始文本, passwordModified 为 true 时有值 + private String newPassword; } diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/pom.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/pom.xml index 372909055..220c63b8f 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/pom.xml +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/pom.xml @@ -5,11 +5,12 @@ hsweb-system-authorization org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 hsweb-system-authorization-default + ${artifactId} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveUserService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveUserService.java index a7aaae404..71b558668 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveUserService.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveUserService.java @@ -113,18 +113,22 @@ protected Mono doUpdate(UserEntity old, UserEntity newer) { old.getPassword() ); + String newPassword = passwordChanged ? newer.getPassword() : null; if (updatePassword) { newer.setSalt(IDGenerator.RANDOM.generate()); passwordValidator.validate(newer.getPassword()); newer.setPassword(passwordEncoder.encode(newer.getPassword(), newer.getSalt())); } + UserEntity copyEntity = old.copyTo(new UserEntity()); + UserEntity newEntity = newer.copyTo(copyEntity); return getRepository() .createUpdate() .set(newer) .where(newer::getId) .execute() - .flatMap(__ -> new UserModifiedEvent(old, newer, passwordChanged).publish(eventPublisher)) - .thenReturn(newer) + .flatMap(__ -> new UserModifiedEvent(old, newEntity, passwordChanged, newPassword) + .publish(eventPublisher) + .thenReturn(newEntity)) .flatMap(e -> ClearUserAuthorizationCacheEvent .of(e.getId()) .publish(eventPublisher) @@ -202,7 +206,7 @@ public Mono changePassword(String userId, String oldPassword, String ne .set(newer::getPassword) .where(newer::getId) .execute() - .flatMap(e -> new UserModifiedEvent(old, newer, passwordChanged) + .flatMap(e -> new UserModifiedEvent(old, newer, passwordChanged, newPassword) .publish(eventPublisher) .thenReturn(e)); }) diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-oauth2/pom.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-oauth2/pom.xml index 4ada89a76..3f0263965 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-oauth2/pom.xml +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-oauth2/pom.xml @@ -5,12 +5,13 @@ hsweb-system-authorization org.hswebframework.web - 4.0.18 + 4.0.19 ../pom.xml 4.0.0 hsweb-system-authorization-oauth2 + ${artifactId} diff --git a/hsweb-system/hsweb-system-authorization/pom.xml b/hsweb-system/hsweb-system-authorization/pom.xml index d52b9b914..bb9dc5e54 100644 --- a/hsweb-system/hsweb-system-authorization/pom.xml +++ b/hsweb-system/hsweb-system-authorization/pom.xml @@ -5,7 +5,7 @@ hsweb-system org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 pom @@ -17,6 +17,7 @@ hsweb-system-authorization-oauth2 hsweb-system-authorization + ${artifactId} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/pom.xml b/hsweb-system/hsweb-system-dictionary/pom.xml index 4524218ab..6ca7f251c 100644 --- a/hsweb-system/hsweb-system-dictionary/pom.xml +++ b/hsweb-system/hsweb-system-dictionary/pom.xml @@ -5,11 +5,12 @@ hsweb-system org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 hsweb-system-dictionary + ${artifactId} diff --git a/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/configuration/DictionaryProperties.java b/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/configuration/DictionaryProperties.java index e18ad0355..7f73ed524 100644 --- a/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/configuration/DictionaryProperties.java +++ b/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/configuration/DictionaryProperties.java @@ -35,35 +35,30 @@ public Stream> doScanEnum() { CachingMetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(); ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(); - return packages - .parallelStream() - .flatMap(enumPackage -> { - String path = "classpath*:" + ClassUtils.convertClassNameToResourcePath(enumPackage) + "/**/*.class"; - log.info("scan enum dict package:{}", path); - Resource[] resources; + List> classes = new ArrayList<>(); + for (String enumPackage : packages) { + String path = "classpath*:" + ClassUtils.convertClassNameToResourcePath(enumPackage) + "/**/*.class"; + log.info("scan enum dict package:{}", path); + Resource[] resources; + try { + resources = resourcePatternResolver.getResources(path); + } catch (IOException e) { + log.warn("scan enum dict package:{} error:", path, e); + return Stream.empty(); + } + for (Resource resource : resources) { try { - resources = resourcePatternResolver.getResources(path); - } catch (IOException e) { - log.warn("scan enum dict package:{} error:", path, e); - return Stream.empty(); - } - return Stream - .of(resources) - .map(resource -> { - try { - MetadataReader reader = metadataReaderFactory.getMetadataReader(resource); - String name = reader.getClassMetadata().getClassName(); - Class clazz = ClassUtils.forName(name, null); - if (clazz.isEnum() && EnumDict.class.isAssignableFrom(clazz)) { - return clazz; - } - } catch (Throwable ignore) { - - } - return null; - }) - .filter(Objects::nonNull); - }); + MetadataReader reader = metadataReaderFactory.getMetadataReader(resource); + String name = reader.getClassMetadata().getClassName(); + Class clazz = ClassUtils.forName(name, null); + if (clazz.isEnum() && EnumDict.class.isAssignableFrom(clazz)) { + classes.add(clazz); + } + } catch (Throwable ignore) { + } + } + } + return classes.stream(); } } diff --git a/hsweb-system/hsweb-system-file/pom.xml b/hsweb-system/hsweb-system-file/pom.xml index ea7c1807b..984726a6a 100644 --- a/hsweb-system/hsweb-system-file/pom.xml +++ b/hsweb-system/hsweb-system-file/pom.xml @@ -5,11 +5,12 @@ hsweb-system org.hswebframework.web - 4.0.18 + 4.0.19 4.0.0 hsweb-system-file + ${artifactId} diff --git a/hsweb-system/pom.xml b/hsweb-system/pom.xml index e2cf75205..c5bf02d3b 100644 --- a/hsweb-system/pom.xml +++ b/hsweb-system/pom.xml @@ -5,7 +5,7 @@ hsweb-framework org.hswebframework.web - 4.0.18 + 4.0.19 ../pom.xml 4.0.0 @@ -17,5 +17,6 @@ hsweb-system-dictionary hsweb-system + ${artifactId} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 84afb9430..86547506d 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ org.hswebframework.web hsweb-framework - 4.0.18 + 4.0.19 hsweb-starter hsweb-core @@ -89,7 +89,7 @@ 3.2.2 1.6.12 - 4.1.3-SNAPSHOT + 4.1.4 3.0.4 3.0.2 2.7.0 @@ -103,27 +103,18 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.3 + org.sonatype.central + central-publishing-maven-plugin + 0.8.0 true - sonatype-releases - https://oss.sonatype.org/ - true - 120 - - - - org.apache.maven.plugins - maven-release-plugin - - true - false - release - deploy + central + true + validated + ${project.name}-${project.version} + org.apache.maven.plugins maven-gpg-plugin @@ -138,6 +129,7 @@ + org.apache.maven.plugins maven-javadoc-plugin @@ -157,15 +149,10 @@ - - sonatype-releases - sonatype repository - https://oss.sonatype.org/service/local/staging/deploy/maven2 - - sonatype-snapshots - Nexus Snapshot Repository - https://oss.sonatype.org/content/repositories/snapshots + central + Central Snapshot Repository + https://central.sonatype.com/repository/maven-snapshots @@ -415,7 +402,7 @@ commons-beanutils commons-beanutils - 1.9.4 + 1.11.0 @@ -517,11 +504,6 @@ - - releases - Nexus Release Repository - https://nexus.jetlinks.cn/content/repositories/releases/ - snapshots Nexus Snapshot Repository