From aca46f22cf62dfe8ec2eb1673d57b71f3b594663 Mon Sep 17 00:00:00 2001 From: helge Date: Wed, 20 Oct 2004 22:07:58 +0000 Subject: [PATCH] extract IMAP4 password from request git-svn-id: http://svn.opengroupware.org/SOGo/trunk@417 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/Main/SOGoAuthenticator.h | 7 ++++++ SOGo/SoObjects/Mailer/ChangeLog | 5 ++++ SOGo/SoObjects/Mailer/SOGoMailBaseObject.m | 27 ++++++++++++++++++++-- SOGo/SoObjects/Mailer/Version | 4 ++-- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/SOGo/Main/SOGoAuthenticator.h b/SOGo/Main/SOGoAuthenticator.h index 2d4476d8..31e7afcb 100644 --- a/SOGo/Main/SOGoAuthenticator.h +++ b/SOGo/Main/SOGoAuthenticator.h @@ -25,6 +25,13 @@ #include +/* + SOGoAuthenticator + + This just overrides the login/pwd check method and always returns YES since + the password is already checked in Apache. +*/ + @interface SOGoAuthenticator : SoHTTPAuthenticator { } diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 954effab..a88df095 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,3 +1,8 @@ +2004-10-21 Helge Hess + + * SOGoMailBaseObject.m: extract IMAP4 password from HTTP basic + authentication (v0.9.36) + 2004-10-20 Marcus Mueller * SOGoMailAccounts.m: changed methods according to new API of diff --git a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m index 26f02e11..a6b8f631 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m @@ -24,11 +24,12 @@ #include "SOGoMailManager.h" #include "common.h" #include +#include #include @implementation SOGoMailBaseObject -static BOOL debugOn = YES; +//static BOOL debugOn = YES; static BOOL debugTree = NO; - (id)initWithImap4URL:(NSURL *)_url inContainer:(id)_container { @@ -105,7 +106,29 @@ static BOOL debugTree = NO; } - (NSString *)imap4Password { - return [[NSUserDefaults standardUserDefaults] stringForKey:@"hackpwd"]; + /* + Extract password from basic authentication. + + TODO: we might want to + a) move the primary code to SOGoMailAccount + b) cache the password + */ + WORequest *rq; + NSString *auth; + NSArray *creds; + + rq = [[(WOApplication *)[WOApplication application] context] request]; + if ((auth = [rq headerForKey:@"authorization"]) == nil) { + /* no basic auth */ + return nil; + } + + creds = [SoHTTPAuthenticator parseCredentials:auth]; + if ([creds count] < 2) + /* somehow invalid */ + return nil; + + return [creds objectAtIndex:1]; /* the password */ } - (NGImap4Client *)imap4ClientForURL:(NSURL *)_url password:(NSString *)_pwd { diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 79d695bd..734431d7 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ -# $Id$ +# Version file -SUBMINOR_VERSION:=35 +SUBMINOR_VERSION:=36 # v0.9.35 requires SOGoLogic v0.9.24 # v0.9.34 requires SOGoLogic v0.9.22 -- 2.39.5