Skip to content

Commit ebf232c

Browse files
authored
Return updated account object on DeactivateRegistration path (#8060)
Update the SA to re-query the database for the updated account after deactivating it, and return this to the RA. Update the RA to pass this value through to the WFE. Update the WFE to return this value, rather than locally modifying the pre-deactivation account object, if it gets one (for deployability). Also remove the RA's requirement that the request object specify its current status so that the request can be trimmed down to just an ID. This proto change is backwards-compatible because the new DeactivateRegistrationRequest's registrationID field has the same type (int64) and field number (1) as corepb.Registration's id field. Part of #5554
1 parent cb94164 commit ebf232c

File tree

13 files changed

+498
-373
lines changed

13 files changed

+498
-373
lines changed

ra/proto/ra.pb.go

+291-225
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ra/proto/ra.proto

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ service RegistrationAuthority {
1111
rpc NewRegistration(core.Registration) returns (core.Registration) {}
1212
rpc UpdateRegistrationContact(UpdateRegistrationContactRequest) returns (core.Registration) {}
1313
rpc UpdateRegistrationKey(UpdateRegistrationKeyRequest) returns (core.Registration) {}
14+
rpc DeactivateRegistration(DeactivateRegistrationRequest) returns (core.Registration) {}
1415
rpc PerformValidation(PerformValidationRequest) returns (core.Authorization) {}
15-
rpc DeactivateRegistration(core.Registration) returns (google.protobuf.Empty) {}
1616
rpc DeactivateAuthorization(core.Authorization) returns (google.protobuf.Empty) {}
1717
rpc RevokeCertByApplicant(RevokeCertByApplicantRequest) returns (google.protobuf.Empty) {}
1818
rpc RevokeCertByKey(RevokeCertByKeyRequest) returns (google.protobuf.Empty) {}
@@ -51,6 +51,10 @@ message UpdateRegistrationKeyRequest {
5151
bytes jwk = 2;
5252
}
5353

54+
message DeactivateRegistrationRequest {
55+
int64 registrationID = 1;
56+
}
57+
5458
message UpdateAuthorizationRequest {
5559
core.Authorization authz = 1;
5660
int64 challengeIndex = 2;

ra/proto/ra_grpc.pb.go

+26-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ra/ra.go

+5-11
Original file line numberDiff line numberDiff line change
@@ -2171,23 +2171,17 @@ func (ra *RegistrationAuthorityImpl) AdministrativelyRevokeCertificate(ctx conte
21712171
}
21722172

21732173
// DeactivateRegistration deactivates a valid registration
2174-
func (ra *RegistrationAuthorityImpl) DeactivateRegistration(ctx context.Context, reg *corepb.Registration) (*emptypb.Empty, error) {
2175-
if reg == nil || reg.Id == 0 {
2174+
func (ra *RegistrationAuthorityImpl) DeactivateRegistration(ctx context.Context, req *rapb.DeactivateRegistrationRequest) (*corepb.Registration, error) {
2175+
if req == nil || req.RegistrationID == 0 {
21762176
return nil, errIncompleteGRPCRequest
21772177
}
2178-
// TODO(#5554): Remove this check: this is only enforcing that the WFE has
2179-
// told us the correct status. The SA will enforce that the current status is
2180-
// valid during its database update.
2181-
if reg.Status != string(core.StatusValid) {
2182-
return nil, berrors.MalformedError("only valid registrations can be deactivated")
2183-
}
2184-
_, err := ra.SA.DeactivateRegistration(ctx, &sapb.RegistrationID{Id: reg.Id})
2178+
2179+
updatedAcct, err := ra.SA.DeactivateRegistration(ctx, &sapb.RegistrationID{Id: req.RegistrationID})
21852180
if err != nil {
21862181
return nil, err
21872182
}
21882183

2189-
// TODO(#5554): Return the updated account object.
2190-
return &emptypb.Empty{}, nil
2184+
return updatedAcct, nil
21912185
}
21922186

21932187
// DeactivateAuthorization deactivates a currently valid authorization

ra/ra_test.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -988,18 +988,13 @@ func TestDeactivateRegistration(t *testing.T) {
988988
defer cleanUp()
989989

990990
// Deactivate failure because incomplete registration provided
991-
_, err := ra.DeactivateRegistration(context.Background(), &corepb.Registration{})
991+
_, err := ra.DeactivateRegistration(context.Background(), &rapb.DeactivateRegistrationRequest{})
992992
test.AssertDeepEquals(t, err, fmt.Errorf("incomplete gRPC request message"))
993993

994-
// Deactivate failure because registration status already deactivated
995-
_, err = ra.DeactivateRegistration(context.Background(),
996-
&corepb.Registration{Id: 1, Status: string(core.StatusDeactivated)})
997-
test.AssertError(t, err, "DeactivateRegistration failed with a non-valid registration")
998-
999994
// Deactivate success with valid registration
1000-
_, err = ra.DeactivateRegistration(context.Background(),
1001-
&corepb.Registration{Id: 1, Status: string(core.StatusValid)})
995+
got, err := ra.DeactivateRegistration(context.Background(), &rapb.DeactivateRegistrationRequest{RegistrationID: 1})
1002996
test.AssertNotError(t, err, "DeactivateRegistration failed")
997+
test.AssertEquals(t, got.Status, string(core.StatusDeactivated))
1003998

1004999
// Check db to make sure account is deactivated
10051000
dbReg, err := ra.SA.GetRegistration(context.Background(), &sapb.RegistrationID{Id: 1})

0 commit comments

Comments
 (0)