sync: Permit XSRF header between sync stages/sessions (#1081)

This commit is contained in:
Russell Hancox 2023-04-27 10:52:35 -04:00 committed by GitHub
parent d0f2a0ac4d
commit feac080fa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -54,6 +54,7 @@ static const uint8_t kMaxEnqueuedSyncs = 2;
@property NSUInteger eventBatchSize; @property NSUInteger eventBatchSize;
@property NSString *xsrfToken; @property NSString *xsrfToken;
@property NSString *xsrfTokenHeader;
@end @end
@ -125,6 +126,7 @@ static void reachabilityHandler(SCNetworkReachabilityRef target, SCNetworkReacha
[self startReachability]; [self startReachability];
} }
self.xsrfToken = syncState.xsrfToken; self.xsrfToken = syncState.xsrfToken;
self.xsrfTokenHeader = syncState.xsrfTokenHeader;
} }
- (void)postBundleEventToSyncServer:(SNTStoredEvent *)event - (void)postBundleEventToSyncServer:(SNTStoredEvent *)event
@ -158,6 +160,7 @@ static void reachabilityHandler(SCNetworkReachabilityRef target, SCNetworkReacha
[self startReachability]; [self startReachability];
} }
self.xsrfToken = syncState.xsrfToken; self.xsrfToken = syncState.xsrfToken;
self.xsrfTokenHeader = syncState.xsrfTokenHeader;
} }
- (void)isFCMListening:(void (^)(BOOL))reply { - (void)isFCMListening:(void (^)(BOOL))reply {
@ -229,6 +232,7 @@ static void reachabilityHandler(SCNetworkReachabilityRef target, SCNetworkReacha
BOOL ret = [p sync]; BOOL ret = [p sync];
LOGD(@"Rule download %@", ret ? @"complete" : @"failed"); LOGD(@"Rule download %@", ret ? @"complete" : @"failed");
self.xsrfToken = syncState.xsrfToken; self.xsrfToken = syncState.xsrfToken;
self.xsrfTokenHeader = syncState.xsrfTokenHeader;
}); });
} }
@ -254,6 +258,7 @@ static void reachabilityHandler(SCNetworkReachabilityRef target, SCNetworkReacha
if ([p sync]) { if ([p sync]) {
SLOGD(@"Preflight complete"); SLOGD(@"Preflight complete");
self.xsrfToken = syncState.xsrfToken; self.xsrfToken = syncState.xsrfToken;
self.xsrfTokenHeader = syncState.xsrfTokenHeader;
// Clean up reachability if it was started for a non-network error // Clean up reachability if it was started for a non-network error
[self stopReachability]; [self stopReachability];
@ -355,6 +360,7 @@ static void reachabilityHandler(SCNetworkReachabilityRef target, SCNetworkReacha
} }
syncState.xsrfToken = self.xsrfToken; syncState.xsrfToken = self.xsrfToken;
syncState.xsrfTokenHeader = self.xsrfTokenHeader;
NSURLSessionConfiguration *sessConfig = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSessionConfiguration *sessConfig = [NSURLSessionConfiguration defaultSessionConfiguration];
sessConfig.connectionProxyDictionary = [[SNTConfigurator configurator] syncProxyConfig]; sessConfig.connectionProxyDictionary = [[SNTConfigurator configurator] syncProxyConfig];