From 6fbb9a22e6c9ba094f45324ca3a73b5ed4c7ef93 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Tue, 1 Apr 2025 15:23:29 +0800 Subject: [PATCH 01/20] build: 4.0.19-SNAPSHOT --- hsweb-authorization/hsweb-authorization-api/pom.xml | 2 +- hsweb-authorization/hsweb-authorization-basic/pom.xml | 2 +- hsweb-authorization/hsweb-authorization-oauth2/pom.xml | 2 +- hsweb-authorization/pom.xml | 2 +- hsweb-commons/hsweb-commons-api/pom.xml | 2 +- hsweb-commons/hsweb-commons-crud/pom.xml | 2 +- hsweb-commons/pom.xml | 2 +- hsweb-concurrent/hsweb-concurrent-cache/pom.xml | 2 +- hsweb-concurrent/pom.xml | 2 +- hsweb-core/pom.xml | 2 +- hsweb-datasource/hsweb-datasource-api/pom.xml | 2 +- hsweb-datasource/hsweb-datasource-jta/pom.xml | 2 +- hsweb-datasource/hsweb-datasource-web/pom.xml | 2 +- hsweb-datasource/pom.xml | 2 +- hsweb-logging/hsweb-access-logging-aop/pom.xml | 2 +- hsweb-logging/hsweb-access-logging-api/pom.xml | 2 +- hsweb-logging/pom.xml | 2 +- hsweb-starter/pom.xml | 2 +- .../hsweb-system-authorization-api/pom.xml | 2 +- .../hsweb-system-authorization-default/pom.xml | 2 +- .../hsweb-system-authorization-oauth2/pom.xml | 2 +- hsweb-system/hsweb-system-authorization/pom.xml | 2 +- hsweb-system/hsweb-system-dictionary/pom.xml | 2 +- hsweb-system/hsweb-system-file/pom.xml | 2 +- hsweb-system/pom.xml | 2 +- pom.xml | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) diff --git a/hsweb-authorization/hsweb-authorization-api/pom.xml b/hsweb-authorization/hsweb-authorization-api/pom.xml index 9862aafaa..195d652e3 100644 --- a/hsweb-authorization/hsweb-authorization-api/pom.xml +++ b/hsweb-authorization/hsweb-authorization-api/pom.xml @@ -5,7 +5,7 @@ hsweb-authorization org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT 4.0.0 diff --git a/hsweb-authorization/hsweb-authorization-basic/pom.xml b/hsweb-authorization/hsweb-authorization-basic/pom.xml index 440c32d40..cb9153818 100644 --- a/hsweb-authorization/hsweb-authorization-basic/pom.xml +++ b/hsweb-authorization/hsweb-authorization-basic/pom.xml @@ -5,7 +5,7 @@ hsweb-authorization org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT 4.0.0 diff --git a/hsweb-authorization/hsweb-authorization-oauth2/pom.xml b/hsweb-authorization/hsweb-authorization-oauth2/pom.xml index 6e4c486ab..f7f7d7ba3 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/pom.xml +++ b/hsweb-authorization/hsweb-authorization-oauth2/pom.xml @@ -5,7 +5,7 @@ hsweb-authorization org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT 4.0.0 diff --git a/hsweb-authorization/pom.xml b/hsweb-authorization/pom.xml index c1e77eee2..ee6b2965d 100644 --- a/hsweb-authorization/pom.xml +++ b/hsweb-authorization/pom.xml @@ -5,7 +5,7 @@ hsweb-framework org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT 4.0.0 diff --git a/hsweb-commons/hsweb-commons-api/pom.xml b/hsweb-commons/hsweb-commons-api/pom.xml index 677aa0619..cd8a6e8dd 100644 --- a/hsweb-commons/hsweb-commons-api/pom.xml +++ b/hsweb-commons/hsweb-commons-api/pom.xml @@ -5,7 +5,7 @@ hsweb-commons org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT 4.0.0 diff --git a/hsweb-commons/hsweb-commons-crud/pom.xml b/hsweb-commons/hsweb-commons-crud/pom.xml index b47b32830..b2eb669b5 100644 --- a/hsweb-commons/hsweb-commons-crud/pom.xml +++ b/hsweb-commons/hsweb-commons-crud/pom.xml @@ -5,7 +5,7 @@ hsweb-commons org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT 4.0.0 diff --git a/hsweb-commons/pom.xml b/hsweb-commons/pom.xml index afd4fd02c..7ebea61e5 100644 --- a/hsweb-commons/pom.xml +++ b/hsweb-commons/pom.xml @@ -23,7 +23,7 @@ hsweb-framework org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT ../pom.xml 4.0.0 diff --git a/hsweb-concurrent/hsweb-concurrent-cache/pom.xml b/hsweb-concurrent/hsweb-concurrent-cache/pom.xml index ecf183cba..0089af942 100644 --- a/hsweb-concurrent/hsweb-concurrent-cache/pom.xml +++ b/hsweb-concurrent/hsweb-concurrent-cache/pom.xml @@ -5,7 +5,7 @@ hsweb-concurrent org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT 4.0.0 diff --git a/hsweb-concurrent/pom.xml b/hsweb-concurrent/pom.xml index 71647ddac..522b84b97 100644 --- a/hsweb-concurrent/pom.xml +++ b/hsweb-concurrent/pom.xml @@ -5,7 +5,7 @@ hsweb-framework org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT 4.0.0 diff --git a/hsweb-core/pom.xml b/hsweb-core/pom.xml index f5c562521..7e9fb7dc3 100644 --- a/hsweb-core/pom.xml +++ b/hsweb-core/pom.xml @@ -5,7 +5,7 @@ hsweb-framework org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT ../pom.xml 4.0.0 diff --git a/hsweb-datasource/hsweb-datasource-api/pom.xml b/hsweb-datasource/hsweb-datasource-api/pom.xml index 18b2d1bd3..17c3f50e9 100644 --- a/hsweb-datasource/hsweb-datasource-api/pom.xml +++ b/hsweb-datasource/hsweb-datasource-api/pom.xml @@ -5,7 +5,7 @@ hsweb-datasource org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT ../pom.xml diff --git a/hsweb-datasource/hsweb-datasource-jta/pom.xml b/hsweb-datasource/hsweb-datasource-jta/pom.xml index 3f957055b..0e197c107 100644 --- a/hsweb-datasource/hsweb-datasource-jta/pom.xml +++ b/hsweb-datasource/hsweb-datasource-jta/pom.xml @@ -5,7 +5,7 @@ hsweb-datasource org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT ../pom.xml diff --git a/hsweb-datasource/hsweb-datasource-web/pom.xml b/hsweb-datasource/hsweb-datasource-web/pom.xml index 433fbd6bb..2fdc3b6d2 100644 --- a/hsweb-datasource/hsweb-datasource-web/pom.xml +++ b/hsweb-datasource/hsweb-datasource-web/pom.xml @@ -5,7 +5,7 @@ hsweb-datasource org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT ../pom.xml diff --git a/hsweb-datasource/pom.xml b/hsweb-datasource/pom.xml index e545ac575..fb4f0136d 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-SNAPSHOT ../pom.xml diff --git a/hsweb-logging/hsweb-access-logging-aop/pom.xml b/hsweb-logging/hsweb-access-logging-aop/pom.xml index edb2060c2..dce4f0377 100644 --- a/hsweb-logging/hsweb-access-logging-aop/pom.xml +++ b/hsweb-logging/hsweb-access-logging-aop/pom.xml @@ -5,7 +5,7 @@ hsweb-logging org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT ../pom.xml 4.0.0 diff --git a/hsweb-logging/hsweb-access-logging-api/pom.xml b/hsweb-logging/hsweb-access-logging-api/pom.xml index c085d49e0..a2464762f 100644 --- a/hsweb-logging/hsweb-access-logging-api/pom.xml +++ b/hsweb-logging/hsweb-access-logging-api/pom.xml @@ -5,7 +5,7 @@ hsweb-logging org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT ../pom.xml 4.0.0 diff --git a/hsweb-logging/pom.xml b/hsweb-logging/pom.xml index 8dde6c8df..203f258f2 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-SNAPSHOT ../pom.xml 4.0.0 diff --git a/hsweb-starter/pom.xml b/hsweb-starter/pom.xml index e3cf55b77..f37df0c2a 100644 --- a/hsweb-starter/pom.xml +++ b/hsweb-starter/pom.xml @@ -5,7 +5,7 @@ hsweb-framework org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT 4.0.0 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..ad96c6eeb 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,7 +5,7 @@ hsweb-system-authorization org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT 4.0.0 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..8bc207865 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,7 +5,7 @@ hsweb-system-authorization org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT 4.0.0 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..d16e96bbe 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,7 +5,7 @@ hsweb-system-authorization org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT ../pom.xml 4.0.0 diff --git a/hsweb-system/hsweb-system-authorization/pom.xml b/hsweb-system/hsweb-system-authorization/pom.xml index d52b9b914..17a18f1c7 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-SNAPSHOT 4.0.0 pom diff --git a/hsweb-system/hsweb-system-dictionary/pom.xml b/hsweb-system/hsweb-system-dictionary/pom.xml index 4524218ab..0ee8c76d2 100644 --- a/hsweb-system/hsweb-system-dictionary/pom.xml +++ b/hsweb-system/hsweb-system-dictionary/pom.xml @@ -5,7 +5,7 @@ hsweb-system org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT 4.0.0 diff --git a/hsweb-system/hsweb-system-file/pom.xml b/hsweb-system/hsweb-system-file/pom.xml index ea7c1807b..5351fa264 100644 --- a/hsweb-system/hsweb-system-file/pom.xml +++ b/hsweb-system/hsweb-system-file/pom.xml @@ -5,7 +5,7 @@ hsweb-system org.hswebframework.web - 4.0.18 + 4.0.19-SNAPSHOT 4.0.0 diff --git a/hsweb-system/pom.xml b/hsweb-system/pom.xml index e2cf75205..8799d0eed 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-SNAPSHOT ../pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index 84afb9430..d2be7ba1a 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ org.hswebframework.web hsweb-framework - 4.0.18 + 4.0.19-SNAPSHOT hsweb-starter hsweb-core From 2f082089a6da77646f0849364a41c881722842ab Mon Sep 17 00:00:00 2001 From: hello09x Date: Tue, 1 Apr 2025 17:20:43 +0800 Subject: [PATCH 02/20] =?UTF-8?q?feat:=20UserModifiedEvent=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E6=96=B0=E5=AF=86=E7=A0=81=E5=8E=9F=E5=A7=8B=E6=96=87?= =?UTF-8?q?=E6=9C=AC=20(#315)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/authorization/api/event/UserModifiedEvent.java | 3 +++ .../defaults/service/DefaultReactiveUserService.java | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) 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/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..9f66fe726 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,6 +113,7 @@ 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()); @@ -123,7 +124,7 @@ protected Mono doUpdate(UserEntity old, UserEntity newer) { .set(newer) .where(newer::getId) .execute() - .flatMap(__ -> new UserModifiedEvent(old, newer, passwordChanged).publish(eventPublisher)) + .flatMap(__ -> new UserModifiedEvent(old, newer, passwordChanged, newPassword).publish(eventPublisher)) .thenReturn(newer) .flatMap(e -> ClearUserAuthorizationCacheEvent .of(e.getId()) @@ -202,7 +203,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)); }) From 9a12aa89f61bbeca5922beeac28c0def716abfc1 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Mon, 7 Apr 2025 10:55:50 +0800 Subject: [PATCH 03/20] =?UTF-8?q?refactor:=20=E6=8C=87=E5=AE=9A=E4=BA=86?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=9D=83=E9=99=90=E7=9A=84token=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=BF=BD=E7=95=A5=E5=BC=82=E5=9C=B0=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../token/redis/RedisUserTokenManager.java | 288 +++++++++--------- 1 file changed, 146 insertions(+), 142 deletions(-) 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..6651bacac 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 @@ -44,21 +44,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 +67,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 +107,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 +190,99 @@ 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)); + }); } 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 = 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)); + }); + 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 +293,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 +311,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) { @@ -364,7 +368,7 @@ 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) From c3f59abe7a363a85c8d8378e99918206110f4c48 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Thu, 10 Apr 2025 14:38:16 +0800 Subject: [PATCH 04/20] =?UTF-8?q?refactor:=20=E6=9D=83=E9=99=90=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E5=A2=9E=E5=8A=A0=E5=8C=BF=E5=90=8D=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E6=94=AF=E6=8C=81.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/authorization/annotation/Authorize.java | 8 ++++++++ .../define/AuthorizeDefinition.java | 4 ++++ .../basic/aop/AopAuthorizingController.java | 7 +++++-- .../define/DefaultBasicAuthorizeDefinition.java | 17 +++++++++++------ 4 files changed, 28 insertions(+), 8 deletions(-) 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-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/define/DefaultBasicAuthorizeDefinition.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/define/DefaultBasicAuthorizeDefinition.java index 624261eee..a4762c259 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,20 @@ public class DefaultBasicAuthorizeDefinition implements AopAuthorizeDefinition { private Phased phased = Phased.before; + private boolean allowAnonymous = false; + @Override public boolean isEmpty() { return false; } 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 +76,9 @@ public void putAnnotation(Authorize ann) { for (Dimension dimension : ann.dimension()) { putAnnotation(dimension); } + if (ann.anonymous()) { + allowAnonymous = true; + } } public void putAnnotation(Dimension ann) { From 0ae207408bc5cf123d59f83057a9c12092c9fd9d Mon Sep 17 00:00:00 2001 From: zhouhao Date: Thu, 17 Apr 2025 10:51:27 +0800 Subject: [PATCH 05/20] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0UserTokenBe?= =?UTF-8?q?foreCreateEvent=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../token/UserTokenBeforeCreateEvent.java | 17 ++++ .../token/redis/RedisUserTokenManager.java | 82 +++++++++++++------ 2 files changed, 75 insertions(+), 24 deletions(-) create mode 100644 hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/token/UserTokenBeforeCreateEvent.java 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..eea44a87b --- /dev/null +++ b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/token/UserTokenBeforeCreateEvent.java @@ -0,0 +1,17 @@ +package org.hswebframework.web.authorization.token; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.hswebframework.web.event.DefaultAsyncEvent; + +@Getter +@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 6651bacac..d789157aa 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.*; @@ -219,6 +220,45 @@ public Mono changeTokenState(String token, TokenState state) { }); } + 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()); + 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)); + }); + } + private Mono signIn(String token, String type, String userId, @@ -229,29 +269,16 @@ private Mono signIn(String token, 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)); - }); - if(ignoreAllopatricLoginMode){ + Mono doSign = sign0( + token, + type, + userId, + expires, + ignoreAllopatricLoginMode, + cacheBuilder + ); + + if (ignoreAllopatricLoginMode) { return doSign; } AllopatricLoginMode mode = allopatricLoginModes.getOrDefault(type, allopatricLoginMode); @@ -282,7 +309,7 @@ private Mono signIn(String token, @Override public Mono signIn(String token, String type, String userId, long maxInactiveInterval) { - return signIn(token, type, userId, maxInactiveInterval,false, ignore -> { + return signIn(token, type, userId, maxInactiveInterval, false, ignore -> { }); } @@ -364,6 +391,13 @@ 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) { From 8a73a2281d37f0797cae70ac05ea959a3bc06f70 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Thu, 17 Apr 2025 12:11:10 +0800 Subject: [PATCH 06/20] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E6=97=B6=E9=97=B4=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/authorization/token/redis/RedisUserTokenManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d789157aa..8e2488c60 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 @@ -250,7 +250,7 @@ protected Mono sign0(String token, })) .then(Mono.defer(() -> { if (expires > 0) { - return operations.expire(key, Duration.ofMillis(expires)); + return operations.expire(key, Duration.ofMillis(event.getExpires())); } return Mono.empty(); })) From d2fb65bdce9e32034e5dd8b4b292c33cfb0b2fe9 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Thu, 17 Apr 2025 12:12:55 +0800 Subject: [PATCH 07/20] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E6=97=B6=E9=97=B4=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/authorization/token/redis/RedisUserTokenManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8e2488c60..071aa6405 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 @@ -249,7 +249,7 @@ protected Mono sign0(String token, return userTokenStore.putAll(key, map); })) .then(Mono.defer(() -> { - if (expires > 0) { + if (event.getExpires() > 0) { return operations.expire(key, Duration.ofMillis(event.getExpires())); } return Mono.empty(); From 505f9a387ef93eb9502c55287c684c59fbc12ed2 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Thu, 17 Apr 2025 12:38:23 +0800 Subject: [PATCH 08/20] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E6=97=B6=E9=97=B4=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../token/redis/RedisUserTokenManager.java | 11 ++-- .../AuthorizingHandlerAutoConfiguration.java | 34 ------------ .../basic/web/UserTokenWebFilter.java | 53 ++++++++++--------- 3 files changed, 34 insertions(+), 64 deletions(-) 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 071aa6405..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 @@ -246,16 +246,15 @@ protected Mono sign0(String token, .publishEvent(event) .then(Mono.defer(() -> { map.put("maxInactiveInterval", event.getExpires()); - return userTokenStore.putAll(key, map); - })) - .then(Mono.defer(() -> { if (event.getExpires() > 0) { - return operations.expire(key, Duration.ofMillis(event.getExpires())); + return userTokenStore + .putAll(key, map) + .then(operations.expire(key, Duration.ofMillis(event.getExpires()))); } - return Mono.empty(); + return userTokenStore.putAll(key, map); })) .then(userTokenMapping.add(getUserRedisKey(userId), token)) - .thenReturn(SimpleUserToken.of(map)); + .thenReturn(userToken); }); } 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/web/UserTokenWebFilter.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/UserTokenWebFilter.java index 711b32d73..e3ac261cb 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 @@ -43,41 +43,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()); } } From a1cc9688dee8952901d5e2d819b5baec8b65a66e Mon Sep 17 00:00:00 2001 From: zhouhao Date: Thu, 17 Apr 2025 13:32:56 +0800 Subject: [PATCH 09/20] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E6=97=B6=E9=97=B4=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/authorization/token/UserTokenBeforeCreateEvent.java | 2 ++ 1 file changed, 2 insertions(+) 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 index eea44a87b..ddcaa8967 100644 --- 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 @@ -2,9 +2,11 @@ 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; From 21f14781489881368727366a8f327b530d323ebf Mon Sep 17 00:00:00 2001 From: fighter-wang <118291973+fighter-wang@users.noreply.github.com> Date: Fri, 18 Apr 2025 15:45:58 +0800 Subject: [PATCH 10/20] =?UTF-8?q?fix(=E7=94=A8=E6=88=B7=E4=BF=9D=E5=AD=98)?= =?UTF-8?q?:=20=E4=BF=AE=E5=A4=8D=E4=BF=9D=E5=AD=98=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=97=B6=EF=BC=8C=E6=8A=9B=E5=87=BA=E7=9A=84?= =?UTF-8?q?UserModifiedEvent=E4=BA=8B=E4=BB=B6=E4=B8=AD=E7=9A=84=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E4=B8=8D=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E7=9A=84=E9=97=AE=E9=A2=98=20(#316)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(用户保存): 修复保存用户信息时抛出的UserModifiedEvent事件中的最新用户信息不完整的问题 * fix(用户保存): 代码优化 * fix(用户保存): 修复old实体会被修改的问题 --------- Co-authored-by: fighter-wang <11291691+fighter-wang@user.noreply.gitee.com> --- .../defaults/service/DefaultReactiveUserService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 9f66fe726..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 @@ -119,13 +119,16 @@ protected Mono doUpdate(UserEntity old, UserEntity newer) { 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, newPassword).publish(eventPublisher)) - .thenReturn(newer) + .flatMap(__ -> new UserModifiedEvent(old, newEntity, passwordChanged, newPassword) + .publish(eventPublisher) + .thenReturn(newEntity)) .flatMap(e -> ClearUserAuthorizationCacheEvent .of(e.getId()) .publish(eventPublisher) From 791084d3f3cd816b3919fd09c1b4bdc645ae29c2 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Fri, 25 Apr 2025 17:39:49 +0800 Subject: [PATCH 11/20] =?UTF-8?q?refactor:=20=E5=8F=AA=E8=AE=B0=E5=BD=95ap?= =?UTF-8?q?i=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/logging/aop/AopAccessLoggerSupport.java | 5 +++++ .../web/logging/aop/ReactiveAopAccessLoggerSupport.java | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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; From b3352521fe8911a9d42971ffa98c0f848cdca01a Mon Sep 17 00:00:00 2001 From: Zhang Ji <125540670@qq.com> Date: Mon, 28 Apr 2025 18:36:51 +0800 Subject: [PATCH 12/20] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=A0=91?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E5=AE=9E=E4=BD=93=E7=9A=84=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=20(#319)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hswebframework/web/crud/service/TreeSortServiceHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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()); From 4e9344bf346a50301e4b629c8ea66ec2b2f89553 Mon Sep 17 00:00:00 2001 From: Zhang Ji <125540670@qq.com> Date: Mon, 19 May 2025 15:18:27 +0800 Subject: [PATCH 13/20] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E7=9A=84=E5=B9=B6=E8=A1=8C=E6=89=A7=E8=A1=8C=E5=92=8C?= =?UTF-8?q?=E6=A0=91=E7=BB=93=E6=9E=84=E8=BD=AC=E6=8D=A2=20(#321)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configuration/DictionaryProperties.java | 51 +++++++++---------- 1 file changed, 23 insertions(+), 28 deletions(-) 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(); } } From dd545b10eecf50ee9089501b26036fcc643ba627 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 May 2025 10:45:11 +0800 Subject: [PATCH 14/20] build(deps): bump commons-beanutils:commons-beanutils (#323) Bumps commons-beanutils:commons-beanutils from 1.9.4 to 1.11.0. --- updated-dependencies: - dependency-name: commons-beanutils:commons-beanutils dependency-version: 1.11.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d2be7ba1a..9a0f50a76 100644 --- a/pom.xml +++ b/pom.xml @@ -415,7 +415,7 @@ commons-beanutils commons-beanutils - 1.9.4 + 1.11.0 From 22aaf141b28506dab56c8df3b4ca5729b9a3a461 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Thu, 29 May 2025 16:28:35 +0800 Subject: [PATCH 15/20] =?UTF-8?q?refactor(=E5=9F=BA=E7=A1=80=E6=A8=A1?= =?UTF-8?q?=E5=9D=97):=20=E4=BF=AE=E5=A4=8DallowAnonymous=E5=A4=B1?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basic/define/DefaultBasicAuthorizeDefinition.java | 5 +++++ 1 file changed, 5 insertions(+) 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 a4762c259..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 @@ -48,6 +48,11 @@ public boolean isEmpty() { return false; } + @Override + public boolean allowAnonymous() { + return allowAnonymous; + } + private static final Set> types = new HashSet<>(Arrays.asList( Authorize.class, DataAccess.class, From 303b679a54efcd32906a658b43fbd2b699cc12a9 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Fri, 6 Jun 2025 18:28:19 +0800 Subject: [PATCH 16/20] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96DefaultR2db?= =?UTF-8?q?cExecutor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/hswebframework/web/crud/sql/DefaultR2dbcExecutor.java | 1 + 1 file changed, 1 insertion(+) 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 From 44d3633f34bb80c42486db0973dd5d5f07edfc10 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Mon, 9 Jun 2025 11:59:03 +0800 Subject: [PATCH 17/20] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E9=BB=98?= =?UTF-8?q?=E8=AE=A4buffer=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../crud/service/GenericReactiveTreeSupportCrudService.java | 6 ++++++ .../web/crud/service/ReactiveTreeSortEntityService.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) 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); } From 2177028284b5f6c5fd372527d88f9d1858a55df9 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Tue, 10 Jun 2025 11:51:37 +0800 Subject: [PATCH 18/20] =?UTF-8?q?refactor:=20=E5=8D=87=E7=BA=A7easyorm?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9a0f50a76..13a59626f 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,7 @@ 3.2.2 1.6.12 - 4.1.3-SNAPSHOT + 4.1.4-SNAPSHOT 3.0.4 3.0.2 2.7.0 From f2e933f55f57678aaa1710fca9280f621ef24d24 Mon Sep 17 00:00:00 2001 From: gyl <80454341+goten7@users.noreply.github.com> Date: Tue, 17 Jun 2025 13:40:18 +0800 Subject: [PATCH 19/20] =?UTF-8?q?feat(=E5=9F=BA=E7=A1=80=E6=A8=A1=E5=9D=97?= =?UTF-8?q?):=20=E8=AE=BE=E7=BD=AEtoken=E8=A7=A3=E6=9E=90WebFilter?= =?UTF-8?q?=E7=9A=84=E5=8A=A0=E8=BD=BD=E9=A1=BA=E5=BA=8F=20(#329)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/authorization/basic/web/UserTokenWebFilter.java | 2 ++ 1 file changed, 2 insertions(+) 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 e3ac261cb..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<>(); From 7347cdf2d77e8ec3e20b42924e0051274c83c5f0 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Mon, 30 Jun 2025 11:12:53 +0800 Subject: [PATCH 20/20] build: 4.0.19 release --- .../hsweb-authorization-api/pom.xml | 3 +- .../hsweb-authorization-basic/pom.xml | 3 +- .../hsweb-authorization-oauth2/pom.xml | 3 +- hsweb-authorization/pom.xml | 3 +- hsweb-commons/hsweb-commons-api/pom.xml | 3 +- hsweb-commons/hsweb-commons-crud/pom.xml | 3 +- hsweb-commons/pom.xml | 3 +- .../hsweb-concurrent-cache/pom.xml | 3 +- hsweb-concurrent/pom.xml | 3 +- hsweb-core/pom.xml | 3 +- hsweb-datasource/hsweb-datasource-api/pom.xml | 3 +- hsweb-datasource/hsweb-datasource-jta/pom.xml | 3 +- hsweb-datasource/hsweb-datasource-web/pom.xml | 3 +- hsweb-datasource/pom.xml | 3 +- .../hsweb-access-logging-aop/pom.xml | 3 +- .../hsweb-access-logging-api/pom.xml | 3 +- hsweb-logging/pom.xml | 3 +- hsweb-starter/pom.xml | 3 +- .../hsweb-system-authorization-api/pom.xml | 3 +- .../pom.xml | 3 +- .../hsweb-system-authorization-oauth2/pom.xml | 3 +- .../hsweb-system-authorization/pom.xml | 3 +- hsweb-system/hsweb-system-dictionary/pom.xml | 3 +- hsweb-system/hsweb-system-file/pom.xml | 3 +- hsweb-system/pom.xml | 3 +- pom.xml | 46 ++++++------------- 26 files changed, 64 insertions(+), 57 deletions(-) diff --git a/hsweb-authorization/hsweb-authorization-api/pom.xml b/hsweb-authorization/hsweb-authorization-api/pom.xml index 195d652e3..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.19-SNAPSHOT + 4.0.19 4.0.0 + ${artifactId} 授权,权限管理API hsweb-authorization-api diff --git a/hsweb-authorization/hsweb-authorization-basic/pom.xml b/hsweb-authorization/hsweb-authorization-basic/pom.xml index cb9153818..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.19-SNAPSHOT + 4.0.19 4.0.0 + ${artifactId} hsweb-authorization-basic 实现hsweb-authorization-api的相关接口以及使用aop实现RBAC和数据权限的控制 diff --git a/hsweb-authorization/hsweb-authorization-oauth2/pom.xml b/hsweb-authorization/hsweb-authorization-oauth2/pom.xml index f7f7d7ba3..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.19-SNAPSHOT + 4.0.19 4.0.0 + ${artifactId} hsweb-authorization-oauth2 diff --git a/hsweb-authorization/pom.xml b/hsweb-authorization/pom.xml index ee6b2965d..ad5db2179 100644 --- a/hsweb-authorization/pom.xml +++ b/hsweb-authorization/pom.xml @@ -5,10 +5,11 @@ hsweb-framework org.hswebframework.web - 4.0.19-SNAPSHOT + 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 cd8a6e8dd..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.19-SNAPSHOT + 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 b2eb669b5..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.19-SNAPSHOT + 4.0.19 4.0.0 hsweb-commons-crud + ${artifactId} diff --git a/hsweb-commons/pom.xml b/hsweb-commons/pom.xml index 7ebea61e5..7c478dd31 100644 --- a/hsweb-commons/pom.xml +++ b/hsweb-commons/pom.xml @@ -23,9 +23,10 @@ hsweb-framework org.hswebframework.web - 4.0.19-SNAPSHOT + 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 0089af942..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.19-SNAPSHOT + 4.0.19 4.0.0 hsweb-concurrent-cache + ${artifactId} diff --git a/hsweb-concurrent/pom.xml b/hsweb-concurrent/pom.xml index 522b84b97..c2058abe3 100644 --- a/hsweb-concurrent/pom.xml +++ b/hsweb-concurrent/pom.xml @@ -5,11 +5,12 @@ hsweb-framework org.hswebframework.web - 4.0.19-SNAPSHOT + 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 7e9fb7dc3..c3e7d0fa2 100644 --- a/hsweb-core/pom.xml +++ b/hsweb-core/pom.xml @@ -5,12 +5,13 @@ hsweb-framework org.hswebframework.web - 4.0.19-SNAPSHOT + 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 17c3f50e9..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.19-SNAPSHOT + 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 0e197c107..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.19-SNAPSHOT + 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 2fdc3b6d2..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.19-SNAPSHOT + 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 fb4f0136d..55a97d809 100644 --- a/hsweb-datasource/pom.xml +++ b/hsweb-datasource/pom.xml @@ -5,7 +5,7 @@ hsweb-framework org.hswebframework.web - 4.0.19-SNAPSHOT + 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 dce4f0377..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.19-SNAPSHOT + 4.0.19 ../pom.xml 4.0.0 hsweb-access-logging-aop + ${artifactId} 基于AOP实现访问日志解析,使用spring event发布日志事件. diff --git a/hsweb-logging/hsweb-access-logging-api/pom.xml b/hsweb-logging/hsweb-access-logging-api/pom.xml index a2464762f..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.19-SNAPSHOT + 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 203f258f2..af0447827 100644 --- a/hsweb-logging/pom.xml +++ b/hsweb-logging/pom.xml @@ -23,7 +23,7 @@ hsweb-framework org.hswebframework.web - 4.0.19-SNAPSHOT + 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 f37df0c2a..ed904894d 100644 --- a/hsweb-starter/pom.xml +++ b/hsweb-starter/pom.xml @@ -5,11 +5,12 @@ hsweb-framework org.hswebframework.web - 4.0.19-SNAPSHOT + 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 ad96c6eeb..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.19-SNAPSHOT + 4.0.19 4.0.0 hsweb-system-authorization-api + ${artifactId} 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 8bc207865..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.19-SNAPSHOT + 4.0.19 4.0.0 hsweb-system-authorization-default + ${artifactId} 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 d16e96bbe..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.19-SNAPSHOT + 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 17a18f1c7..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.19-SNAPSHOT + 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 0ee8c76d2..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.19-SNAPSHOT + 4.0.19 4.0.0 hsweb-system-dictionary + ${artifactId} diff --git a/hsweb-system/hsweb-system-file/pom.xml b/hsweb-system/hsweb-system-file/pom.xml index 5351fa264..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.19-SNAPSHOT + 4.0.19 4.0.0 hsweb-system-file + ${artifactId} diff --git a/hsweb-system/pom.xml b/hsweb-system/pom.xml index 8799d0eed..c5bf02d3b 100644 --- a/hsweb-system/pom.xml +++ b/hsweb-system/pom.xml @@ -5,7 +5,7 @@ hsweb-framework org.hswebframework.web - 4.0.19-SNAPSHOT + 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 13a59626f..86547506d 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ org.hswebframework.web hsweb-framework - 4.0.19-SNAPSHOT + 4.0.19 hsweb-starter hsweb-core @@ -89,7 +89,7 @@ 3.2.2 1.6.12 - 4.1.4-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 @@ -517,11 +504,6 @@ - - releases - Nexus Release Repository - https://nexus.jetlinks.cn/content/repositories/releases/ - snapshots Nexus Snapshot Repository