See ChangeLog.

Monotone-Parent: 42fa26da9b1def06a194726cab4199338a4bdf4c
Monotone-Revision: 88b07aa8edf775fa02705a9c03a0f8f14f905db3

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2011-07-15T22:22:11
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Francis Lachapelle 2011-07-15 22:22:11 +00:00
parent 8aae19aeb8
commit 620872202d
14 changed files with 111 additions and 72 deletions

View File

@ -1,8 +1,27 @@
2011-07-15 Francis Lachapelle <flachapelle@inverse.ca>
2011-07-18 Francis Lachapelle <flachapelle@inverse.ca>
* SoObjects/SOGo/SOGoUser.m (-initWithLogin:roles:trust:): when
the login contains a @ character, compare the right part with only the
defined login domains (SOGoLoginDomains) -- don't consider all domains.
* SoObjects/SOGo/SOGoSystemDefaults.m (-addDomainToUID): new
method that returns the boolean value of the new system defaults
SOGoAddDomainToUID if at least one domain is defined.
* SoObjects/SOGo/SOGoUser.m (-initWithLogin:roles:trust:): we now
try to extract the domain part of the login name only if the new
system defaults SOGoAddDomainToUID is set to YES.
* SoObjects/SOGo/SOGoUserManager.m
(-contactInfosForUserWithUIDorEmail): idem.
* SoObjects/SOGo/SOGoSession.m
(+decodeValue:usingKey:login:domain:password:): idem.
* SoObjects/SOGo/SOGoUserManager.m
(-_sourceCheckLogin:andPassword:domain:perr:expire:grace:): the
domain argument is now a pointer so it will be set according to
the matching authentication source.
* UI/MainUI/SOGoUserHomePage.m (-usersSearchAction): only append
the domain to the user's login if the new system defaults
SOGoAddToDomainToUID is set to YES.
2011-07-15 Wolfgang Sourdeau <wsourdeau@inverse.ca>

View File

@ -53,18 +53,20 @@
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
{
NSString *domain;
SOGoSystemDefaults *sd;
SOGoCASSession *session;
SOGoPasswordPolicyError perr;
int expire, grace;
BOOL rc;
domain = nil;
perr = PolicyNoError;
rc = ([[SOGoUserManager sharedUserManager]
checkLogin: [_login stringByReplacingString: @"%40"
withString: @"@"]
password: _pwd
domain: nil
domain: &domain
perr: &perr
expire: &expire
grace: &grace]

View File

@ -29,6 +29,7 @@
SOGoWebAccessEnabled = YES;
SOGoCalendarDAVAccessEnabled = YES;
SOGoAddressBookDAVAccessEnabled = YES;
SOGoAddDomainToUID = NO;
SOGoLoginModule = "Mail";
SOGoLanguage = "English";
@ -38,15 +39,13 @@
"Russian", "Ukrainian", "Swedish");
SOGoTimeZone = "UTC";
SOGoDayStartTime = "8";
SOGoDayEndTime = "18";
SOGoTimeFormat = "%H:%M";
SOGoIMAPServer = "localhost";
SOGoFirstDayOfWeek = 0;
SOGoFirstWeekOfYear = "January1";
SOGoIMAPServer = "localhost";
SOGoMailDomain = "localhost";
SOGoMailMessageCheck = "manually";
SOGoMailMessageForwarding = "inline";
@ -57,7 +56,6 @@
SOGoMailListViewColumnsOrder = ( "Thread", "Flagged", "Attachment", "Subject",
"From", "Unread", "Date", "Priority",
"Size" );
SOGoSentFolderName = "Sent";
SOGoDraftsFolderName = "Drafts";
SOGoTrashFolderName = "Trash";

View File

@ -251,21 +251,23 @@
r = [decodedValue rangeOfString: @":"];
*theLogin = [decodedValue substringToIndex: r.location];
*thePassword = [decodedValue substringFromIndex: r.location+1];
r = [*theLogin rangeOfString: @"@" options: NSBackwardsSearch];
if (r.location != NSNotFound)
*theDomain = nil;
sd = [SOGoSystemDefaults sharedSystemDefaults];
if ([sd addDomainToUID])
{
// The domain is probably appended to the username;
// make sure it is defined as a login domain in the configuration.
sd = [SOGoSystemDefaults sharedSystemDefaults];
*theDomain = [*theLogin substringFromIndex: (r.location + r.length)];
if ([[sd loginDomains] containsObject: *theDomain])
*theLogin = [*theLogin substringToIndex: r.location];
else
*theDomain = nil;
r = [*theLogin rangeOfString: @"@" options: NSBackwardsSearch];
if (r.location != NSNotFound)
{
// The domain is probably appended to the username;
// make sure it is defined as a domain in the configuration.
*theDomain = [*theLogin substringFromIndex: (r.location + r.length)];
if ([[sd domainIds] containsObject: *theDomain])
*theLogin = [*theLogin substringToIndex: r.location];
else
*theDomain = nil;
}
}
else
*theDomain = nil;
}
@end

