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 support for shamir recovery invitation #8819

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

vxgmichel
Copy link
Contributor

@vxgmichel vxgmichel commented Oct 30, 2024

Part of #6090

Close #7359

Fix #8429

Tested with:

$ . ./cli/run_testenv.sh 
[...]
Alice & Bob devices (password: P@ssw0rd.):
- 624 // Alice
- 196 // Alice 2nd device
- 1f2 // Bob

$ echo P@ssw0rd. | target/debug/parsec-cli shared-recovery create --password-stdin -d 1f2
Shamir setup has been created

$ echo P@ssw0rd. | target/debug/parsec-cli invite shared-recovery --password-stdin -d 624 --email [email protected]
Invitation URL: parsec3://127.0.0.1:41997/Org?no_ssl=true&a=claim_shamir_recovery&p=xBCqEy9RIO8HPyycmlus9Qzg

$ echo P@ssw0rd. | target/debug/parsec-cli invite list --password-stdin -d 624
aa132f5120ef073f2c9c9a5bacf50ce0        idle    shamir recovery (Bob <[email protected]>)

$ echo P@ssw0rd. | target/debug/parsec-cli invite cancel --password-stdin -d 624 --token aa132f5120ef073f2c9c9a5bacf50ce0
Invitation deleted

$ echo P@ssw0rd. | target/debug/parsec-cli invite list --password-stdin -d 624 
aa132f5120ef073f2c9c9a5bacf50ce0        cancelled       shamir recovery (Bob <[email protected]>)

@vxgmichel vxgmichel requested review from a team as code owners October 30, 2024 10:51
@vxgmichel vxgmichel marked this pull request as draft October 30, 2024 10:51
@vxgmichel vxgmichel force-pushed the issue-7359 branch 10 times, most recently from 2c19d47 to c63b236 Compare November 1, 2024 16:12
@vxgmichel vxgmichel marked this pull request as ready for review November 1, 2024 16:12
@vxgmichel vxgmichel requested review from a team as code owners November 1, 2024 16:12
@vxgmichel
Copy link
Contributor Author

vxgmichel commented Nov 1, 2024

Missing tests for:

  • invite_list with shamir recovery
  • invite_info for shamir recovery
  • certificates_get with shamir certificates

@vxgmichel vxgmichel force-pushed the issue-7359 branch 2 times, most recently from 3dcdb16 to 35ea62b Compare November 1, 2024 17:10
@@ -289,8 +289,12 @@ class MemoryInvitation:
type: InvitationType
created_by_user_id: UserID
created_by_device_id: DeviceID

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

Copy link
Contributor Author

@vxgmichel vxgmichel Nov 4, 2024

Choose a reason for hiding this comment

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

I grouped the attribute on purpose, to easily visualize those that are type dependent

server/parsec/components/memory/datamodel.py Show resolved Hide resolved
if shamir_setup is None:
# Since the author only knows about a shamir recovery if they are part of it,
# we don't have a specific error for the case where the shamir setup doesn't exist
return InviteNewForShamirBadOutcome.AUTHOR_NOT_ALLOWED
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a specific reason to not define a SetupNotFound error ?

Copy link
Contributor Author

@vxgmichel vxgmichel Nov 4, 2024

Choose a reason for hiding this comment

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

AFAIC we decided to not share the brief and removal certificates with users that are not part of the corresponding shamir. That means that users don't have a way to know whether another user has a shamir recovery setup when they are not part of it. For this reason, it would be weird to have the server give this information through an error status.

3. Start the invitation process from a device already part of the organization,
then follow the steps on the Parsec client.
{% elif is_shamir_recovery_invitation %}
3. Get in touch with <b>{{ greeter }}</b> and follow the next steps on the Parsec client.
Copy link
Contributor

Choose a reason for hiding this comment

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

There is one mail sent per greeter ? Does the order of greeter matter ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this context, the greeter is the user that created the invitation link. That user is part of the recipients so it's a good idea to include their name in the mail, although the claimer will have to contact some of the other recipients too.

cli/src/commands/invite/greet.rs Outdated Show resolved Hide resolved
cli/src/commands/invite/claim.rs Show resolved Hide resolved
cli/src/commands/invite/shared_recovery.rs Outdated Show resolved Hide resolved
cli/src/commands/invite/shared_recovery.rs Outdated Show resolved Hide resolved
Comment on lines +75 to +86
InvitationEmailSentStatus::RecipientRefused => {
println!(
"Invitation email not sent to {} because the recipient was refused",
email
);
}
InvitationEmailSentStatus::ServerUnavailable => {
println!(
"Invitation email not sent to {} because the server is unavailable",
email
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If the email was not sent, should the CLI fail with an error ?

It's expected that the message being print to stdout and not stderr ? (println vs eprintln)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand the email sent status as extra information, so maybe it could be a warning if the mail wasn't sent properly?

Also we should probably start a discussion about making sure that all commands use the same approach to error handling.

@FirelightFlagboy FirelightFlagboy linked an issue Nov 4, 2024 that may be closed by this pull request
@FirelightFlagboy
Copy link
Contributor

FirelightFlagboy commented Nov 4, 2024

Missing multiple news fragments for the CLI change

@vxgmichel
Copy link
Contributor Author

vxgmichel commented Nov 4, 2024

@FirelightFlagboy

Missing multiple news fragments for the CLI change

You mean for #8429 or for other shamir related commands?

I don't think it's worth adding newsfragments for the different shamir commands, a single newsfragment commenting the general feature at the end is enough IMO.

@FirelightFlagboy
Copy link
Contributor

You would expect at least 2 newsfragment: one for the updated example in the CLI help message, and the other that could group the change related to the added/updated shamir command

@vxgmichel
Copy link
Contributor Author

vxgmichel commented Nov 4, 2024

one for the updated example in the CLI help message,

Does that really deserve a newsfragment though? I'd say no, but I can add it if necessary.

and the other that could group the change related to the added/updated shamir command

This will come later once the feature is fully implemented.

cli/src/commands/invite/greet.rs Outdated Show resolved Hide resolved
cli/src/commands/invite/greet.rs Outdated Show resolved Hide resolved
Comment on lines +11 to +12
#[arg(long)]
email: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of providing the email as a argument over an option ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does our clap_parser_with_shared_opts_builder allow to do that?

libparsec/crates/client/src/invite/claimer.rs Outdated Show resolved Hide resolved
@@ -489,7 +489,8 @@ fn invitation_addr_bad_type(
&url,
AddrError::InvalidParamValue {
param: "a",
help: "Expected `a=claim_user` or `a=claim_device`".to_string(),
help: "Expected `a=claim_user`, `a=claim_device` or `a=claim_shamir_recovery`"
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Could we use constant here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Feel free to provide a suggested change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants