Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
yuz10 committed Jun 5, 2024
1 parent 2b580c6 commit 10e7cc4
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public List<DefaultAuthorizationContext> build(ChannelHandlerContext context, Re
subject = User.of(fields.get(SessionCredentials.ACCESS_KEY));
}
String remoteAddr = RemotingHelper.parseChannelRemoteAddr(context.channel());
String sourceIp = StringUtils.substringBefore(remoteAddr, CommonConstants.COLON);
String sourceIp = StringUtils.substringBeforeLast(remoteAddr, CommonConstants.COLON);

Resource topic;
Resource group;
Expand Down Expand Up @@ -394,7 +394,7 @@ private List<DefaultAuthorizationContext> newContext(Metadata metadata, QueryRou
subject = User.of(metadata.get(GrpcConstants.AUTHORIZATION_AK));
}
Resource resource = Resource.ofTopic(topic.getName());
String sourceIp = StringUtils.substringBefore(metadata.get(GrpcConstants.REMOTE_ADDRESS), CommonConstants.COLON);
String sourceIp = StringUtils.substringBeforeLast(metadata.get(GrpcConstants.REMOTE_ADDRESS), CommonConstants.COLON);
DefaultAuthorizationContext context = DefaultAuthorizationContext.of(subject, resource, Arrays.asList(Action.PUB, Action.SUB), sourceIp);
return Collections.singletonList(context);
}
Expand Down Expand Up @@ -437,7 +437,7 @@ private static List<DefaultAuthorizationContext> newPubContext(Metadata metadata
subject = User.of(metadata.get(GrpcConstants.AUTHORIZATION_AK));
}
Resource resource = Resource.ofTopic(topic.getName());
String sourceIp = StringUtils.substringBefore(metadata.get(GrpcConstants.REMOTE_ADDRESS), CommonConstants.COLON);
String sourceIp = StringUtils.substringBeforeLast(metadata.get(GrpcConstants.REMOTE_ADDRESS), CommonConstants.COLON);
DefaultAuthorizationContext context = DefaultAuthorizationContext.of(subject, resource, Action.PUB, sourceIp);
return Collections.singletonList(context);
}
Expand Down Expand Up @@ -483,7 +483,7 @@ private static List<DefaultAuthorizationContext> newSubContexts(Metadata metadat
if (metadata.containsKey(GrpcConstants.AUTHORIZATION_AK)) {
subject = User.of(metadata.get(GrpcConstants.AUTHORIZATION_AK));
}
String sourceIp = StringUtils.substringBefore(metadata.get(GrpcConstants.REMOTE_ADDRESS), CommonConstants.COLON);
String sourceIp = StringUtils.substringBeforeLast(metadata.get(GrpcConstants.REMOTE_ADDRESS), CommonConstants.COLON);
result.add(DefaultAuthorizationContext.of(subject, resource, Action.SUB, sourceIp));
return result;
}
Expand Down

0 comments on commit 10e7cc4

Please sign in to comment.