Private
Public Access
1
0

Basic authentication support

This commit is contained in:
James Magahern
2019-01-23 20:26:35 -08:00
parent e6314b0f80
commit de852a926d
5 changed files with 133 additions and 3 deletions

View File

@@ -18,6 +18,10 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) UInt16 port;
@property (nonatomic, readonly) NSOperationQueue *operationQueue;
@property (nonatomic, assign) BOOL usesAccessControl;
@property (nonatomic, strong) NSString *authUsername;
@property (nonatomic, strong) NSString *authPassword;
@property (nonatomic, assign) BOOL usesSSL;
@property (nonatomic, strong) NSString *sslCertPath;

View File

@@ -29,6 +29,28 @@
return [[MBIMBridge sharedInstance] sslCertificateAndIdentity];
}
- (BOOL)isPasswordProtected:(NSString *)path
{
return [[MBIMBridge sharedInstance] usesAccessControl];
}
- (NSString *)passwordForUser:(NSString *)username
{
MBIMBridge *bridge = [MBIMBridge sharedInstance];
if ([username isEqualToString:bridge.authUsername]) {
return bridge.authPassword;
}
return @"";
}
- (BOOL)useDigestAccessAuthentication
{
// TODO: should use digest all the time, but it's a bit more complicated. Allow this to be NO if
// SSL is on, because then at least basic auth is encrypted
return ![[MBIMBridge sharedInstance] usesSSL];
}
- (BOOL)supportsMethod:(NSString *)method atPath:(NSString *)path
{
if ([method isEqualToString:@"GET"] || [method isEqualToString:@"POST"]) {