Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions includes/auth/auth_saml.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function autologin_saml()
if (!saml_instance()->isAuthenticated())
return array();

return saml_user_row(saml_attribute($config['saml_uid']));
return saml_user_row(utf8_htmlspecialchars(saml_attribute($config['saml_mail'])));
}

/** Login through SAML.
Expand Down Expand Up @@ -106,14 +106,17 @@ function login_saml(&$username, &$password)
saml_auth_or_redirect();

if ($saml->isAuthenticated()) {
$username = saml_attribute($config['saml_uid']);
$user_row = saml_user_row($username);
// Use usermail instead of username; username could be changed in phpBB3 ucp, mail should be more unique
$usermail = '';
if (!empty($config['saml_mail']))
$usermail = utf8_htmlspecialchars(saml_attribute($config['saml_mail']));

$user_row = saml_user_row($usermail);

if (empty($user_row)) {
// User unknown... We create his/her profile.
$usermail = '';
if (!empty($config['saml_mail']))
$usermail = utf8_htmlspecialchars(saml_attribute($config['saml_mail']));

$username = saml_attribute($config['saml_uid']));

// retrieve default group id
global $db;
Expand Down Expand Up @@ -263,20 +266,20 @@ function saml_username()
*
* Reads the user row from the database. If none is found, then returns the $default_row.
*
* @param string $username Username.
* @param string $usermail Usermail.
* @param array $default_row The default row in case no user is found.
* @param bool $select_all Whether to retrieve all fields or just a specific subset.
*
* @return array The user row or $default_row if the user does not exists in phpBB.
*/
function saml_user_row($username, $default_row = array(), $select_all = true)
function saml_user_row($usermail, $default_row = array(), $select_all = true)
{
global $db;
$user_row = $default_row;
$sql = 'SELECT';
if ($select_all)
$sql .= ' *';
$sql .= ' FROM ' . USERS_TABLE . " WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
$sql .= ' FROM ' . USERS_TABLE . " WHERE user_email = '" . $usermail . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
Expand Down
50 changes: 50 additions & 0 deletions language/de/mods/info_acp_saml.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/*
Copyright (c) 2012 ANELIS <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* phpBB SAML auth plug-in. English translation.
*
* @package language
* @version $Id$
* @copyright (c) 2012 Anelis
* @author Gregoire Astruc <[email protected]>
* @licence http://opensource.org/licenses/MIT MIT Licence
*/

if (empty($lang) || !is_array($lang))
{
$lang = array();
}

$lang = array_merge($lang, array(
'SAML_NOT_IMPLEMENTED' => 'SAML wurde noch nicht implementiert.',
'SAML_PATH' => 'SimpleSAMLphp Pfad',
'SAML_PATH_EXPLAIN' => 'Absoluter oder Relativer Pfad zu der simpleSAMLphp Installation.',
'SAML_SP' => 'Genutzter SP.',
'SAML_SP_EXPLAIN' => 'SAML Service Provider, den das Board nutzt.',
'SAML_UID' => 'SAML Benutzernamen Attribut.',
'SAML_UID_EXPLAIN' => 'Gibt Benutzernamen an. Bsp: uid, sn, cn, username, eduPerson...',
'SAML_MAIL' => 'SAML EMail Attribut.',
'SAML_MAIL_EXPLAIN' => 'Setzt die EMail-Adresse des Nutzers bei der ersten Anmeldung.',

'SAML_NOT_DIRECTORY' => 'Der angegebene Pfad ist kein g�ltiges Verzeichnis.',
'SAML_CANNOT_INCLUDE' => 'Kann simpleSAMLphp Installation nicht finden. Ist der Pfad korrekt angegeben?',
'SAML_INVALID_SP' => 'Der Name des SP ist ung�ltig.',
));
?>