Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add profile filter to Get[Valid]Authorizations methods
Browse files Browse the repository at this point in the history
aarongable committed Feb 1, 2025
1 parent b155102 commit 69bfacc
Showing 4 changed files with 676 additions and 645 deletions.
2 changes: 2 additions & 0 deletions ra/ra.go
Original file line number Diff line number Diff line change
@@ -2232,13 +2232,15 @@ func (ra *RegistrationAuthorityImpl) NewOrder(ctx context.Context, req *rapb.New
RegistrationID: newOrder.RegistrationID,
ValidUntil: timestamppb.New(authzExpiryCutoff),
DnsNames: newOrder.DnsNames,
Profile: req.CertificateProfileName,
}
existingAuthz, err = ra.SA.GetValidAuthorizations2(ctx, getAuthReq)
} else {
getAuthReq := &sapb.GetAuthorizationsRequest{
RegistrationID: newOrder.RegistrationID,
ValidUntil: timestamppb.New(authzExpiryCutoff),
DnsNames: newOrder.DnsNames,
Profile: req.CertificateProfileName,
}
existingAuthz, err = ra.SA.GetAuthorizations2(ctx, getAuthReq)
}
1,305 changes: 662 additions & 643 deletions sa/proto/sa.pb.go

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions sa/proto/sa.proto
Original file line number Diff line number Diff line change
@@ -108,11 +108,12 @@ message AuthorizationID {
}

message GetValidAuthorizationsRequest {
// Next unused field number: 5
// Next unused field number: 6
int64 registrationID = 1;
repeated string dnsNames = 2;
reserved 3; // Previously nowNS
google.protobuf.Timestamp validUntil = 4;
string profile = 5;
}

message Serial {
@@ -267,11 +268,12 @@ message FinalizeOrderRequest {
}

message GetAuthorizationsRequest {
// Next unused field number: 5
// Next unused field number: 6
int64 registrationID = 1;
repeated string dnsNames = 2;
reserved 3; // Previously nowNS
google.protobuf.Timestamp validUntil = 4;
string profile = 5;
}

message Authorizations {
8 changes: 8 additions & 0 deletions sa/saro.go
Original file line number Diff line number Diff line change
@@ -645,6 +645,10 @@ func (ssa *SQLStorageAuthorityRO) GetAuthorizations2(ctx context.Context, req *s

authzModelMap := make(map[string]authzModel, len(authzModels))
for _, am := range authzModels {
if req.Profile != "" && am.CertificateProfileName != &req.Profile {
// Don't return authzs whose profile doesn't match that requested.
continue
}
// If there is an existing authorization in the map, only replace it with
// one which has a "better" validation state (valid instead of pending).
existing, present := authzModelMap[am.IdentifierValue]
@@ -820,6 +824,10 @@ func (ssa *SQLStorageAuthorityRO) GetValidAuthorizations2(ctx context.Context, r

authzMap := make(map[string]authzModel, len(authzModels))
for _, am := range authzModels {
if req.Profile != "" && am.CertificateProfileName != &req.Profile {
// Don't return authzs whose profile doesn't match that requested.
continue
}
// If there is an existing authorization in the map only replace it with one
// which has a later expiry.
existing, present := authzMap[am.IdentifierValue]

0 comments on commit 69bfacc

Please sign in to comment.