Auth: Use Set-Cookie for auth token
This commit is contained in:
@@ -60,9 +60,14 @@
|
|||||||
MBIMAuthToken *token = [[MBIMAuthToken alloc] initWithUsername:username];
|
MBIMAuthToken *token = [[MBIMAuthToken alloc] initWithUsername:username];
|
||||||
|
|
||||||
// All systems go
|
// All systems go
|
||||||
response = [MBIMJSONDataResponse responseWithJSONObject:@{
|
MBIMJSONDataResponse *dataResponse = [MBIMJSONDataResponse responseWithJSONObject:@{
|
||||||
@"jwt" : token.jwtToken
|
@"jwt" : token.jwtToken
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
// Send a cookie down so we can use httpOnly cookies
|
||||||
|
dataResponse.httpHeaders[@"Set-Cookie"] = [NSString stringWithFormat:@"auth_token=%@", token.jwtToken];
|
||||||
|
|
||||||
|
response = dataResponse;
|
||||||
} while (NO);
|
} while (NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface MBIMDataResponse : HTTPDataResponse
|
@interface MBIMDataResponse : HTTPDataResponse
|
||||||
|
@property (nonatomic, readonly) NSMutableDictionary *httpHeaders;
|
||||||
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType;
|
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
@implementation MBIMDataResponse {
|
@implementation MBIMDataResponse {
|
||||||
NSString *_contentType;
|
NSString *_contentType;
|
||||||
|
NSMutableDictionary *_httpHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType
|
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType
|
||||||
@@ -17,6 +18,9 @@
|
|||||||
self = [super initWithData:data];
|
self = [super initWithData:data];
|
||||||
if (self) {
|
if (self) {
|
||||||
_contentType = contentType;
|
_contentType = contentType;
|
||||||
|
_httpHeaders = [@{
|
||||||
|
@"Content-Type" : _contentType ?: @"application/octet-stream"
|
||||||
|
} mutableCopy];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
@@ -24,9 +28,7 @@
|
|||||||
|
|
||||||
- (NSDictionary *)httpHeaders
|
- (NSDictionary *)httpHeaders
|
||||||
{
|
{
|
||||||
return @{
|
return _httpHeaders;
|
||||||
@"Content-Type" : _contentType ?: @"application/octet-stream"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user