From bb5c9ff1065afd0ac0dc7fe6dad91e860b595741 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 26 Sep 2018 09:30:51 -0400 Subject: [PATCH] Respond to CR. --- .../src/Contacts/ContactDiscoveryService.h | 16 ++++++++++++++-- .../src/Contacts/ContactDiscoveryService.m | 12 +----------- .../Contacts/OWSContactDiscoveryOperation.swift | 10 ++-------- .../src/Network/API/Requests/OWSRequestFactory.m | 1 + 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/SignalServiceKit/src/Contacts/ContactDiscoveryService.h b/SignalServiceKit/src/Contacts/ContactDiscoveryService.h index be0a47ef6..58952bb27 100644 --- a/SignalServiceKit/src/Contacts/ContactDiscoveryService.h +++ b/SignalServiceKit/src/Contacts/ContactDiscoveryService.h @@ -7,6 +7,15 @@ NS_ASSUME_NONNULL_BEGIN @class ECKeyPair; @class OWSAES256Key; +@interface RemoteAttestationAuth : NSObject + +@property (nonatomic, readonly) NSString *username; +@property (nonatomic, readonly) NSString *password; + +@end + +#pragma mark - + @interface RemoteAttestationKeys : NSObject @property (nonatomic, readonly) ECKeyPair *keyPair; @@ -18,17 +27,20 @@ NS_ASSUME_NONNULL_BEGIN @end +#pragma mark - + @interface RemoteAttestation : NSObject @property (nonatomic, readonly) RemoteAttestationKeys *keys; @property (nonatomic, readonly) NSArray *cookies; @property (nonatomic, readonly) NSData *requestId; @property (nonatomic, readonly) NSString *enclaveId; -@property (nonatomic, readonly) NSString *authUsername; -@property (nonatomic, readonly) NSString *authToken; +@property (nonatomic, readonly) RemoteAttestationAuth *auth; @end +#pragma mark - + @interface ContactDiscoveryService : NSObject - (instancetype)init NS_UNAVAILABLE; diff --git a/SignalServiceKit/src/Contacts/ContactDiscoveryService.m b/SignalServiceKit/src/Contacts/ContactDiscoveryService.m index c6d3e8e86..8f6fee440 100644 --- a/SignalServiceKit/src/Contacts/ContactDiscoveryService.m +++ b/SignalServiceKit/src/Contacts/ContactDiscoveryService.m @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface RemoteAttestationAuth : NSObject +@interface RemoteAttestationAuth () @property (nonatomic) NSString *username; @property (nonatomic) NSString *password; @@ -152,16 +152,6 @@ NS_ASSUME_NONNULL_BEGIN @implementation RemoteAttestation -- (NSString *)authUsername -{ - return self.auth.username; -} - -- (NSString *)authToken -{ - return self.auth.password; -} - @end #pragma mark - diff --git a/SignalServiceKit/src/Contacts/OWSContactDiscoveryOperation.swift b/SignalServiceKit/src/Contacts/OWSContactDiscoveryOperation.swift index 0774af072..df4ac48dc 100644 --- a/SignalServiceKit/src/Contacts/OWSContactDiscoveryOperation.swift +++ b/SignalServiceKit/src/Contacts/OWSContactDiscoveryOperation.swift @@ -7,9 +7,6 @@ import Foundation @objc(OWSLegacyContactDiscoveryOperation) class LegacyContactDiscoveryBatchOperation: OWSOperation { - // TODO: Remove this feature flag. - private let isCDSEnabled = true - @objc var registeredRecipientIds: Set @@ -86,9 +83,6 @@ class LegacyContactDiscoveryBatchOperation: OWSOperation { // Called at most one time. override func didSucceed() { - guard isCDSEnabled else { - return - } // Compare against new CDS service let modernCDSOperation = CDSOperation(recipientIdsToLookup: self.recipientIdsToLookup) let cdsFeedbackOperation = CDSFeedbackOperation(legacyRegisteredRecipientIds: self.registeredRecipientIds) @@ -271,8 +265,8 @@ class CDSBatchOperation: OWSOperation { cryptIv: encryptionResult.initializationVector, cryptMac: encryptionResult.authTag, enclaveId: remoteAttestation.enclaveId, - authUsername: remoteAttestation.authUsername, - authPassword: remoteAttestation.authToken, + authUsername: remoteAttestation.auth.username, + authPassword: remoteAttestation.auth.password, cookies: remoteAttestation.cookies) self.networkManager.makeRequest(request, diff --git a/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m b/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m index 1358cbaf8..04caf17a8 100644 --- a/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m +++ b/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m @@ -328,6 +328,7 @@ NS_ASSUME_NONNULL_BEGIN // these cookies are ephemeral. [request setHTTPShouldHandleCookies:NO]; // Set the cookie header. + OWSAssertDebug(request.allHTTPHeaderFields.count == 0); [request setAllHTTPHeaderFields:[NSHTTPCookie requestHeaderFieldsWithCookies:cookies]]; return request;