Private
Public Access
1
0

updates: should really return 401 for bad auth instead of 404

This commit is contained in:
2025-06-16 19:18:14 -07:00
parent bb04bc4352
commit 800090542d

View File

@@ -17,6 +17,7 @@
#import <Security/Security.h>
#import "HTTPMessage.h"
#import "GCDAsyncSocket.h"
@interface HTTPConnection (/* INTERNAL */)
- (BOOL)isAuthenticated;
@@ -139,6 +140,14 @@
if (![self isAuthenticated] && ![queryAuthToken isValid]) {
NSLog(@"Websocket: auth invalid, rejecting.");
NSLog(@"Query Token: %@, raw: %@", queryAuthToken, authTokenString);
// Respond with 401 unauthorized
HTTPMessage *response = [[HTTPMessage alloc] initResponseWithStatusCode:401 description:nil version:HTTPVersion1_1];
[response setHeaderField:@"Content-Length" value:@"0"];
NSData *responseData = [self preprocessErrorResponse:response];
[asyncSocket writeData:responseData withTimeout:30 tag:90];
return nil;
}