View File

@ -34,6 +34,7 @@
+ (SOGoSystemDefaults *) sharedSystemDefaults;
- (NSArray *) domainIds;
- (BOOL) addDomainToUID;
- (NSArray *) loginDomains;
- (NSArray *) visibleDomainsForDomain: (NSString *) domain;

View File

@ -193,6 +193,11 @@ BootstrapNSUserDefaults ()
return [[self dictionaryForKey: @"domains"] allKeys];
}
- (BOOL) addDomainToUID
{
return ([[self domainIds] count] > 0 && [self boolForKey: @"SOGoAddDomainToUID"]);
}
- (NSArray *) loginDomains
{
NSMutableArray *filteredLoginDomains;
@ -237,11 +242,11 @@ BootstrapNSUserDefaults ()
[domains addObjectsFromArray: currentGroup];
}
// Remove lookup domain from list
// Remove lookup domain and invalid domains
groups = [domains objectEnumerator];
while ((currentDomain = [groups nextObject]))
{
if ([currentDomain isEqualToString: domain])
if ([currentDomain isEqualToString: domain] || ![definedDomains containsObject: currentDomain])
[domains removeObject: currentDomain];
}

View File

@ -124,7 +124,8 @@
/**
* Return a new instance for the login name, which can be appended by a
* domain name.
* domain name. The domain is extracted only if the system defaults
* SOGoAddDomainToUID is enabled.
*
* @param newLogin a login name optionally follow by @domain
* @param newRoles
@ -152,17 +153,20 @@
realUID = newLogin;
else
{
r = [newLogin rangeOfString: @"@" options: NSBackwardsSearch];
if (r.location != NSNotFound)
sd = [SOGoSystemDefaults sharedSystemDefaults];
if ([sd addDomainToUID])
{
// The domain is probably appended to the username;
// make sure it is defined as a login domain in the configuration.
sd = [SOGoSystemDefaults sharedSystemDefaults];
domain = [newLogin substringFromIndex: (r.location + r.length)];
if ([[sd loginDomains] containsObject: domain])
newLogin = [newLogin substringToIndex: r.location];
else
domain = nil;
r = [newLogin rangeOfString: @"@" options: NSBackwardsSearch];
if (r.location != NSNotFound)
{
// The domain is probably appended to the username;
// make sure it is defined as a domain in the configuration.
domain = [newLogin substringFromIndex: (r.location + r.length)];
if ([[sd domainIds] containsObject: domain])
newLogin = [newLogin substringToIndex: r.location];
else
domain = nil;
}
}
newLogin = [newLogin stringByReplacingString: @"%40"

View File

@ -83,7 +83,7 @@
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
domain: (NSString *) _domain
domain: (NSString **) _domain
perr: (SOGoPasswordPolicyError *) _perr
expire: (int *) _expire
grace: (int *) _grace;

View File

@ -396,7 +396,7 @@
- (BOOL) _sourceCheckLogin: (NSString *) login
andPassword: (NSString *) password
domain: (NSString *) domain
domain: (NSString **) domain
perr: (SOGoPasswordPolicyError *) perr
expire: (int *) expire
grace: (int *) grace
@ -408,23 +408,26 @@
checkOK = NO;
authIDs = [[self authenticationSourceIDsInDomain: domain] objectEnumerator];
authIDs = [[self authenticationSourceIDsInDomain: *domain] objectEnumerator];
while (!checkOK && (currentID = [authIDs nextObject]))
{
sogoSource = [_sources objectForKey: currentID];
checkOK = [sogoSource checkLogin: login
password: password
perr: perr
expire: expire
grace: grace];
password: password
perr: perr
expire: expire
grace: grace];
}
if (checkOK && *domain == nil)
*domain = [sogoSource domain];
return checkOK;
}
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
domain: (NSString *) _domain
domain: (NSString **) _domain
perr: (SOGoPasswordPolicyError *) _perr
expire: (int *) _expire
grace: (int *) _grace
@ -436,8 +439,8 @@
// We check for cached passwords. If the entry is cached, we
// check this immediately. If not, we'll go directly at the
// authentication source and try to validate there, then cache it.
if (_domain)
username = [NSString stringWithFormat: @"%@@%@", _login, _domain];
if (*_domain != nil)
username = [NSString stringWithFormat: @"%@@%@", _login, *_domain];
else
username = _login;
jsonUser = [[SOGoCache sharedCache] userAttributesForLogin: username];
@ -502,13 +505,12 @@
newPassword: (NSString *) newPassword
perr: (SOGoPasswordPolicyError *) perr
{
NSString *dictPassword, *jsonUser;
NSString *jsonUser;
NSMutableDictionary *currentUser;
BOOL didChange;
jsonUser = [[SOGoCache sharedCache] userAttributesForLogin: login];
currentUser = [jsonUser objectFromJSONString];
dictPassword = [currentUser objectForKey: @"password"];
if ([self _sourceChangePasswordForLogin: login
inDomain: domain
@ -713,27 +715,31 @@
domain = nil;
infos = nil;
r = [uid rangeOfString: @"@" options: NSBackwardsSearch];
if (r.location != NSNotFound)
sd = [SOGoSystemDefaults sharedSystemDefaults];
if ([sd addDomainToUID])
{
// The domain is probably appended to the username;
// make sure it is a defined domain in the configuration.
sd = [SOGoSystemDefaults sharedSystemDefaults];
domain = [uid substringFromIndex: (r.location + r.length)];
if ([[sd domainIds] containsObject: domain])
username = [uid substringToIndex: r.location];
else
domain = nil;
r = [uid rangeOfString: @"@" options: NSBackwardsSearch];
if (r.location != NSNotFound)
{
// The domain is probably appended to the username;
// make sure it is a defined domain in the configuration.
domain = [uid substringFromIndex: (r.location + r.length)];
if ([[sd domainIds] containsObject: domain])
username = [uid substringToIndex: r.location];
else
domain = nil;
}
if (domain != nil)
infos = [self contactInfosForUserWithUIDorEmail: username
inDomain: domain];
}
if (domain != nil)
infos = [self contactInfosForUserWithUIDorEmail: username
inDomain: domain];
if (infos == nil)
// If the user was not found using the domain or if no domain was detected,
// search using the original uid.
infos = [self contactInfosForUserWithUIDorEmail: uid
inDomain: nil];
return infos;
}

View File

@ -40,7 +40,7 @@
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
domain: (NSString *) _domain
domain: (NSString **) _domain
perr: (SOGoPasswordPolicyError *) _perr
expire: (int *) _expire
grace: (int *) _grace;

View File

@ -65,7 +65,7 @@
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
{
NSString *username, *domain, *password, *value;
NSString *username, *password, *domain, *value;
SOGoPasswordPolicyError perr;
int expire, grace;
@ -83,6 +83,7 @@
if (!value)
return NO;
domain = nil;
[SOGoSession decodeValue: value
usingKey: _login
login: &username
@ -91,7 +92,7 @@
return [self checkLogin: username
password: password
domain: domain
domain: &domain
perr: &perr
expire: &expire
grace: &grace];
@ -99,7 +100,7 @@
- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
domain: (NSString *) _domain
domain: (NSString **) _domain
perr: (SOGoPasswordPolicyError *) _perr
expire: (int *) _expire
grace: (int *) _grace
@ -207,7 +208,7 @@
if (![self checkLogin: login
password: pwd
domain: domain
domain: &domain
perr: &perr
expire: &expire
grace: &grace])

View File

@ -167,7 +167,7 @@
language = [request formValueForKey: @"language"];
domain = [request formValueForKey: @"domain"];
if ((b = [auth checkLogin: username password: password domain: domain
if ((b = [auth checkLogin: username password: password domain: &domain
perr: &err expire: &expire grace: &grace])
&& (err == PolicyNoError)
// no password policy

View File

@ -366,30 +366,31 @@
{
NSMutableArray *users;
NSArray *currentUsers;
NSString *contact, *domain;
NSString *contact, *domain, *uidDomain;
NSEnumerator *visibleDomains;
id <WOActionResults> result;
SOGoUserManager *um;
SOGoSystemDefaults *sd;
um = [SOGoUserManager sharedUserManager];
contact = [self queryParameterForKey: @"search"];
if ([contact length])
{
um = [SOGoUserManager sharedUserManager];
sd = [SOGoSystemDefaults sharedSystemDefaults];
domain = [[context activeUser] domain];
uidDomain = [sd addDomainToUID]? domain : nil;
users = [self _usersForResults: [um fetchUsersMatching: contact
inDomain: domain]
inDomain: domain];
inDomain: uidDomain];
if ([domain length])
{
// Add results from visible domains
sd = [SOGoSystemDefaults sharedSystemDefaults];
visibleDomains = [[sd visibleDomainsForDomain: domain] objectEnumerator];
while ((domain = [visibleDomains nextObject]))
{
currentUsers = [self _usersForResults: [um fetchUsersMatching: contact
inDomain: domain]
inDomain: domain];
inDomain: uidDomain];
[users addObjectsFromArray: currentUsers];
}
}