Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify auth failed message #14801

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void authenticate(Invocation invocation, URL url) throws RpcAuthenticatio
try {
accessKeyPair = getAccessKeyPair(invocation, url);
} catch (Exception e) {
throw new RpcAuthenticationException("Failed to authenticate , can't load the accessKeyPair", e);
throw new RpcAuthenticationException("Failed to authenticate , can't load the accessKeyPair");
}

String computeSignature = getSignature(url, invocation, accessKeyPair.getSecretKey(), requestTimestamp);
Expand All @@ -85,7 +85,7 @@ AccessKeyPair getAccessKeyPair(Invocation invocation, URL url) {
throw new AccessKeyNotFoundException("AccessKeyId or secretAccessKey not found");
}
} catch (Exception e) {
throw new RuntimeException("Can't load the AccessKeyPair from accessKeyStorage", e);
throw new RuntimeException("Can't load the AccessKeyPair from accessKeyStorage");
}
return accessKeyPair;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.HeaderFilter;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcContext;
import org.apache.dubbo.rpc.RpcException;
import org.apache.dubbo.rpc.RpcInvocation;
import org.apache.dubbo.rpc.model.FrameworkModel;
import org.apache.dubbo.rpc.support.RpcUtils;

import static org.apache.dubbo.rpc.RpcException.AUTHORIZATION_EXCEPTION;

Expand All @@ -49,13 +47,7 @@ public RpcInvocation invoke(Invoker<?> invoker, RpcInvocation invocation) throws
try {
authenticator.authenticate(invocation, url);
} catch (Exception e) {
Class<?> serviceType = invoker.getInterface();
throw new RpcException(
AUTHORIZATION_EXCEPTION,
"Forbid invoke remote service " + serviceType + " method " + RpcUtils.getMethodName(invocation)
+ "() from consumer "
+ invocation.getAttributes().get(Constants.REMOTE_ADDRESS_KEY) + " to provider "
+ RpcContext.getServiceContext().getLocalHost());
throw new RpcException(AUTHORIZATION_EXCEPTION, "No Auth.");
}
invocation.getAttributes().put(Constants.AUTH_SUCCESS, Boolean.TRUE);
}
Expand Down
Loading