-
Notifications
You must be signed in to change notification settings - Fork 29
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
Signer-less Device Pairing #281
Conversation
41335cf
to
4050841
Compare
92251ee
to
981db7e
Compare
8b5a797
to
40c5809
Compare
4050841
to
8fb8916
Compare
8fb8916
to
5c485cd
Compare
ad9d0b4
to
180bb26
Compare
e0db8e2
to
157a322
Compare
157a322
to
ed1aed8
Compare
3194f42
to
2d46078
Compare
2d46078
to
9cec7a5
Compare
9cec7a5
to
06d40ab
Compare
06d40ab
to
6265146
Compare
644185e
to
d010f8d
Compare
f2b305e
to
f504032
Compare
match self.verify_rune(PendingRequest { | ||
request: vec![], | ||
uri: "/cln.Node/ApprovePairing".to_string(), | ||
signature: req.sig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the Context need to be updated to handle the signature?
greenlight/libs/gl-client/src/runes.rs
Line 159 in e38a376
pub struct Context { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is independent of checking the actual context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite an impressive PR! I went through and all I could find were small nits. There is one comment in there about the ordering assumptions on the streams, but that can be deferred until it becomes important, if we leave enough breadcrumbs to identify the issue once it arises, otherwise just naming suggestions, that you should feel free to ignore :-)
|
||
message PairDeviceRequest { | ||
// The tls public key of the new device. | ||
string session_id = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: The name session_id
is a bit misleading, could cert_id
or client_id
be better names? This is definitely bike-shedding the name, so if interested let's merge this and continue the discussion in a separate thread.
fn restriction_contains_pubkey_exactly_once(s: &str, pubkey: &str) -> bool { | ||
let search_field = format!("pubkey={}", pubkey); | ||
match s.find(&search_field) { | ||
Some(index) => { | ||
// Check if 'pubkey=<pubkey>' is not preceded by '|' | ||
if index > 0 && s.chars().nth(index - 1) == Some('|') { | ||
return false; | ||
} | ||
|
||
// Check if 'pubkey=<pubkey>' is not followed by '|' | ||
let end_index = index + search_field.len(); | ||
if end_index < s.len() && s.chars().nth(end_index) == Some('|') { | ||
return false; | ||
} | ||
|
||
// Check if 'pubkey=<pubkey>' appears exactly once | ||
s.matches(&search_field).count() == 1 | ||
} | ||
None => false, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we be checking for a standalone pubkey=03....
restriction? That'd mean that there cannot be any qualifiers (alternatives) on that restriction, and any rune including this restriction has to adhere to that pubkey. Attempting to parse a logical expression, and testing it doesn't somehow negate the clause we're interested in is hard (NP-hard to be precise, even if parsing works perfectly).
613af99
to
7a24cba
Compare
b2cd32b
to
52f60db
Compare
52f60db
to
f70230f
Compare
We need to create a keypair before we can actually create the cert during the pairing process. Signed-off-by: Peter Neuroth <[email protected]>
This commit only affects the protos, generated files and places that include the protos. Signed-off-by: Peter Neuroth <[email protected]>
This implements the service and the methods to initialize a pairing session on the "new device" Signed-off-by: Peter Neuroth <[email protected]>
Adds the PairingQR proto message and pass it to the channel once we did the request. Signed-off-by: Peter Neuroth <[email protected]>
Adds a method that returns the relevant data for "old device" to approve a pairing. This includes the requested restrictions that an old device needs to sign off. Signed-off-by: Peter Neuroth <[email protected]>
Adds the approval of the old device. This does not check the signature and does also not check the restrictions. This soley approves the pairing request. This needs a tls cert and a rune to be present as we need these to sign and attestate the approval. Signed-off-by: Peter Neuroth <[email protected]>
This adds a method to the pairing service that allows to check the validity of the PairingDataResponse. This is that the public key from the session_id matches the public key from the CSR. We may want to add a signature for the restrictions to ensure that GL did not manipulate them. We are OK for now as a user has to aggree to the restrictions anyway. Signed-off-by: Peter Neuroth <[email protected]>
Signer now receives requests from the scheduler for further processing. The signer processes a ApprovePairingRequest and responds to the scheduler. Signed-off-by: Peter Neuroth <[email protected]>
This commit replaces TlsConfig dependencies introduced by the signerless device pairing with Credentials. Signed-off-by: Peter Neuroth <[email protected]>
As we already pass the credentials to the pairing client we can also remove parts that are part of the credentials from the client struct. This allows to remove the node_id from `approve_pairing`. Signed-off-by: Peter Neuroth <[email protected]>
Signed-off-by: Peter Neuroth <[email protected]>
Signed-off-by: Peter Neuroth <[email protected]>
Signed-off-by: Peter Neuroth <[email protected]>
Using a `Result<()>` instead of printing debug logs saves some lines of code and is more idiomatic. Signed-off-by: Peter Neuroth <[email protected]>
We expect a signer response during the pairing procedure. This adds an extra assertion to help track down issues in the future. Signed-off-by: Peter Neuroth <[email protected]>
Signed-off-by: Peter Neuroth <[email protected]>
f70230f
to
83d1bfb
Compare
ACK f70230f |
This PR adds the "Pairing Process/Protocol" to the client stack. The Pairing-Process is a way to connect a signer-less client to a greenlight node. The pairing request has to be approved by a trusted device.
I'll add a more details about the process soon.