From feac080fa74c7ef893c92e7abe0bc4d509db4226 Mon Sep 17 00:00:00 2001 From: Russell Hancox Date: Thu, 27 Apr 2023 10:52:35 -0400 Subject: [PATCH] sync: Permit XSRF header between sync stages/sessions (#1081) --- Source/santasyncservice/SNTSyncManager.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/santasyncservice/SNTSyncManager.m b/Source/santasyncservice/SNTSyncManager.m index 0bf9dea8..56f8e0fa 100644 --- a/Source/santasyncservice/SNTSyncManager.m +++ b/Source/santasyncservice/SNTSyncManager.m @@ -54,6 +54,7 @@ static const uint8_t kMaxEnqueuedSyncs = 2; @property NSUInteger eventBatchSize; @property NSString *xsrfToken; +@property NSString *xsrfTokenHeader; @end @@ -125,6 +126,7 @@ static void reachabilityHandler(SCNetworkReachabilityRef target, SCNetworkReacha [self startReachability]; } self.xsrfToken = syncState.xsrfToken; + self.xsrfTokenHeader = syncState.xsrfTokenHeader; } - (void)postBundleEventToSyncServer:(SNTStoredEvent *)event @@ -158,6 +160,7 @@ static void reachabilityHandler(SCNetworkReachabilityRef target, SCNetworkReacha [self startReachability]; } self.xsrfToken = syncState.xsrfToken; + self.xsrfTokenHeader = syncState.xsrfTokenHeader; } - (void)isFCMListening:(void (^)(BOOL))reply { @@ -229,6 +232,7 @@ static void reachabilityHandler(SCNetworkReachabilityRef target, SCNetworkReacha BOOL ret = [p sync]; LOGD(@"Rule download %@", ret ? @"complete" : @"failed"); self.xsrfToken = syncState.xsrfToken; + self.xsrfTokenHeader = syncState.xsrfTokenHeader; }); } @@ -254,6 +258,7 @@ static void reachabilityHandler(SCNetworkReachabilityRef target, SCNetworkReacha if ([p sync]) { SLOGD(@"Preflight complete"); self.xsrfToken = syncState.xsrfToken; + self.xsrfTokenHeader = syncState.xsrfTokenHeader; // Clean up reachability if it was started for a non-network error [self stopReachability]; @@ -355,6 +360,7 @@ static void reachabilityHandler(SCNetworkReachabilityRef target, SCNetworkReacha } syncState.xsrfToken = self.xsrfToken; + syncState.xsrfTokenHeader = self.xsrfTokenHeader; NSURLSessionConfiguration *sessConfig = [NSURLSessionConfiguration defaultSessionConfiguration]; sessConfig.connectionProxyDictionary = [[SNTConfigurator configurator] syncProxyConfig];