Blame view
sources/apps/user_saml/appinfo/app.php
2.24 KB
|
42e4f8d60
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
<?php
/**
* ownCloud - user_saml
*
* @author Sixto Martin <smartin@yaco.es>
* @copyright 2012 Yaco Sistemas // CONFIA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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 AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
if (OCP\App::isEnabled('user_saml')) {
$ocVersion = implode('.',OCP\Util::getVersion());
if (version_compare($ocVersion,'5.0','<')) {
if ( ! function_exists('p')) {
function p($string) {
print(OC_Util::sanitizeHTML($string));
}
}
}
require_once 'user_saml/user_saml.php';
OCP\App::registerAdmin('user_saml', 'settings');
// register user backend
OC_User::useBackend( 'SAML' );
OC::$CLASSPATH['OC_USER_SAML_Hooks'] = 'user_saml/lib/hooks.php';
OCP\Util::connectHook('OC_User', 'post_login', 'OC_USER_SAML_Hooks', 'post_login');
OCP\Util::connectHook('OC_User', 'logout', 'OC_USER_SAML_Hooks', 'logout');
$forceLogin = OCP\Config::getAppValue('user_saml', 'saml_force_saml_login', false);
if( (isset($_GET['app']) && $_GET['app'] == 'user_saml') || (!OCP\User::isLoggedIn() && $forceLogin && !isset($_GET['admin_login']) )) {
require_once 'user_saml/auth.php';
if (!OC_User::login('', '')) {
$error = true;
OC_Log::write('saml','Error trying to authenticate the user', OC_Log::DEBUG);
}
if (isset($_GET["linktoapp"])) {
$path = OC::$WEBROOT . '/?app='.$_GET["linktoapp"];
if (isset($_GET["linktoargs"])) {
$path .= '&'.urldecode($_GET["linktoargs"]);
}
header( 'Location: ' . $path);
exit();
}
OC::$REQUESTEDAPP = '';
OC_Util::redirectToDefaultPage();
}
if (!OCP\User::isLoggedIn()) {
// Load js code in order to render the SAML link and to hide parts of the normal login form
OCP\Util::addScript('user_saml', 'utils');
}
}
|