Allow multiple user accounts for authentication

This commit is contained in:
Pierre-Olivier Latour
2014-04-18 12:50:09 -03:00
parent 80cff01154
commit 1ca5a56952
5 changed files with 53 additions and 46 deletions
+7 -9
View File
@@ -300,16 +300,14 @@ int main(int argc, const char* argv[]) {
NSMutableDictionary* options = [NSMutableDictionary dictionary];
[options setObject:@8080 forKey:GCDWebServerOption_Port];
[options setObject:@"" forKey:GCDWebServerOption_BonjourName];
if ([authenticationMethod isEqualToString:@"Basic"]) {
[options setObject:GCDWebServerAuthenticationMethod_Basic forKey:GCDWebServerOption_AuthenticationMethod];
if (authenticationUser && authenticationPassword) {
[options setValue:authenticationRealm forKey:GCDWebServerOption_AuthenticationRealm];
[options setValue:authenticationUser forKey:GCDWebServerOption_AuthenticationUser];
[options setValue:authenticationPassword forKey:GCDWebServerOption_AuthenticationPassword];
} else if ([authenticationMethod isEqualToString:@"Digest"]) {
[options setObject:GCDWebServerAuthenticationMethod_DigestAccess forKey:GCDWebServerOption_AuthenticationMethod];
[options setValue:authenticationRealm forKey:GCDWebServerOption_AuthenticationRealm];
[options setValue:authenticationUser forKey:GCDWebServerOption_AuthenticationUser];
[options setValue:authenticationPassword forKey:GCDWebServerOption_AuthenticationPassword];
[options setObject:@{authenticationUser: authenticationPassword} forKey:GCDWebServerOption_AuthenticationAccounts];
if ([authenticationMethod isEqualToString:@"Basic"]) {
[options setObject:GCDWebServerAuthenticationMethod_Basic forKey:GCDWebServerOption_AuthenticationMethod];
} else if ([authenticationMethod isEqualToString:@"Digest"]) {
[options setObject:GCDWebServerAuthenticationMethod_DigestAccess forKey:GCDWebServerOption_AuthenticationMethod];
}
}
if ([webServer runWithOptions:options]) {
result = 0;