Specification
In some AgentService handlers we need to be able to verify the connecting node information such as the NodeId, certificates and connection information. Since the ForwardProxy<->ReverseProxy connection uses mTLS to ensure a secure connection we can obtain this trusted information from the ReverseProxy.
We need to copy and adapt the authenticator implementation from the client/utils. it should be called getTrustedConnectionInfo. This needs to fetch the connection info from the ReverseProxy. The ReverseProxy provides the ReverseProxy.getConnectionInfoByProxy() method for fetching this information. The information will take this form.
type ConnectionInfo = {
nodeId: NodeId;
certificates: Array<Certificate>;
egressHost: Host;
egressPort: Port;
ingressHost: Host;
ingressPort: Port;
};
Within the handler we can obtain the the host and port of the incoming address by using call.getPeer() This will return the address information in the form of host:port. This can be used to look up the information from the ReverseProxy.
Usage
The fix for this introduced a connectionInformationGetter to the agent service container. This allows you to access it within the service handlers by doing ...
function echo({
connectionInfoGetter,
}: {
connectionInfoGetter: ConnectionInfoGetter;
}) {
return async (
call: grpc.ServerUnaryCall<utilsPB.EchoMessage, utilsPB.EchoMessage>,
callback: grpc.sendUnaryData<utilsPB.EchoMessage>,
): Promise<void> => {
const connectionInfo = connectionInfoGetter(call);
if ( connectionInfo == null) throw new agentErrors.ErrorConnectionInfoMissing();
// ...
};
}
If it can't find the respective connectionInfo connectionInfoGetter will return undefined but during normal operation when connecting through the proxies this should never happen. You can't obtain any information when connecting directly bypassing proxies. this only happens in testing so far.
connectionInfoGetter takes the call as a parameter. It uses call.getPeer() to get the connection info. This should be parsed as a URL to handle it more robustly. The format of call.getPeer() is usually Host:Port but it can be protocol://Host:Port.
When using connectionInfoGetter we need an error for when we fail to obtain the ConnectionInfo. ErrorConnectionInfoMissing error needs to be created for this. Likely use the sysexits.UNAVAILABLE exit code in this case.
Additional context
Tasks
Specification
In some AgentService handlers we need to be able to verify the connecting node information such as the NodeId, certificates and connection information. Since the
ForwardProxy<->ReverseProxyconnection uses mTLS to ensure a secure connection we can obtain this trusted information from theReverseProxy.We need to copy and adapt the
authenticatorimplementation from the client/utils. it should be calledgetTrustedConnectionInfo. This needs to fetch the connection info from theReverseProxy. TheReverseProxyprovides theReverseProxy.getConnectionInfoByProxy()method for fetching this information. The information will take this form.Within the handler we can obtain the the host and port of the incoming address by using
call.getPeer()This will return the address information in the form ofhost:port. This can be used to look up the information from theReverseProxy.Usage
The fix for this introduced a
connectionInformationGetterto the agent service container. This allows you to access it within the service handlers by doing ...If it can't find the respective connectionInfo
connectionInfoGetterwill return undefined but during normal operation when connecting through the proxies this should never happen. You can't obtain any information when connecting directly bypassing proxies. this only happens in testing so far.connectionInfoGettertakes thecallas a parameter. It usescall.getPeer()to get the connection info. This should be parsed as a URL to handle it more robustly. The format ofcall.getPeer()is usuallyHost:Portbut it can beprotocol://Host:Port.When using
connectionInfoGetterwe need an error for when we fail to obtain theConnectionInfo.ErrorConnectionInfoMissingerror needs to be created for this. Likely use thesysexits.UNAVAILABLEexit code in this case.Additional context
VaultInternal#305 (comment) to Redesign usage of CDSS withVaultInternal#305 (comment).VaultInternal#305Tasks
getTrustedConnectionInfoutility that mimics the use ofauthenticatorinclient/utils.ErrorConnectionInfoMissingerror.ConnectionInfofromReverseProxy.getConnectionInfoByProxy()createService(container)parameter similar to how the clientauthenticatorworks