Fix for bug #

pull/67/head
Ludovic Marcotte 2014-11-26 13:00:47 -05:00
parent 20e728afac
commit 913a75f410
7 changed files with 46 additions and 26 deletions

View File

@ -40,6 +40,7 @@
* cas-ticket:< > value = * cas-ticket:< > value =
* cas-pgtiou:< > value = * cas-pgtiou:< > value =
* session:< > value = * session:< > value =
* saml2-login:< > value =
*/ */

View File

@ -1,8 +1,6 @@
/* SOGoSAML2Session.h - this file is part of SOGo /* SOGoSAML2Session.h - this file is part of SOGo
* *
* Copyright (C) 2012 Inverse inc. * Copyright (C) 2012-2014 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
* This file is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -1,8 +1,6 @@
/* SOGoSAML2Session.m - this file is part of SOGo /* SOGoSAML2Session.m - this file is part of SOGo
* *
* Copyright (C) 2012 Inverse inc. * Copyright (C) 2012-2014 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
* This file is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -215,7 +213,6 @@ LassoServerInContext (WOContext *context)
- (void) _updateDataFromLogin - (void) _updateDataFromLogin
{ {
// LassoSamlp2Response *response;
LassoSaml2Assertion *saml2Assertion; LassoSaml2Assertion *saml2Assertion;
GList *statementList, *attributeList; GList *statementList, *attributeList;
LassoSaml2AttributeStatement *statement; LassoSaml2AttributeStatement *statement;
@ -223,10 +220,15 @@ LassoServerInContext (WOContext *context)
LassoSaml2AttributeValue *value; LassoSaml2AttributeValue *value;
LassoMiscTextNode *textNode; LassoMiscTextNode *textNode;
LassoSaml2NameID *nameIdentifier; LassoSaml2NameID *nameIdentifier;
SOGoSystemDefaults *sd;
NSString *loginAttribue;
gchar *dump; gchar *dump;
saml2Assertion saml2Assertion = LASSO_SAML2_ASSERTION (lasso_login_get_assertion (lassoLogin));
= LASSO_SAML2_ASSERTION (lasso_login_get_assertion (lassoLogin)); sd = [SOGoSystemDefaults sharedSystemDefaults];
loginAttribue = [sd SAML2LoginAttribute];
if (saml2Assertion) if (saml2Assertion)
{ {
/* deduce user login */ /* deduce user login */
@ -241,6 +243,25 @@ LassoServerInContext (WOContext *context)
while (!login && attributeList) while (!login && attributeList)
{ {
attribute = LASSO_SAML2_ATTRIBUTE (attributeList->data); attribute = LASSO_SAML2_ATTRIBUTE (attributeList->data);
if (loginAttribue && (strcmp (attribute->Name, [loginAttribue UTF8String]) == 0))
{
value = LASSO_SAML2_ATTRIBUTE_VALUE (attribute->AttributeValue->data);
textNode = value->any->data;
// If we got an @ sign in the value, it's most likely an email address
// so we'll ask SOGoUserManager about this
login = [NSString stringWithUTF8String: textNode->content];
if ([login rangeOfString: @"@"].location != NSNotFound)
{
login = [[SOGoUserManager sharedUserManager] getUIDForEmail: login];
}
[login retain];
}
else if (!loginAttribue)
{
// We fallback on "standard" attributes such as "uid" and "mail"
if (strcmp (attribute->Name, "uid") == 0) if (strcmp (attribute->Name, "uid") == 0)
{ {
value = LASSO_SAML2_ATTRIBUTE_VALUE (attribute->AttributeValue->data); value = LASSO_SAML2_ATTRIBUTE_VALUE (attribute->AttributeValue->data);
@ -255,7 +276,8 @@ LassoServerInContext (WOContext *context)
login = [[SOGoUserManager sharedUserManager] getUIDForEmail: [NSString stringWithUTF8String: textNode->content]]; login = [[SOGoUserManager sharedUserManager] getUIDForEmail: [NSString stringWithUTF8String: textNode->content]];
[login retain]; [login retain];
} }
else }
attributeList = attributeList->next; attributeList = attributeList->next;
} }
statementList = statementList->next; statementList = statementList->next;

View File

@ -1,9 +1,6 @@
/* SOGoSession.h - this file is part of SOGo /* SOGoSession.h - this file is part of SOGo
* *
* Copyright (C) 2010-2011 Inverse inc. * Copyright (C) 2010-2014 Inverse inc.
*
* Author: Ludovic Marcotte <lmarcotte@inverse.ca>
* Francis Lachapelle <flachapelle@inverse.ca>
* *
* This file is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -1,10 +1,6 @@
/* SOGoSession.m - this file is part of SOGo /* SOGoSession.m - this file is part of SOGo
* *
* Copyright (C) 2010-2011 Inverse inc. * Copyright (C) 2010-2014 Inverse inc.
*
* Author: Ludovic Marcotte <lmarcotte@inverse.ca>
* Francis Lachapelle <flachapelle@inverse.ca>
* *
* This file is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -80,6 +80,7 @@
- (NSString *) SAML2IdpMetadataLocation; - (NSString *) SAML2IdpMetadataLocation;
- (NSString *) SAML2IdpPublicKeyLocation; - (NSString *) SAML2IdpPublicKeyLocation;
- (NSString *) SAML2IdpCertificateLocation; - (NSString *) SAML2IdpCertificateLocation;
- (NSString *) SAML2LoginAttribute;
- (BOOL) SAML2LogoutEnabled; - (BOOL) SAML2LogoutEnabled;
- (BOOL) enablePublicAccess; - (BOOL) enablePublicAccess;

View File

@ -511,6 +511,11 @@ _injectConfigurationFromFile (NSMutableDictionary *defaultsDict,
return [self boolForKey: @"SOGoSAML2LogoutEnabled"]; return [self boolForKey: @"SOGoSAML2LogoutEnabled"];
} }
- (NSString *) SAML2LoginAttribute
{
return [self stringForKey: @"SOGoSAML2LoginAttribute"];
}
- (BOOL) enablePublicAccess - (BOOL) enablePublicAccess
{ {
return [self boolForKey: @"SOGoEnablePublicAccess"]; return [self boolForKey: @"SOGoEnablePublicAccess"];