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

Support creating a new directory with a pre-determined signing key #1365

Merged
merged 14 commits into from
Jun 3, 2024

Conversation

crwood
Copy link
Member

@crwood crwood commented May 14, 2024

This PR adds support for specifying the signing key to use when creating a new mutable directory via the web API. More specifically, with this, users can pass an optional private-key=... argument to POST ?t=mkdir or ?t=mkdir-with-children in order to specify the key to be used -- where the value of private-key must be a DER-encoded 2048-bit RSA private key in "urlsafe" base64 encoding. Because the resultant mutable directory writecap is (always) derived deterministically from its underlying signing key, additional care should be taken when generating and handling the this value. See the updated docs/frontends/webapi.rst for further details.

Note that this PR effectively builds upon prior/existing work from #1245 (which previously added support for such a private-key=... argument for new mutable files; this PR mainly extends such support to new mutable directories).

Closes ticket 4094.

@coveralls
Copy link
Collaborator

coveralls commented May 14, 2024

Coverage Status

coverage: 95.347% (-0.03%) from 95.379%
when pulling 00f82a4 on crwood:4094.deterministic-dircaps
into 432e041 on tahoe-lafs:master.

@crwood crwood marked this pull request as ready for review May 17, 2024 15:17
@crwood
Copy link
Member Author

crwood commented May 17, 2024

I'm not sure what's going on with the failing CircleCI python jobs but I see the same tests failing/timing out in other independent PRs (such as here and here) so presumably those are unrelated?

Copy link
Contributor

@hacklschorsch hacklschorsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

Copy link
Contributor

@meejah meejah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Some inline comments.

It would be great to replace (any) test_system tests with smaller ones for sure. I'm not sure if these are "the same" errors as the ones you link at, but there's definitely some occasionally-failing tests still :(

self,
initial_children=None,
version=None,
*,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we use this syntax or type-hinting anywhere else in this codebase, so might cause more confusion than it solves? Ideally should gain a docstring (too/instead).

Copy link
Member Author

@crwood crwood May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a docstring via f694224

The syntax and type-hinting follow the already-existing create_mutable_file function (just two functions down in the same module) which I was borrowing from. 00f82a4 adds the missing hints (if that's what you were referring to?) but I can take them out entirely and/or inline everything if that's what you would prefer -- just let me know. (I found a number of conflicting "styles" in use throughout the codebase and wasn't sure which to follow so I'm happy to have some guidance here on expected standards :).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the docstring. leaving the type-hints is fine / good (just AFAIK they won't really "do" anything but that can come later)

keypair, the resulting filecap should also always be the same.
"""
# Randomly generated with `openssl genrsa -out privkey.pem 2048`
privkey_pem = """-----BEGIN RSA PRIVATE KEY-----
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be worthwhile factoring these out into the existing src/allmydata/test/data/* directory for readability.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a30a7cb

unique, that it is kept confidential, and that it was derived from an
appropriate (high-entropy) source of randomness. If this argument is omitted
(the default behavior), Tahoe-LAFS will generate an appropriate signing key
using the underlying operating system's source of entropy.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's a straightforward command-line to do this, it might be nice to include an example (i.e. to turn a PEM file into "a DER-encoded urlsafe b64" string).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this counts as "straightforward", but here's an attempt.

@meejah
Copy link
Contributor

meejah commented May 30, 2024

Looks like one of those failures is something like "a test_system test -- test_mutable_mdmf -- times out, but doesn't get killed correctly causing follow-on "reactor is dirty" errors in several other tests ... the other two are "test_mutable_mdmf fails".

... not looking for further action in this PR but I looked so wanted to note it somewhere

@meejah meejah merged commit b6fefa0 into tahoe-lafs:master Jun 3, 2024
28 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants