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

Implement account deactivation. #111

Merged
merged 1 commit into from
Apr 16, 2018
Merged

Conversation

calavera
Copy link
Contributor

@calavera calavera commented Apr 7, 2018

ACME v11 is not very clear about the problem returned after the account
has been deactivated:

Once an account is deactivated, the server MUST NOT accept further
requests authorized by that account's key.

This change assumes that any further request that requires to check the
account will return an unauthorized error. That might be something to
ammend in the ACME spec.

Fixes #108

Signed-off-by: David Calavera [email protected]

@calavera calavera force-pushed the deactivate_account branch 2 times, most recently from d2c0e55 to 451eca2 Compare April 7, 2018 03:30
@cpu
Copy link
Contributor

cpu commented Apr 9, 2018

@calavera Thanks for the PR! I'll give it a 🔍 in the next day or so.

@cpu cpu self-assigned this Apr 9, 2018
@cpu cpu self-requested a review April 9, 2018 16:22
Copy link
Contributor

@cpu cpu left a comment

Choose a reason for hiding this comment

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

One small request, otherwise looks great. Thanks @calavera ! I appreciate the PR 🌮

This change assumes that any further request that requires to check the account will return an unauthorized error. That might be something to ammend in the ACME spec.

This is what Boulder returns too 👍

wfe/wfe.go Outdated
if prob != nil {
wfe.sendError(prob, response)
return
if updateAcctReq.Status == "deactivated" {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be worth returning a probs.Malformed instance if the user POST's an update with Status != "deactivated" to be a little bit more strict here.

The way you have it implemented now will ignore an invalid status in an update which isn't unreasonable, but I'd like to shake out as many client errors in Pebble as possible.

It looks like Boulder is generous and does similar: it only checks that the update status != the existing status: https://github.com/letsencrypt/boulder/blob/699c7e4c4448bf70cd2410504684cc60737cd504/wfe/wfe.go#L1138-L1153 which is fine because ultimately the SA ignores the update status and explicitly uses the deactivated status in sa.DeactivateRegistration: https://github.com/letsencrypt/boulder/blob/699c7e4c4448bf70cd2410504684cc60737cd504/sa/sa.go#L1357

@calavera
Copy link
Contributor Author

@cpu I've updated this change with your suggestion and rebased the PR to have only one commit. 🙌

Copy link
Contributor

@cpu cpu left a comment

Choose a reason for hiding this comment

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

Another round of feedback. Thanks for iterating on this @calavera!

wfe/wfe.go Outdated

// deactivatedStatus is the only valid status accepted by ACME to update Accounts
// and auhtorizations.
deactivatedStatus = "deactivated"
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add this to acme/common.go as a new top level exported status alongside StatusPending, StatusValid, etc? Only the wfe references it presently but I think its best to keep all of the ACME constants in one place where possible.

wfe/wfe.go Outdated
case updateAcctReq.Status != newAcct.Status:
wfe.sendError(
acme.MalformedProblem(fmt.Sprintf(
"Invalid account status: %s", updateAcctReq.Status)), response)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this %s should be %q, otherwise sending { "status": "" } returns "Invalid account status: "

wfe/wfe.go Outdated
switch {
case updateAcctReq.Status == deactivatedStatus:
newAcct.Status = updateAcctReq.Status
case updateAcctReq.Status != newAcct.Status:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this switch case might need to be updatedAcctReq.Status != "" && updatedAcctReq.Status != newAcct.Status.

It looks like as-written this breaks an account update that only changes the contact field, not sending any new status field:

$ pebble-client -email [email protected]
welcome to the pebble shell
Requesting directory from "https://localhost:14000/dir"
Requesting nonce from "https://localhost:14000/nonce-plz"
Registering new account with "https://localhost:14000/sign-me-up"
Requesting nonce from "https://localhost:14000/nonce-plz"
Your account ID is "https://localhost:14000/my-account/4e74148cfb32e323d86667990bc9b9ce5a28b47cfa6b86f76c09a762cec9f523"
Starting REPL environment...
$> Enter a directory endpoint or a URL to POST: https://localhost:14000/my-account/4e74148cfb32e323d86667990bc9b9ce5a28b47cfa6b86f76c09a762cec9f523
$> Enter JSON body, empty line to finish : 
{ "contact":["mailto:[email protected]"] }

Requesting nonce from "https://localhost:14000/nonce-plz"
REPL error: Response 400: {
   "type": "urn:ietf:params:acme:error:malformedRequest",
   "detail": "Invalid account status: ",
   "status": 400
}

ACME v11 is not very clear about the problem returned after the account
has been deactivated:

> Once an account is deactivated, the server MUST NOT accept further
> requests authorized by that account's key.

This change assumes that any further request that requires to check the
account will return an unauthorized error. That might be something to
ammend in the ACME spec.

- Return a malformed problem if the status is not deactivated or the
current account status.

Signed-off-by: David Calavera <[email protected]>
@calavera
Copy link
Contributor Author

@cpu Updated! Thanks again for the reviews 🌞

Copy link
Contributor

@cpu cpu left a comment

Choose a reason for hiding this comment

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

Looks great 🔍 💯

Thanks @calavera !

@cpu cpu merged commit 1688a1b into letsencrypt:master Apr 16, 2018
@calavera calavera deleted the deactivate_account branch April 17, 2018 20:37
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.

2 participants