mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-03-17 20:45:56 +00:00
Monotone-Parent: 7f0ab11449bfed467e7eb2411375074d9017d620
Monotone-Revision: cb310c719dd9d9eb9bc98d19485f667d0d6bf777 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-09-04T15:39:51 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
2007-09-04 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/SOGoWebAuthenticator.m: new class module
|
||||
implementing a subclass of SoCookieAuthenticator, designed for
|
||||
web-based cookie authentication of users.m
|
||||
|
||||
* UI/MainUI/SOGoUserHomePage.m ([SOGoUserHomePage -logoffAction]):
|
||||
new method that resets the authentification cookie.
|
||||
|
||||
|
||||
42
SoObjects/SOGo/SOGoWebAuthenticator.h
Normal file
42
SoObjects/SOGo/SOGoWebAuthenticator.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* SOGoWebAuthenticator.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2007 Inverse groupe conseil
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _SOGOWEBAUTHENTICATOR_H_
|
||||
#define _SOGOWEBAUTHENTICATOR_H_
|
||||
|
||||
#import <NGObjWeb/SoCookieAuthenticator.h>
|
||||
#import "SOGoAuthenticator.h"
|
||||
|
||||
@class NSString;
|
||||
|
||||
@class SOGoUser;
|
||||
|
||||
@interface SOGoWebAuthenticator : SoCookieAuthenticator
|
||||
{
|
||||
NSString *authMethod;
|
||||
}
|
||||
|
||||
+ (id) sharedSOGoWebAuthenticator;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* _SOGOWEBAUTHENTICATOR_H__ */
|
||||
157
SoObjects/SOGo/SOGoWebAuthenticator.m
Normal file
157
SoObjects/SOGo/SOGoWebAuthenticator.m
Normal file
@@ -0,0 +1,157 @@
|
||||
/* SOGoWebAuthenticator.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2007 Inverse groupe conseil
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
|
||||
#import <NGObjWeb/WOApplication.h>
|
||||
#import <NGObjWeb/WOContext.h>
|
||||
#import <NGObjWeb/WORequest.h>
|
||||
#import <NGObjWeb/WOResponse.h>
|
||||
#import <NGLdap/NGLdapConnection.h>
|
||||
|
||||
#import <UI/MainUI/SOGoRootPage.h>
|
||||
|
||||
#import "LDAPUserManager.h"
|
||||
#import "SOGoPermissions.h"
|
||||
#import "SOGoUser.h"
|
||||
|
||||
#import "SOGoWebAuthenticator.h"
|
||||
|
||||
@implementation SOGoWebAuthenticator
|
||||
|
||||
+ (id) sharedSOGoWebAuthenticator
|
||||
{
|
||||
static SOGoWebAuthenticator *auth = nil;
|
||||
|
||||
if (!auth)
|
||||
auth = [self new];
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
authMethod = [[NSUserDefaults standardUserDefaults]
|
||||
stringForKey: @"SOGoAuthentificationMethod"];
|
||||
[authMethod retain];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[authMethod release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL) checkLogin: (NSString *) _login
|
||||
password: (NSString *) _pwd
|
||||
{
|
||||
BOOL accept;
|
||||
LDAPUserManager *um;
|
||||
|
||||
if ([authMethod isEqualToString: @"LDAP"])
|
||||
{
|
||||
um = [LDAPUserManager sharedUserManager];
|
||||
accept = [um checkLogin: _login andPassword: _pwd];
|
||||
}
|
||||
else
|
||||
accept = ([authMethod isEqualToString: @"bypass"]
|
||||
&& [_login length] > 0);
|
||||
|
||||
return accept;
|
||||
// || ([_login isEqualToString: @"freebusy"]
|
||||
// && [_pwd isEqualToString: @"freebusy"]));
|
||||
}
|
||||
|
||||
- (NSString *) passwordInContext: (WOContext *) context
|
||||
{
|
||||
NSArray *creds;
|
||||
NSString *auth, *password;
|
||||
|
||||
auth = [[context request] cookieValueForKey:
|
||||
[self cookieNameInContext: context]];
|
||||
creds = [self parseCredentials: auth];
|
||||
if ([creds count] > 1)
|
||||
password = [creds objectAtIndex: 1];
|
||||
else
|
||||
password = nil;
|
||||
|
||||
return password;
|
||||
}
|
||||
|
||||
/* create SOGoUser */
|
||||
|
||||
- (SOGoUser *) userWithLogin: (NSString *) login
|
||||
andRoles: (NSArray *) roles
|
||||
inContext: (WOContext *) ctx
|
||||
{
|
||||
/* the actual factory method */
|
||||
return [SOGoUser userWithLogin: login roles: roles];
|
||||
}
|
||||
|
||||
- (void) setupAuthFailResponse: (WOResponse *) response
|
||||
withReason: (NSString *) reason
|
||||
inContext: (WOContext *) context
|
||||
{
|
||||
id page;
|
||||
|
||||
page = [[WOApplication application] pageWithName: @"SOGoRootPage"
|
||||
inContext: context];
|
||||
[page appendToResponse: response inContext: context];
|
||||
}
|
||||
|
||||
// - (BOOL) renderException: (NSException *) exception
|
||||
// inContext: (WOContext *) context
|
||||
// {
|
||||
// id renderedException;
|
||||
// WOComponent *tmpComponent;
|
||||
// WOResponse *response;
|
||||
// BOOL rc;
|
||||
|
||||
// rc = [super renderException: exception inContext: context];
|
||||
// if (!rc)
|
||||
// {
|
||||
// tmpComponent = [WOComponent new];
|
||||
// renderedException = [tmpComponent pageWithName: @"UIxException"];
|
||||
// if (renderedException)
|
||||
// {
|
||||
// rc = YES;
|
||||
// response = [context response];
|
||||
// [response setHeader: @"text/html" forKey: @"content-type"];
|
||||
// [renderedException setClientObject: exception];
|
||||
// [context setPage: renderedException];
|
||||
// [renderedException appendToResponse: response
|
||||
// inContext: context];
|
||||
// }
|
||||
// [tmpComponent release];
|
||||
// }
|
||||
|
||||
// return rc;
|
||||
// }
|
||||
|
||||
@end /* SOGoWebAuthenticator */
|
||||
Reference in New Issue
Block a user