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

Add a mock grpc-web-proxy #536

Merged
merged 8 commits into from
Nov 22, 2024
Merged

Add a mock grpc-web-proxy #536

merged 8 commits into from
Nov 22, 2024

Conversation

cdecker
Copy link
Collaborator

@cdecker cdecker commented Oct 29, 2024

We are working on building a grpc-web-proxy for production, but in
the meantime this already allows browsers and other environments that
do not like mTLS for authentication to integrate with Greenlight.

It exposes a grpc-web interface on the public side, allowing
non-mTLS clients to talk to it, and it can be provisioned with a valid
wildcard certificate, so browsers don't complain. On the other side it
forwards the requests over an mTLS connection to the actual node, such
that nodes continue to be protected from a variety of attacks.

Authentication and authorization is not affected, since the payloads
of the calls is signed by the device certificate, which is the one
that is ultimately the principal for authorization in the Runes. This
means that clients still need to implement the payload signing, but
that's much simpler than teaching browsers to not show scary messages
due to a self-signed cert or missing client cert.

sequenceDiagram
	alt grpc-web / TLS
    Browser->>Proxy: Please execute this request
	end 
    Proxy-->>Proxy: Verify signature 
	alt grpc-h2 / mTLS
	Proxy-->>Proxy: Fetch node client certificate
	Proxy-->>Node: Forward request 
	Node-->>Node: Process request
    Node-->>Proxy: Response
	end 
	alt grpc-web
	Proxy-->>Browser: Response
	end
	
Loading

Fewer demands on the environments, better managed, should make it
simpler to use.
It turns out we were accessing the external `$PATH` which may or may
not contain a valid `lightningd`.`
@cdecker cdecker force-pushed the 202444-grpc-web branch 3 times, most recently from 8719ebc to 851cf70 Compare November 7, 2024 16:06
@cdecker cdecker marked this pull request as ready for review November 7, 2024 17:04
`uv` gives us more control, and fewer failure opportunities, so let's
use it.
This proxy is used in the local testing environment to provide
node-access to browser based clients. It strips the transport
authentication, and replaces it with the payload authentication
already used for the signer context.
We create a standalone service and front it with the
grpc-web-proxy. Since the proxy must not rely on the payload to make
decisions we just implemented a simple test proto just for this case.
Besides the grpc-web proxy functionality, the node grpc-web-proxy also
needs the capability of locating and starting a node if it hasn't been
started yet. It also needs to be configured with the correct client
certificates. The `NodeHandler` class encapsulates that logic.

We also test it by running a `GetInfo` call through the
grpc-web-client, the node-grpc-web-proxy-, finally hitting the node,
and back again.
24.08 broke the plugin handling in CLN by no longer passing the description
along. We'll need to unpin them again once we have switched to CLN 24.08
for testing.
@cdecker cdecker merged commit 4629d8d into main Nov 22, 2024
12 checks passed
@cdecker cdecker deleted the 202444-grpc-web branch November 22, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant