From d7744ceaee8efecb742114afd766a7216c1615eb Mon Sep 17 00:00:00 2001 From: kyooosukedn Date: Fri, 7 Apr 2023 00:11:30 +0200 Subject: [PATCH 01/12] Code optimization --- .../auth/token/impl/auth/AuthTokenUtils.java | 112 ++++++------------ 1 file changed, 34 insertions(+), 78 deletions(-) diff --git a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java index 0bf004c626..0e5cecdeaa 100644 --- a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java +++ b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java @@ -33,6 +33,7 @@ import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; import java.util.Set; +import java.util.Objects; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwt; @@ -52,44 +53,9 @@ public static void authTokenByPublicKey(AclProperties aclProperties) { + aclProperties.getTopic()); } String publicKeyUrl = null; - token = token.replace("Bearer ", ""); - for (String key : ConfigurationContextUtil.KEYS) { - CommonConfiguration commonConfiguration = ConfigurationContextUtil.get(key); - if (null == commonConfiguration) { - continue; - } - if (StringUtils.isBlank(commonConfiguration.getEventMeshSecurityPublickey())) { - throw new AclException("publicKeyUrl cannot be null"); - } - publicKeyUrl = commonConfiguration.getEventMeshSecurityPublickey(); - } - byte[] validationKeyBytes = new byte[0]; - try { - validationKeyBytes = Files.readAllBytes(Paths.get(publicKeyUrl)); - X509EncodedKeySpec spec = new X509EncodedKeySpec(validationKeyBytes); - KeyFactory kf = KeyFactory.getInstance("RSA"); - Key validationKey = kf.generatePublic(spec); - JwtParser signedParser = Jwts.parserBuilder().setSigningKey(validationKey).build(); - Jwt signJwt = signedParser.parseClaimsJws(token); - String sub = signJwt.getBody().get("sub", String.class); - if (!sub.contains(aclProperties.getExtendedField("group").toString()) && !sub.contains("pulsar-admin")) { - throw new AclException("group:" + aclProperties.getExtendedField("group ") + " has no auth to access eventMesh:" - + aclProperties.getTopic()); - } - } catch (IOException e) { - throw new AclException("public key read error!", e); - } catch (NoSuchAlgorithmException e) { - throw new AclException("no such RSA algorithm!", e); - } catch (InvalidKeySpecException e) { - throw new AclException("invalid public key spec!", e); - } catch (JwtException e) { - throw new AclException("invalid token!", e); - } - + String sub = validateTokenAndGetSub(token, publicKeyUrl, aclProperties); } else { - { - throw new AclException("invalid token!"); - } + throw new AclException("invalid token!"); } } @@ -97,43 +63,9 @@ public static void helloTaskAuthTokenByPublicKey(AclProperties aclProperties) { String token = aclProperties.getToken(); if (StringUtils.isNotBlank(token)) { String publicKeyUrl = null; - token = token.replace("Bearer ", ""); - for (String key : ConfigurationContextUtil.KEYS) { - CommonConfiguration commonConfiguration = ConfigurationContextUtil.get(key); - if (null == commonConfiguration) { - continue; - } - if (StringUtils.isBlank(commonConfiguration.getEventMeshSecurityPublickey())) { - throw new AclException("publicKeyUrl cannot be null"); - } - publicKeyUrl = commonConfiguration.getEventMeshSecurityPublickey(); - } - byte[] validationKeyBytes = new byte[0]; - try { - validationKeyBytes = Files.readAllBytes(Paths.get(publicKeyUrl)); - X509EncodedKeySpec spec = new X509EncodedKeySpec(validationKeyBytes); - KeyFactory kf = KeyFactory.getInstance("RSA"); - Key validationKey = kf.generatePublic(spec); - JwtParser signedParser = Jwts.parserBuilder().setSigningKey(validationKey).build(); - Jwt signJwt = signedParser.parseClaimsJws(token); - String sub = signJwt.getBody().get("sub", String.class); - if (!sub.contains(aclProperties.getExtendedField("group").toString()) && !sub.contains("pulsar-admin")) { - throw new AclException("group:" + aclProperties.getExtendedField("group ") + " has no auth to access eventMesh:" - + aclProperties.getTopic()); - } - } catch (IOException e) { - throw new AclException("public key read error!", e); - } catch (NoSuchAlgorithmException e) { - throw new AclException("no such RSA algorithm!", e); - } catch (InvalidKeySpecException e) { - throw new AclException("invalid public key spec!", e); - } catch (JwtException e) { - throw new AclException("invalid token!", e); - } + String sub = validateTokenAndGetSub(token, publicKeyUrl, aclProperties); } else { - { - throw new AclException("invalid token!"); - } + throw new AclException("invalid token!"); } } @@ -143,12 +75,36 @@ public static boolean authAccess(AclProperties aclProperties) { Set groupTopics = (Set) aclProperties.getExtendedField("topics"); - if (groupTopics.contains(topic)) { - return true; - } else { - return false; - } + return groupTopics.contains(topic); + + } + public static String validateTokenAndGetSub(String token, String publicKeyUrl, AclProperties aclProperties) { + String sub = null; + token = token.replace("Bearer ", ""); + byte[] validationKeyBytes; + try { + validationKeyBytes = Files.readAllBytes(Paths.get(Objects.requireNonNull(publicKeyUrl))); + X509EncodedKeySpec spec = new X509EncodedKeySpec(validationKeyBytes); + KeyFactory kf = KeyFactory.getInstance("RSA"); + Key validationKey = kf.generatePublic(spec); + JwtParser signedParser = Jwts.parserBuilder().setSigningKey(validationKey).build(); + Jwt signJwt = signedParser.parseClaimsJws(token); + sub = signJwt.getBody().get("sub", String.class); + if (!sub.contains(aclProperties.getExtendedField("group").toString()) && !sub.contains("pulsar-admin")) { + throw new AclException("group:" + aclProperties.getExtendedField("group ") + " has no auth to access eventMesh:" + + aclProperties.getTopic()); + } + } catch (IOException e) { + throw new AclException("public key read error!", e); + } catch (NoSuchAlgorithmException e) { + throw new AclException("no such RSA algorithm!", e); + } catch (InvalidKeySpecException e) { + throw new AclException("invalid public key spec!", e); + } catch (JwtException e) { + throw new AclException("invalid token!", e); + } + return sub; } } From 8f72bdd40b5cd0c92b7aeba69f594bee2029274b Mon Sep 17 00:00:00 2001 From: kyooosukedn Date: Fri, 7 Apr 2023 16:02:30 +0200 Subject: [PATCH 02/12] Remove unused imports --- .../apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java index 0e5cecdeaa..711da4c128 100644 --- a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java +++ b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java @@ -19,8 +19,6 @@ import org.apache.eventmesh.api.acl.AclProperties; import org.apache.eventmesh.api.exception.AclException; -import org.apache.eventmesh.common.config.CommonConfiguration; -import org.apache.eventmesh.common.utils.ConfigurationContextUtil; import org.apache.commons.lang3.StringUtils; @@ -33,7 +31,6 @@ import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; import java.util.Set; -import java.util.Objects; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwt; From e8407939411b1dfcdccb1766ee5d58c2b4f35b55 Mon Sep 17 00:00:00 2001 From: kyooosukedn Date: Fri, 7 Apr 2023 16:46:21 +0200 Subject: [PATCH 03/12] Added one forgotten import 'Objects' --- .../eventmesh/runtime/admin/handler/HTTPClientHandler.java | 2 +- .../apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/HTTPClientHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/HTTPClientHandler.java index 30976366a8..7f1f6d03d4 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/HTTPClientHandler.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/HTTPClientHandler.java @@ -139,7 +139,7 @@ void list(HttpExchange httpExchange) throws IOException { }); String result = JsonUtils.toJSONString(getClientResponseList); - httpExchange.sendResponseHeaders(200, result.getBytes().length); + httpExchange.sendResponseHeaders(200, result.getBytes(Constants.DEFAULT_CHARSET).length); out.write(result.getBytes()); } catch (Exception e) { StringWriter writer = new StringWriter(); diff --git a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java index 711da4c128..9bdd57916a 100644 --- a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java +++ b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java @@ -30,6 +30,7 @@ import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; +import java.util.Objects; import java.util.Set; import io.jsonwebtoken.Claims; From 3709e3daed0843d99b04ef8e4e2d9711b7e03b6d Mon Sep 17 00:00:00 2001 From: kyooosukedn Date: Wed, 12 Apr 2023 21:57:15 +0200 Subject: [PATCH 04/12] Added Constants import --- .../eventmesh/runtime/admin/handler/HTTPClientHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/HTTPClientHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/HTTPClientHandler.java index 7f1f6d03d4..9b1239cf40 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/HTTPClientHandler.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/HTTPClientHandler.java @@ -17,6 +17,7 @@ package org.apache.eventmesh.runtime.admin.handler; +import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.admin.request.DeleteHTTPClientRequest; From fd6518a706c70d57963f32caf7ad54a4620a8fc2 Mon Sep 17 00:00:00 2001 From: kyooosukedn Date: Sun, 14 Jan 2024 15:52:00 +0100 Subject: [PATCH 05/12] removed unnecessary space --- .../apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java | 1 - 1 file changed, 1 deletion(-) diff --git a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java index 23e5f670f0..80bab1e6a4 100644 --- a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java +++ b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java @@ -74,7 +74,6 @@ public static boolean authAccess(AclProperties aclProperties) { String topic = aclProperties.getTopic(); Object topics = aclProperties.getExtendedField("topics"); - if (!(topics instanceof Set)) { return false; } From 12b521c4fe30d7575839d4b036cf3fb6890eb25e Mon Sep 17 00:00:00 2001 From: kyooosukedn Date: Sun, 14 Jan 2024 17:02:25 +0100 Subject: [PATCH 06/12] fixed code optimization --- .../auth/token/impl/auth/AuthTokenUtils.java | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java index 80bab1e6a4..92a859110f 100644 --- a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java +++ b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java @@ -52,8 +52,9 @@ public static void authTokenByPublicKey(AclProperties aclProperties) { throw new AclException("group:" + aclProperties.getExtendedField("group ") + " has no auth to access the topic:" + aclProperties.getTopic()); } - String publicKeyUrl = null; - String sub = validateTokenAndGetSub(token, publicKeyUrl, aclProperties); + token = token.replace("Bearer ", ""); + String publicKeyUrl = getPublicKeyUrl(); + validateToken(token, publicKeyUrl, aclProperties); } else { throw new AclException("invalid token!"); } @@ -62,8 +63,8 @@ public static void authTokenByPublicKey(AclProperties aclProperties) { public static void helloTaskAuthTokenByPublicKey(AclProperties aclProperties) { String token = aclProperties.getToken(); if (StringUtils.isNotBlank(token)) { - String publicKeyUrl = null; - String sub = validateTokenAndGetSub(token, publicKeyUrl, aclProperties); + String publicKeyUrl = getPublicKeyUrl(); + validateToken(token, publicKeyUrl, aclProperties); } else { throw new AclException("invalid token!"); } @@ -84,8 +85,8 @@ public static boolean authAccess(AclProperties aclProperties) { } - public static String validateTokenAndGetSub(String token, String publicKeyUrl, AclProperties aclProperties) { - String sub = null; + public static void validateToken(String token, String publicKeyUrl, AclProperties aclProperties) { + String sub; token = token.replace("Bearer ", ""); byte[] validationKeyBytes; try { @@ -109,7 +110,22 @@ public static String validateTokenAndGetSub(String token, String publicKeyUrl, A } catch (JwtException e) { throw new AclException("invalid token!", e); } - return sub; + + } + + public static String getPublicKeyUrl() { + String publicKeyUrl = null; + for (String key : ConfigurationContextUtil.KEYS) { + CommonConfiguration commonConfiguration = ConfigurationContextUtil.get(key); + if (null == commonConfiguration) { + continue; + } + if (StringUtils.isBlank(commonConfiguration.getEventMeshSecurityPublickey())) { + throw new AclException("publicKeyUrl cannot be null"); + } + publicKeyUrl = commonConfiguration.getEventMeshSecurityPublickey(); + } + return publicKeyUrl; } From 7c082febab3123628f2893cba6faa2db5b1dc68d Mon Sep 17 00:00:00 2001 From: kyooosukedn Date: Tue, 16 Jan 2024 23:17:13 +0100 Subject: [PATCH 07/12] corrected some small changes --- .../auth/token/impl/auth/AuthTokenUtils.java | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java index 92a859110f..2f88beb0ff 100644 --- a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java +++ b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java @@ -52,7 +52,6 @@ public static void authTokenByPublicKey(AclProperties aclProperties) { throw new AclException("group:" + aclProperties.getExtendedField("group ") + " has no auth to access the topic:" + aclProperties.getTopic()); } - token = token.replace("Bearer ", ""); String publicKeyUrl = getPublicKeyUrl(); validateToken(token, publicKeyUrl, aclProperties); } else { @@ -63,8 +62,7 @@ public static void authTokenByPublicKey(AclProperties aclProperties) { public static void helloTaskAuthTokenByPublicKey(AclProperties aclProperties) { String token = aclProperties.getToken(); if (StringUtils.isNotBlank(token)) { - String publicKeyUrl = getPublicKeyUrl(); - validateToken(token, publicKeyUrl, aclProperties); + validateToken(token, getPublicKeyUrl(), aclProperties); } else { throw new AclException("invalid token!"); } @@ -75,6 +73,7 @@ public static boolean authAccess(AclProperties aclProperties) { String topic = aclProperties.getTopic(); Object topics = aclProperties.getExtendedField("topics"); + if (!(topics instanceof Set)) { return false; } @@ -85,7 +84,22 @@ public static boolean authAccess(AclProperties aclProperties) { } - public static void validateToken(String token, String publicKeyUrl, AclProperties aclProperties) { + private static String getPublicKeyUrl() { + String publicKeyUrl = null; + for (String key : ConfigurationContextUtil.KEYS) { + CommonConfiguration commonConfiguration = ConfigurationContextUtil.get(key); + if (null == commonConfiguration) { + continue; + } + if (StringUtils.isBlank(commonConfiguration.getEventMeshSecurityPublickey())) { + throw new AclException("publicKeyUrl cannot be null"); + } + publicKeyUrl = commonConfiguration.getEventMeshSecurityPublickey(); + } + return publicKeyUrl; + } + + private static void validateToken(String token, String publicKeyUrl, AclProperties aclProperties) { String sub; token = token.replace("Bearer ", ""); byte[] validationKeyBytes; @@ -113,20 +127,4 @@ public static void validateToken(String token, String publicKeyUrl, AclPropertie } - public static String getPublicKeyUrl() { - String publicKeyUrl = null; - for (String key : ConfigurationContextUtil.KEYS) { - CommonConfiguration commonConfiguration = ConfigurationContextUtil.get(key); - if (null == commonConfiguration) { - continue; - } - if (StringUtils.isBlank(commonConfiguration.getEventMeshSecurityPublickey())) { - throw new AclException("publicKeyUrl cannot be null"); - } - publicKeyUrl = commonConfiguration.getEventMeshSecurityPublickey(); - } - return publicKeyUrl; - - } - } From a49336eaf25c92814a1a8ec51b0c54755916078b Mon Sep 17 00:00:00 2001 From: kyooosukedn Date: Wed, 17 Jan 2024 23:38:28 +0100 Subject: [PATCH 08/12] redundant lines --- .../apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java index 2f88beb0ff..c3606518c3 100644 --- a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java +++ b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java @@ -81,7 +81,6 @@ public static boolean authAccess(AclProperties aclProperties) { Set groupTopics = TypeUtils.castSet(topics, String.class); return groupTopics.contains(topic); - } private static String getPublicKeyUrl() { @@ -124,7 +123,6 @@ private static void validateToken(String token, String publicKeyUrl, AclProperti } catch (JwtException e) { throw new AclException("invalid token!", e); } - } } From 42c0d06b18cf8a396cb43cee15e6578974bd7ad4 Mon Sep 17 00:00:00 2001 From: kyooosukedn Date: Thu, 18 Jan 2024 16:51:53 +0100 Subject: [PATCH 09/12] redundant lines --- .../apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java | 1 - 1 file changed, 1 deletion(-) diff --git a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java index c3606518c3..16005649f4 100644 --- a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java +++ b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java @@ -124,5 +124,4 @@ private static void validateToken(String token, String publicKeyUrl, AclProperti throw new AclException("invalid token!", e); } } - } From 98bf805b91eb673f8388c2fc0469f7f934c3e18f Mon Sep 17 00:00:00 2001 From: kyooosukedn Date: Fri, 19 Jan 2024 23:55:21 +0100 Subject: [PATCH 10/12] optimized returned reply in subscribe method --- eventmesh-sdks/eventmesh-sdk-rust/src/grpc/grpc_consumer.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/eventmesh-sdks/eventmesh-sdk-rust/src/grpc/grpc_consumer.rs b/eventmesh-sdks/eventmesh-sdk-rust/src/grpc/grpc_consumer.rs index ad18ccd207..73bc4e5324 100644 --- a/eventmesh-sdks/eventmesh-sdk-rust/src/grpc/grpc_consumer.rs +++ b/eventmesh-sdks/eventmesh-sdk-rust/src/grpc/grpc_consumer.rs @@ -161,12 +161,11 @@ impl EventMeshGrpcConsumer { ProtocolKey::SUB_MESSAGE_TYPE.to_string(), PbCloudEventAttributeValue { attr: Some(PbAttr::CeString( - SubscriptionReply::SUB_TYPE.to_string(), + ProtocolKey::SUB_REPLY_MESSAGE.to_string(), )), }, ); - received.data = - Some(PbData::TextData(serde_json::to_string(&reply).unwrap())); + received.data = None; let _ = keeper.sender.send(received).await; } } else { From 29ccb376e1463e2c853575097491c330331d419d Mon Sep 17 00:00:00 2001 From: kyooosukedn Date: Fri, 19 Jan 2024 23:58:38 +0100 Subject: [PATCH 11/12] reverted correct change --- .../apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java index 16005649f4..c3606518c3 100644 --- a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java +++ b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java @@ -124,4 +124,5 @@ private static void validateToken(String token, String publicKeyUrl, AclProperti throw new AclException("invalid token!", e); } } + } From 13b2beebc4e320c9d2ebb26db2fc458e1696facc Mon Sep 17 00:00:00 2001 From: kyooosukedn Date: Sat, 20 Jan 2024 00:00:19 +0100 Subject: [PATCH 12/12] reverted back --- eventmesh-sdks/eventmesh-sdk-rust/src/grpc/grpc_consumer.rs | 5 +++-- .../eventmesh/auth/token/impl/auth/AuthTokenUtils.java | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eventmesh-sdks/eventmesh-sdk-rust/src/grpc/grpc_consumer.rs b/eventmesh-sdks/eventmesh-sdk-rust/src/grpc/grpc_consumer.rs index 73bc4e5324..ad18ccd207 100644 --- a/eventmesh-sdks/eventmesh-sdk-rust/src/grpc/grpc_consumer.rs +++ b/eventmesh-sdks/eventmesh-sdk-rust/src/grpc/grpc_consumer.rs @@ -161,11 +161,12 @@ impl EventMeshGrpcConsumer { ProtocolKey::SUB_MESSAGE_TYPE.to_string(), PbCloudEventAttributeValue { attr: Some(PbAttr::CeString( - ProtocolKey::SUB_REPLY_MESSAGE.to_string(), + SubscriptionReply::SUB_TYPE.to_string(), )), }, ); - received.data = None; + received.data = + Some(PbData::TextData(serde_json::to_string(&reply).unwrap())); let _ = keeper.sender.send(received).await; } } else { diff --git a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java index c3606518c3..16005649f4 100644 --- a/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java +++ b/eventmesh-security-plugin/eventmesh-security-auth-token/src/main/java/org/apache/eventmesh/auth/token/impl/auth/AuthTokenUtils.java @@ -124,5 +124,4 @@ private static void validateToken(String token, String publicKeyUrl, AclProperti throw new AclException("invalid token!", e); } } - }