Private
Public Access
1
0

2 Commits

Author SHA1 Message Date
James Magahern
37ff0b375f send: must be performed on main queue 2023-07-06 15:27:31 -07:00
James Magahern
d071e68a56 Security: adds authentication to updates websocket operation 2023-07-06 15:27:12 -07:00
2 changed files with 11 additions and 1 deletions

View File

@@ -13,6 +13,7 @@
#import "MBIMBridgeOperation.h"
#import "MBIMAuthToken.h"
#import "MBIMUpdateQueue.h"
#import "MBIMURLUtilities.h"
#import <Security/Security.h>
#import <CocoaHTTPServer/HTTPMessage.h>
@@ -130,7 +131,14 @@
{
NSURL *url = [NSURL URLWithString:path];
NSString *endpointName = [url lastPathComponent];
NSString *authTokenString = [url valueForQueryItemWithName:@"token"];
MBIMAuthToken *authToken = [[MBIMAuthToken alloc] initWithTokenString:authTokenString];
if ([endpointName isEqualToString:@"updates"]) {
if (![authToken isValid]) {
return nil;
}
return [[MBIMUpdateQueue sharedInstance] vendUpdateWebSocketConsumerForRequest:request socket:asyncSocket];
}

View File

@@ -46,7 +46,9 @@
MBIMLogInfo(@"Chat does not exist: %@", chatGUID);
result = NO;
} else {
[chat sendMessage:reply];
dispatch_async(dispatch_get_main_queue(), ^{
[chat sendMessage:reply];
});
}
});