Skip to content

Commit

Permalink
Simplify auth failed message (#14801)
Browse files Browse the repository at this point in the history
* Simplify auth failed message

* Fix style
  • Loading branch information
AlbumenJ authored Oct 24, 2024
1 parent 74218a4 commit 953483a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
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

0 comments on commit 953483a

Please sign in to comment.