-
Notifications
You must be signed in to change notification settings - Fork 4
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
Agent service utility to acquire trusted ConnectionInfo
from connecting client node
#342
Comments
@tegefaulkes as explained the server interceptor is not available. So you have to do something like the |
Just a note, we need to use |
The The GRPC handler doesn't know the egress host and port information, it only knows the reverse proxy's host and port information. Assuming that the reverse proxy creates new ephemeral ports https://en.wikipedia.org/wiki/Ephemeral_port for every connection it establishes with the GRPC server, this would mean the GRPC handlers can use this as the index to request the connection info of the client node. On the GRPC handler, you need to use: The
The reason is that prior to resolution, it may have the The address is "resolved" after the call is awaited. However this is primarily from the client side. So on the server side, it may always be Either way the parser to should strip it before extracting the IP and host. I'm not sure what it looks like from IPv6 perspective, perhaps we need to use a URL parser in this case too? |
ConnectionInfo
from connecting client node
ConnectionInfo
from connecting client nodeConnectionInfo
from connecting client node
We need to test if this works by verifying that ReverseProxy assigns ephemeral ports to any connections it proxies to the GRPCServer. |
@CMCDragonkai Since this issue is related to issues in other PRs. Is this getting addressed here by me or fixed along with the other issues discussed before? |
It's best you take over this issue. Remember to spec out the tasks first. You may want to create a separate PR first. |
Old specCopying the old spec here since it has some useful context information. We need to be able to check the MTLS of a Node the see if it is trusted when handling Agent GRPC requests. Currently this is required by vault clone/pull to verify the permissions of the Node making the request. This information can be obtained from the refer to this diagram https://excalidraw.com/#room=57543403694c95eba2e9,5qJFVQlpWc0vegUgEAQIpA which is regarding the session token usage and https://github.com/MatrixAI/js-polykey/wiki/network. It is implemented through the We need to add a new GRPC upstream has discussion about adding server interceptors: grpc/grpc-node#419. This is why the |
While prototyping and exploring the problem I found that the |
|
The We would actually default on |
And no we don't default on |
You want to keep those tests that only test non network usage. Unit tests are supposed to be less integrationy. You can also additional integration tests, but don't remove the tests that aren't using the network domain. |
Right now I've updated |
I would say you should create a separate set of test functions to test with proxies. This is where a nested describe could be used. But make sure it's at the very end. Also isn't |
Yes, but only fixing the imports and removing the |
Two things that need to be expanded on here.
|
This utility function's input type should be a
For the input, because it may be a URL because Subsequently because the if (grpcServer.secured) {
const certs = grpcServer.getClientCertificates(session);
// process the certs
} else {
const connInfo = revProxy.getConnectionInfoByEgress(host, port);
// process the connInfo
} Note that in both cases, you may get The type of Finally if no certs/nodeid is provided, then The GRPC service handlers must then decide what to do in that case. 2 additional exceptions should be created in
In the case of There is an additional problem, where do you get the This is a hack provided by |
The URL aspect needs to be fixed. but is getting the information from the |
Yea it can moved till later. But you should make the necessary transformation of the output type. Atm I can't even find how to access the client certificate on the server side, because I can't get access to the |
I think it's So:
Should be sufficient to get you the client certificates. I think adding |
Try this: /**
* Acqure the HTTP2 session for a GRPC connection from the server side
* This relies on monkey patching the gRPC library internals
* The `ServerSurfaceCall` is expected to be an instance of `Http2ServerCallStream`
* It will contain `stream` property, which will contain the `session` property
*/
function getServerSession(
call: ServerSurfaceCall
): Http2Session {
// @ts-ignore
return call.stream.session;
} I'll keep it in my branch in the mean time, but when you get around to it see if it works. Then I think your utility function can be simplified to and it will use the
Note the diff between I just checked the The main difference here is that agent service handlers have to be more flexible since you may deal return different results depending on if you know who the contacting agent is. |
Reminder for me to create a new issue for expanding the functionality of Also, do we really want to call it |
This has been updated with the URL changes. the rest of the changes has been moved into issue #355 |
It's sort of propagating authentication information via TLS. So it is form of authentication with respect to the handlers. |
I actually cherry picked this to master. |
Added the test with multiple connections. Looks like it's working fine. each connection has it's own |
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 theReverseProxy
.We need to copy and adapt the
authenticator
implementation from the client/utils. it should be calledgetTrustedConnectionInfo
. This needs to fetch the connection info from theReverseProxy
. TheReverseProxy
provides 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
connectionInformationGetter
to the agent service container. This allows you to access it within the service handlers by doing ...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 thecall
as 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:Port
but it can beprotocol://Host:Port
.When using
connectionInfoGetter
we need an error for when we fail to obtain theConnectionInfo
.ErrorConnectionInfoMissing
error needs to be created for this. Likely use thesysexits.UNAVAILABLE
exit code in this case.Additional context
VaultInternal
#305 (comment) to Redesign usage of CDSS withVaultInternal
#305 (comment).VaultInternal
#305Tasks
getTrustedConnectionInfo
utility that mimics the use ofauthenticator
inclient/utils
.ErrorConnectionInfoMissing
error.ConnectionInfo
fromReverseProxy.getConnectionInfoByProxy()
createService(container)
parameter similar to how the clientauthenticator
worksThe text was updated successfully, but these errors were encountered: