2007-09-04 17:39:51 +02:00
|
|
|
/* SOGoWebAuthenticator.m - this file is part of SOGo
|
|
|
|
*
|
2014-11-27 17:37:08 +01:00
|
|
|
* Copyright (C) 2007-2014 Inverse inc.
|
2007-09-04 17:39:51 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2007-09-05 19:57:17 +02:00
|
|
|
#import <NGObjWeb/SoDefaultRenderer.h>
|
2007-09-04 17:39:51 +02:00
|
|
|
#import <NGObjWeb/WOApplication.h>
|
2007-09-07 00:17:56 +02:00
|
|
|
#import <NGObjWeb/WOCookie.h>
|
2007-09-04 17:39:51 +02:00
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
#import <NGObjWeb/WOResponse.h>
|
2012-11-02 20:31:49 +01:00
|
|
|
#import <NGExtensions/NGBase64Coding.h>
|
2007-09-07 00:17:56 +02:00
|
|
|
#import <NGExtensions/NSCalendarDate+misc.h>
|
2012-11-06 16:46:40 +01:00
|
|
|
#import <NGExtensions/NSData+gzip.h>
|
2008-07-24 20:00:21 +02:00
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2010-12-28 18:42:50 +01:00
|
|
|
#import <NGExtensions/NSNull+misc.h>
|
2012-11-06 16:46:40 +01:00
|
|
|
#import <NGExtensions/NSString+Ext.h>
|
2007-09-04 17:39:51 +02:00
|
|
|
|
2010-01-27 16:48:13 +01:00
|
|
|
#import <MainUI/SOGoRootPage.h>
|
2007-09-04 17:39:51 +02:00
|
|
|
|
2010-12-28 18:42:50 +01:00
|
|
|
#import "SOGoCache.h"
|
2010-01-28 22:42:03 +01:00
|
|
|
#import "SOGoCASSession.h"
|
2007-09-04 17:39:51 +02:00
|
|
|
#import "SOGoPermissions.h"
|
2010-12-28 18:42:50 +01:00
|
|
|
#import "SOGoSession.h"
|
2010-01-28 22:42:03 +01:00
|
|
|
#import "SOGoSystemDefaults.h"
|
2007-09-04 17:39:51 +02:00
|
|
|
#import "SOGoUser.h"
|
2010-01-28 22:42:03 +01:00
|
|
|
#import "SOGoUserManager.h"
|
2012-11-02 20:31:49 +01:00
|
|
|
#if defined(SAML2_CONFIG)
|
|
|
|
#import "SOGoSAML2Session.h"
|
|
|
|
#endif
|
2007-09-04 17:39:51 +02:00
|
|
|
#import "SOGoWebAuthenticator.h"
|
|
|
|
|
2013-02-04 19:55:53 +01:00
|
|
|
#define COOKIE_SESSIONKEY_LEN 16
|
|
|
|
/* the key b64 encoded key XORed with the cookie value
|
|
|
|
* must fit in the database field which is 255 char long at the moment
|
|
|
|
*/
|
|
|
|
#define COOKIE_USERKEY_LEN 160
|
|
|
|
|
2007-09-04 17:39:51 +02:00
|
|
|
@implementation SOGoWebAuthenticator
|
|
|
|
|
|
|
|
+ (id) sharedSOGoWebAuthenticator
|
|
|
|
{
|
|
|
|
static SOGoWebAuthenticator *auth = nil;
|
|
|
|
|
|
|
|
if (!auth)
|
|
|
|
auth = [self new];
|
|
|
|
|
|
|
|
return auth;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) checkLogin: (NSString *) _login
|
2013-06-12 08:36:50 +02:00
|
|
|
password: (NSString *) _pwd
|
2010-12-28 18:42:50 +01:00
|
|
|
{
|
2011-07-16 00:22:11 +02:00
|
|
|
NSString *username, *password, *domain, *value;
|
2010-03-08 16:18:05 +01:00
|
|
|
SOGoPasswordPolicyError perr;
|
|
|
|
int expire, grace;
|
2010-12-28 18:42:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
// We check for the existence of the session in the database/memcache
|
|
|
|
// and we extract the real password from it. Here,
|
|
|
|
//
|
|
|
|
// _login == userKey
|
|
|
|
// _pwd == sessionKey
|
|
|
|
//
|
|
|
|
// If the session isn't present in the database, we fail the login process.
|
|
|
|
//
|
|
|
|
value = [SOGoSession valueForSessionKey: _pwd];
|
2010-03-08 16:18:05 +01:00
|
|
|
|
2010-12-28 18:42:50 +01:00
|
|
|
if (!value)
|
|
|
|
return NO;
|
|
|
|
|
2011-07-16 00:22:11 +02:00
|
|
|
domain = nil;
|
2010-12-28 18:42:50 +01:00
|
|
|
[SOGoSession decodeValue: value
|
2011-06-24 21:19:50 +02:00
|
|
|
usingKey: _login
|
|
|
|
login: &username
|
|
|
|
domain: &domain
|
|
|
|
password: &password];
|
2010-12-28 18:42:50 +01:00
|
|
|
|
|
|
|
return [self checkLogin: username
|
2011-06-24 21:19:50 +02:00
|
|
|
password: password
|
2011-07-16 00:22:11 +02:00
|
|
|
domain: &domain
|
2011-06-24 21:19:50 +02:00
|
|
|
perr: &perr
|
|
|
|
expire: &expire
|
|
|
|
grace: &grace];
|
2010-03-08 16:18:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) checkLogin: (NSString *) _login
|
2013-02-02 00:35:10 +01:00
|
|
|
password: (NSString *) _pwd
|
|
|
|
domain: (NSString **) _domain
|
|
|
|
perr: (SOGoPasswordPolicyError *) _perr
|
|
|
|
expire: (int *) _expire
|
|
|
|
grace: (int *) _grace
|
|
|
|
{
|
|
|
|
return [self checkLogin: _login
|
|
|
|
password: _pwd
|
|
|
|
domain: _domain
|
|
|
|
perr: _perr
|
|
|
|
expire: _expire
|
|
|
|
grace: _grace
|
|
|
|
useCache: YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) checkLogin: (NSString *) _login
|
|
|
|
password: (NSString *) _pwd
|
2011-07-16 00:22:11 +02:00
|
|
|
domain: (NSString **) _domain
|
2013-02-02 00:35:10 +01:00
|
|
|
perr: (SOGoPasswordPolicyError *) _perr
|
|
|
|
expire: (int *) _expire
|
|
|
|
grace: (int *) _grace
|
|
|
|
useCache: (BOOL) _useCache
|
2010-03-08 16:18:05 +01:00
|
|
|
{
|
|
|
|
SOGoCASSession *session;
|
2010-01-28 22:42:03 +01:00
|
|
|
SOGoSystemDefaults *sd;
|
2012-11-02 20:31:49 +01:00
|
|
|
NSString *authenticationType;
|
2010-01-28 22:42:03 +01:00
|
|
|
BOOL rc;
|
|
|
|
|
|
|
|
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
2010-03-08 16:18:05 +01:00
|
|
|
|
2012-11-02 20:31:49 +01:00
|
|
|
authenticationType = [sd authenticationType];
|
|
|
|
if ([authenticationType isEqualToString: @"cas"])
|
2010-01-28 22:42:03 +01:00
|
|
|
{
|
2010-06-10 23:29:55 +02:00
|
|
|
session = [SOGoCASSession CASSessionWithIdentifier: _pwd fromProxy: NO];
|
2010-01-28 22:42:03 +01:00
|
|
|
if (session)
|
|
|
|
rc = [[session login] isEqualToString: _login];
|
|
|
|
else
|
|
|
|
rc = NO;
|
|
|
|
}
|
2012-11-02 20:31:49 +01:00
|
|
|
#if defined(SAML2_CONFIG)
|
|
|
|
else if ([authenticationType isEqualToString: @"saml2"])
|
|
|
|
{
|
|
|
|
SOGoSAML2Session *saml2Session;
|
|
|
|
WOContext *context;
|
|
|
|
|
|
|
|
context = [[WOApplication application] context];
|
|
|
|
saml2Session = [SOGoSAML2Session SAML2SessionWithIdentifier: _pwd
|
|
|
|
inContext: context];
|
|
|
|
rc = [[saml2Session login] isEqualToString: _login];
|
|
|
|
}
|
|
|
|
#endif /* SAML2_CONFIG */
|
2010-01-28 22:42:03 +01:00
|
|
|
else
|
|
|
|
rc = [[SOGoUserManager sharedUserManager] checkLogin: _login
|
2011-06-24 21:19:50 +02:00
|
|
|
password: _pwd
|
|
|
|
domain: _domain
|
|
|
|
perr: _perr
|
|
|
|
expire: _expire
|
2013-02-02 00:35:10 +01:00
|
|
|
grace: _grace
|
2013-06-12 08:36:50 +02:00
|
|
|
useCache: _useCache];
|
2010-03-08 16:18:05 +01:00
|
|
|
|
2010-12-28 18:42:50 +01:00
|
|
|
//[self logWithFormat: @"Checked login with ppolicy enabled: %d %d %d", *_perr, *_expire, *_grace];
|
2010-03-08 16:18:05 +01:00
|
|
|
|
|
|
|
// It's important to return the real value here. The callee will handle
|
|
|
|
// the return code and check for the _perr value.
|
2010-01-28 22:42:03 +01:00
|
|
|
return rc;
|
2007-09-04 17:39:51 +02:00
|
|
|
}
|
|
|
|
|
2010-12-28 18:42:50 +01:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
2007-10-19 00:48:34 +02:00
|
|
|
- (SOGoUser *) userInContext: (WOContext *)_ctx
|
|
|
|
{
|
|
|
|
static SOGoUser *anonymous = nil;
|
|
|
|
SOGoUser *user;
|
|
|
|
|
|
|
|
user = (SOGoUser *) [super userInContext: _ctx];
|
2010-06-02 18:35:59 +02:00
|
|
|
if (!user || [[user login] isEqualToString: @"anonymous"])
|
2010-01-27 16:48:13 +01:00
|
|
|
{
|
|
|
|
if (!anonymous)
|
|
|
|
anonymous = [[SOGoUser alloc]
|
|
|
|
initWithLogin: @"anonymous"
|
|
|
|
roles: [NSArray arrayWithObject: SoRole_Anonymous]];
|
|
|
|
user = anonymous;
|
|
|
|
}
|
2007-10-19 00:48:34 +02:00
|
|
|
|
|
|
|
return user;
|
|
|
|
}
|
|
|
|
|
2007-09-04 17:39:51 +02:00
|
|
|
- (NSString *) passwordInContext: (WOContext *) context
|
|
|
|
{
|
|
|
|
NSString *auth, *password;
|
2010-12-28 18:42:50 +01:00
|
|
|
NSArray *creds;
|
2010-01-28 22:42:03 +01:00
|
|
|
|
2010-01-27 16:48:13 +01:00
|
|
|
auth = [[context request]
|
|
|
|
cookieValueForKey: [self cookieNameInContext: context]];
|
2007-09-04 17:39:51 +02:00
|
|
|
creds = [self parseCredentials: auth];
|
|
|
|
if ([creds count] > 1)
|
2010-12-28 18:42:50 +01:00
|
|
|
{
|
2011-06-24 21:19:50 +02:00
|
|
|
NSString *login, *domain;
|
2010-12-28 18:42:50 +01:00
|
|
|
|
|
|
|
[SOGoSession decodeValue: [SOGoSession valueForSessionKey: [creds objectAtIndex: 1]]
|
2011-06-24 21:19:50 +02:00
|
|
|
usingKey: [creds objectAtIndex: 0]
|
|
|
|
login: &login
|
|
|
|
domain: &domain
|
|
|
|
password: &password];
|
2010-12-28 18:42:50 +01:00
|
|
|
}
|
2007-09-04 17:39:51 +02:00
|
|
|
else
|
|
|
|
password = nil;
|
|
|
|
|
|
|
|
return password;
|
|
|
|
}
|
|
|
|
|
2010-12-28 18:42:50 +01:00
|
|
|
//
|
|
|
|
// We overwrite SOPE's method in order to proper retrieve
|
|
|
|
// the username from the cookie.
|
|
|
|
//
|
|
|
|
- (NSString *) checkCredentials: (NSString *)_creds
|
|
|
|
{
|
2011-06-24 21:19:50 +02:00
|
|
|
NSString *login, *domain, *pwd, *userKey, *sessionKey;
|
2010-12-28 18:42:50 +01:00
|
|
|
NSArray *creds;
|
|
|
|
|
|
|
|
SOGoPasswordPolicyError perr;
|
|
|
|
int expire, grace;
|
|
|
|
|
|
|
|
if (![(creds = [self parseCredentials:_creds]) isNotEmpty])
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
userKey = [creds objectAtIndex:0];
|
|
|
|
if ([userKey isEqualToString:@"anonymous"])
|
|
|
|
return @"anonymous";
|
|
|
|
|
|
|
|
sessionKey = [creds objectAtIndex:1];
|
|
|
|
|
|
|
|
[SOGoSession decodeValue: [SOGoSession valueForSessionKey: sessionKey]
|
2011-06-24 21:19:50 +02:00
|
|
|
usingKey: userKey
|
|
|
|
login: &login
|
|
|
|
domain: &domain
|
|
|
|
password: &pwd];
|
2010-12-28 18:42:50 +01:00
|
|
|
|
|
|
|
if (![self checkLogin: login
|
2011-06-24 21:19:50 +02:00
|
|
|
password: pwd
|
2011-07-16 00:22:11 +02:00
|
|
|
domain: &domain
|
2011-06-24 21:19:50 +02:00
|
|
|
perr: &perr
|
|
|
|
expire: &expire
|
|
|
|
grace: &grace])
|
2010-12-28 18:42:50 +01:00
|
|
|
return nil;
|
|
|
|
|
2013-04-09 17:35:53 +02:00
|
|
|
if (domain && [login rangeOfString: @"@"].location == NSNotFound)
|
2011-06-24 21:19:50 +02:00
|
|
|
login = [NSString stringWithFormat: @"%@@%@", login, domain];
|
|
|
|
|
2010-12-28 18:42:50 +01:00
|
|
|
return login;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-28 22:42:03 +01:00
|
|
|
- (NSString *) imapPasswordInContext: (WOContext *) context
|
2011-02-17 21:55:19 +01:00
|
|
|
forURL: (NSURL *) server
|
2010-01-28 22:42:03 +01:00
|
|
|
forceRenew: (BOOL) renew
|
|
|
|
{
|
2012-11-06 16:46:40 +01:00
|
|
|
NSString *authType, *password;
|
2013-06-18 22:36:11 +02:00
|
|
|
SOGoSystemDefaults *sd;
|
2011-02-17 21:55:19 +01:00
|
|
|
|
2010-01-28 22:42:03 +01:00
|
|
|
password = [self passwordInContext: context];
|
|
|
|
if ([password length])
|
|
|
|
{
|
2013-06-18 22:36:11 +02:00
|
|
|
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
|
|
|
authType = [sd authenticationType];
|
2012-11-06 16:46:40 +01:00
|
|
|
if ([authType isEqualToString: @"cas"])
|
2010-01-28 22:42:03 +01:00
|
|
|
{
|
2012-11-06 16:46:40 +01:00
|
|
|
SOGoCASSession *session;
|
2013-06-19 01:33:36 +02:00
|
|
|
SOGoUser *user;
|
2012-11-06 16:46:40 +01:00
|
|
|
NSString *service, *scheme;
|
|
|
|
|
2010-06-10 23:29:55 +02:00
|
|
|
session = [SOGoCASSession CASSessionWithIdentifier: password
|
|
|
|
fromProxy: NO];
|
2011-02-17 21:55:19 +01:00
|
|
|
|
2013-06-19 01:33:36 +02:00
|
|
|
user = [self userInContext: context];
|
|
|
|
// Try configured CAS service name first
|
|
|
|
service = [[user domainDefaults] imapCASServiceName];
|
2013-06-18 22:36:11 +02:00
|
|
|
if (!service)
|
|
|
|
{
|
|
|
|
// We must NOT assume the scheme exists
|
|
|
|
scheme = [server scheme];
|
2011-02-17 21:55:19 +01:00
|
|
|
|
2013-06-18 22:36:11 +02:00
|
|
|
if (!scheme)
|
|
|
|
scheme = @"imap";
|
2011-02-17 21:55:19 +01:00
|
|
|
|
2013-06-18 22:36:11 +02:00
|
|
|
service = [NSString stringWithFormat: @"%@://%@",
|
|
|
|
scheme, [server host]];
|
|
|
|
}
|
2011-02-17 21:55:19 +01:00
|
|
|
|
2010-01-28 22:42:03 +01:00
|
|
|
if (renew)
|
|
|
|
[session invalidateTicketForService: service];
|
2013-06-12 08:36:50 +02:00
|
|
|
|
2010-01-28 22:42:03 +01:00
|
|
|
password = [session ticketForService: service];
|
2013-06-12 08:36:50 +02:00
|
|
|
|
2010-01-28 22:42:03 +01:00
|
|
|
if ([password length] || renew)
|
|
|
|
[session updateCache];
|
|
|
|
}
|
2012-11-06 16:46:40 +01:00
|
|
|
#if defined(SAML2_CONFIG)
|
|
|
|
else if ([authType isEqualToString: @"saml2"])
|
|
|
|
{
|
|
|
|
SOGoSAML2Session *session;
|
|
|
|
WOContext *context;
|
|
|
|
NSData *assertion;
|
|
|
|
|
|
|
|
context = [[WOApplication application] context];
|
|
|
|
session = [SOGoSAML2Session SAML2SessionWithIdentifier: password
|
|
|
|
inContext: context];
|
|
|
|
assertion = [[session assertion]
|
|
|
|
dataUsingEncoding: NSUTF8StringEncoding];
|
2012-11-06 19:50:26 +01:00
|
|
|
password = [[[assertion compress] stringByEncodingBase64]
|
|
|
|
stringByReplacingString: @"\n"
|
|
|
|
withString: @""];
|
2012-11-06 16:46:40 +01:00
|
|
|
}
|
|
|
|
#endif
|
2010-01-28 22:42:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return password;
|
|
|
|
}
|
|
|
|
|
2007-09-04 17:39:51 +02:00
|
|
|
/* create SOGoUser */
|
|
|
|
|
|
|
|
- (SOGoUser *) userWithLogin: (NSString *) login
|
2013-06-12 08:36:50 +02:00
|
|
|
andRoles: (NSArray *) roles
|
|
|
|
inContext: (WOContext *) ctx
|
2007-09-04 17:39:51 +02:00
|
|
|
{
|
|
|
|
/* the actual factory method */
|
|
|
|
return [SOGoUser userWithLogin: login roles: roles];
|
|
|
|
}
|
|
|
|
|
2010-12-28 18:42:50 +01:00
|
|
|
//
|
|
|
|
// This is called by SoObjectRequestHandler prior doing any significant
|
|
|
|
// processing to allow the authenticator to reject invalid requests.
|
|
|
|
//
|
2007-09-07 00:17:56 +02:00
|
|
|
- (WOResponse *) preprocessCredentialsInContext: (WOContext *) context
|
|
|
|
{
|
|
|
|
WOResponse *response;
|
|
|
|
NSString *auth;
|
2010-01-28 22:42:03 +01:00
|
|
|
|
2007-09-07 00:17:56 +02:00
|
|
|
auth = [[context request]
|
2013-06-12 08:36:50 +02:00
|
|
|
cookieValueForKey: [self cookieNameInContext:context]];
|
2007-09-07 00:17:56 +02:00
|
|
|
if ([auth isEqualToString: @"discard"])
|
|
|
|
{
|
|
|
|
[context setObject: [NSArray arrayWithObject: SoRole_Anonymous]
|
2010-01-27 16:48:13 +01:00
|
|
|
forKey: @"SoAuthenticatedRoles"];
|
2007-09-07 00:17:56 +02:00
|
|
|
response = nil;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
response = [super preprocessCredentialsInContext: context];
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2007-09-04 17:39:51 +02:00
|
|
|
- (void) setupAuthFailResponse: (WOResponse *) response
|
2013-06-12 08:36:50 +02:00
|
|
|
withReason: (NSString *) reason
|
|
|
|
inContext: (WOContext *) context
|
2007-09-04 17:39:51 +02:00
|
|
|
{
|
2007-09-05 19:57:17 +02:00
|
|
|
WOComponent *page;
|
2010-01-28 22:42:03 +01:00
|
|
|
WORequest *request;
|
2007-09-07 00:17:56 +02:00
|
|
|
WOCookie *authCookie;
|
|
|
|
NSCalendarDate *date;
|
2010-01-28 22:42:03 +01:00
|
|
|
NSString *appName;
|
2007-09-04 17:39:51 +02:00
|
|
|
|
2010-01-28 22:42:03 +01:00
|
|
|
request = [context request];
|
2007-09-04 17:39:51 +02:00
|
|
|
page = [[WOApplication application] pageWithName: @"SOGoRootPage"
|
2010-01-28 22:42:03 +01:00
|
|
|
forRequest: request];
|
|
|
|
[[SoDefaultRenderer sharedRenderer] renderObject: [page defaultAction]
|
2010-01-27 16:48:13 +01:00
|
|
|
inContext: context];
|
2007-09-07 00:17:56 +02:00
|
|
|
authCookie = [WOCookie cookieWithName: [self cookieNameInContext: context]
|
2010-01-27 16:48:13 +01:00
|
|
|
value: @"discard"];
|
2010-01-28 22:42:03 +01:00
|
|
|
appName = [request applicationName];
|
|
|
|
[authCookie setPath: [NSString stringWithFormat: @"/%@/", appName]];
|
2007-09-07 00:17:56 +02:00
|
|
|
date = [NSCalendarDate calendarDate];
|
|
|
|
[authCookie setExpires: [date yesterday]];
|
|
|
|
[response addCookie: authCookie];
|
2007-09-04 17:39:51 +02:00
|
|
|
}
|
|
|
|
|
2012-11-02 20:31:49 +01:00
|
|
|
- (WOCookie *) cookieWithUsername: (NSString *) username
|
|
|
|
andPassword: (NSString *) password
|
|
|
|
inContext: (WOContext *) context
|
|
|
|
{
|
|
|
|
WOCookie *authCookie;
|
|
|
|
NSString *cookieValue, *cookieString, *appName, *sessionKey, *userKey, *securedPassword;
|
|
|
|
|
|
|
|
//
|
|
|
|
// We create a new cookie - thus we create a new session
|
|
|
|
// associated to the user. For security, we generate:
|
|
|
|
//
|
|
|
|
// A- a session key
|
|
|
|
// B- a user key
|
|
|
|
//
|
|
|
|
// In memcached, the session key will be associated to the user's password
|
|
|
|
// which will be XOR'ed with the user key.
|
|
|
|
//
|
2013-02-04 19:55:53 +01:00
|
|
|
sessionKey = [SOGoSession generateKeyForLength: COOKIE_SESSIONKEY_LEN];
|
|
|
|
userKey = [SOGoSession generateKeyForLength: COOKIE_USERKEY_LEN];
|
2012-11-02 20:31:49 +01:00
|
|
|
|
|
|
|
NSString *value = [NSString stringWithFormat: @"%@:%@", username, password];
|
|
|
|
securedPassword = [SOGoSession securedValue: value usingKey: userKey];
|
|
|
|
|
|
|
|
|
|
|
|
[SOGoSession setValue: securedPassword forSessionKey: sessionKey];
|
|
|
|
|
|
|
|
//cookieString = [NSString stringWithFormat: @"%@:%@",
|
|
|
|
// username, password];
|
|
|
|
cookieString = [NSString stringWithFormat: @"%@:%@",
|
|
|
|
userKey, sessionKey];
|
|
|
|
cookieValue = [NSString stringWithFormat: @"basic %@",
|
|
|
|
[cookieString stringByEncodingBase64]];
|
|
|
|
authCookie = [WOCookie cookieWithName: [self cookieNameInContext: context]
|
|
|
|
value: cookieValue];
|
|
|
|
appName = [[context request] applicationName];
|
|
|
|
[authCookie setPath: [NSString stringWithFormat: @"/%@/", appName]];
|
|
|
|
|
|
|
|
return authCookie;
|
|
|
|
}
|
|
|
|
|
2007-09-04 17:39:51 +02:00
|
|
|
@end /* SOGoWebAuthenticator */
|