Esempio n. 1
0
/**
 * Check if login should be enforced using user_cas
 */
function shouldEnforceAuthentication()
{
    if (OC::$CLI) {
        return false;
    }
    if (OCP\Config::getAppValue('user_cas', 'cas_force_login', false) !== 'on') {
        return false;
    }
    if (OCP\User::isLoggedIn() || isset($_GET['admin_login'])) {
        return false;
    }
    $script = basename($_SERVER['SCRIPT_FILENAME']);
    return !in_array($script, array('cron.php', 'public.php', 'remote.php', 'status.php'));
}
Esempio n. 2
0
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
if (OCP\App::isEnabled('user_cas')) {
    include_once 'CAS.php';
    require_once 'user_cas/user_cas.php';
    OCP\App::registerAdmin('user_cas', 'settings');
    // register user backend
    OC_User::useBackend('CAS');
    OC::$CLASSPATH['OC_USER_CAS_Hooks'] = 'user_cas/lib/hooks.php';
    OCP\Util::connectHook('OC_User', 'post_createUser', 'OC_USER_CAS_Hooks', 'post_createUser');
    OCP\Util::connectHook('OC_User', 'post_login', 'OC_USER_CAS_Hooks', 'post_login');
    OCP\Util::connectHook('OC_User', 'logout', 'OC_USER_CAS_Hooks', 'logout');
    if (isset($_GET['app']) && $_GET['app'] == 'user_cas') {
        require_once 'user_cas/auth.php';
        if (!OC_User::login('', '')) {
            $error = true;
            OC_Log::write('cas', 'Error trying to authenticate the user', OC_Log::DEBUG);
        }
        if (isset($_SERVER["QUERY_STRING"]) && !empty($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != 'app=user_cas') {
            header('Location: ' . OC::$WEBROOT . '/?' . $_SERVER["QUERY_STRING"]);
            exit;
        }
        OC::$REQUESTEDAPP = '';
        OC_Util::redirectToDefaultPage();
    }
    if (!OCP\User::isLoggedIn()) {
        // Load js code in order to render the CAS link and to hide parts of the normal login form
        OCP\Util::addScript('user_cas', 'utils');
    }
}
Esempio n. 3
0
<?php

OCP\App::checkAppEnabled('user_openid_provider');
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/3rdparty');
require_once 'Zend/OpenId/Provider.php';
if (!isset($_REQUEST['openid_mode'])) {
    OC_Template::printGuestPage('user_openid_provider', 'main');
    die;
}
$session = new OC_OpenIdProviderUserSession();
$storage = new OC_OpenIdProviderStorage();
$server = new Zend_OpenId_Provider(null, null, $session, $storage);
if (OCP\User::isLoggedIn() and !$session->getLoggedInUser()) {
    $session->setLoggedInUser(OCP\Util::linkToAbsolute('', '?') . OCP\User::getUser());
}
if (isset($_GET['openid_action']) and $_GET['openid_action'] == 'login') {
    unset($_GET['openid_action']);
    $params = '?' . Zend_OpenId::paramsToQuery($_GET);
    $next = OCP\Util::linkToRemote('openid_provider') . $params;
    $loginPage = OCP\Util::linkToAbsolute('', 'index.php') . '?redirect_url=' . urlencode($next);
    header('Location: ' . $loginPage);
} else {
    if (isset($_GET['openid_action']) and $_GET['openid_action'] == 'trust') {
        OCP\User::checkLoggedIn();
        if (isset($_POST['allow'])) {
            if (isset($_POST['forever'])) {
                $server->allowSite($server->getSiteRoot($_GET));
            }
            $server->respondToConsumer($_GET);
        } else {
            if (isset($_POST['deny'])) {
Esempio n. 4
0
            $path = OC::$WEBROOT . '/?app=' . $_GET["linktoapp"];
            if (isset($_GET["linktoargs"])) {
                $path .= '&' . urldecode($_GET["linktoargs"]);
            }
            header('Location: ' . $path);
            exit;
        }
        OC::$REQUESTEDAPP = '';
        OC_Util::redirectToDefaultPage();
    }
    // We load the login prompt only if we're stand-alone or on the sharding master
    if (!OCP\User::isLoggedIn() && (!OCP\App::isEnabled('files_sharding') || \OCA\FilesSharding\Lib::isMaster())) {
        // 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');
    }
    if (OCP\App::isEnabled('files_sharding') && OCP\User::isLoggedIn() && strlen($_SERVER['REQUEST_URI']) > 1 && strpos($_SERVER['REQUEST_URI'], '/index.php/settings') === FALSE && strpos($_SERVER['REQUEST_URI'], 'logout') === FALSE && strpos($_SERVER['REQUEST_URI'], '/ajax/') === FALSE && strpos($_SERVER['REQUEST_URI'], '/jqueryFileTree.php') === FALSE && strpos($_SERVER['REQUEST_URI'], '/ws/') === FALSE) {
        $userid = \OCP\User::getUser();
        $redirect = OCA\FilesSharding\Lib::getServerForUser($userid);
        if (!empty($redirect)) {
            $parsedRedirect = parse_url($redirect);
            if ($_SERVER['HTTP_HOST'] !== $parsedRedirect['host']) {
                $redirect_full = preg_replace("/(\\?*)app=user_saml(\\&*)/", "\$1", $redirect . $_SERVER['REQUEST_URI']);
                OC_USER_SAML_Hooks::setRedirectCookie();
                OC_Log::write('user_saml', 'Redirecting to ' . $redirect_full, OC_Log::WARN);
                header("HTTP/1.1 301 Moved Permanently");
                header('Location: ' . $redirect_full);
                exit;
            }
        }
    }
}
Esempio n. 5
0
<?php

function validateBoolean($val)
{
    return $val === true || $val === 'true';
}
OCP\JSON::callCheck();
$username = $_POST['username'];
$password = $_POST['password'];
$ocUser = new OCP\User();
$auth = $password !== null ? $ocUser->checkPassword($username, $password) : OCP\User::isLoggedIn();
if (!$auth) {
    OCP\JSON::encodedPrint(array('result' => 'noauth'));
    exit;
}
$data = array();
$data['xmpp'] = array();
$data['xmpp']['url'] = OCP\Config::getAppValue('ojsxc', 'boshUrl');
$data['xmpp']['domain'] = OCP\Config::getAppValue('ojsxc', 'xmppDomain');
$data['xmpp']['resource'] = OCP\Config::getAppValue('ojsxc', 'xmppResource');
$data['xmpp']['overwrite'] = validateBoolean(OCP\Config::getAppValue('ojsxc', 'xmppOverwrite'));
$data['xmpp']['onlogin'] = true;
$options = OCP\Config::getUserValue($username, 'ojsxc', 'options');
if ($options !== null) {
    $options = json_decode($options, true);
    foreach ($options as $prop => $value) {
        if ($prop !== 'xmpp' || $data['xmpp']['overwrite']) {
            foreach ($value as $key => $v) {
                if ($v !== "") {
                    $data[$prop][$key] = $v === 'false' || $v === 'true' ? validateBoolean($v) : $v;
                }
Esempio n. 6
0
<?php

OC::$CLASSPATH['OC_Crypt'] = 'apps/files_encryption/lib/crypt.php';
OC::$CLASSPATH['OC_CryptStream'] = 'apps/files_encryption/lib/cryptstream.php';
OC::$CLASSPATH['OC_FileProxy_Encryption'] = 'apps/files_encryption/lib/proxy.php';
OC_FileProxy::register(new OC_FileProxy_Encryption());
OCP\Util::connectHook('OC_User', 'post_login', 'OC_Crypt', 'loginListener');
stream_wrapper_register('crypt', 'OC_CryptStream');
if (!isset($_SESSION['enckey']) and OCP\User::isLoggedIn()) {
    //force the user to re-loggin if the encryption key isn't unlocked (happens when a user is logged in before the encryption app is enabled)
    OCP\User::logout();
    header("Location: " . OC::$WEBROOT . '/');
    exit;
}
OCP\App::registerAdmin('files_encryption', 'settings');
Esempio n. 7
0
    ?>
			<link rel="stylesheet" href="<?php 
    p(OCP\Util::linkTo('imprint', 'css/imprint-oc4.css'));
    ?>
" type="text/css" media="screen" />
		<?php 
}
?>
	</head>
	<body id="imprint-content">
		<div class="imprint-factoid">    <?php 
p($l->t("Nothing here yet") . "!");
?>
</div>
		<div class="imprint-suggestion"> <?php 
p($l->t("The content of the legal notice has to be configured first") . ".");
?>
</div>
		<div class="imprint-explanation">
			<?php 
if (OCP\User::isLoggedIn() && (method_exists('OC_User', 'isAdminUser') && OC_User::isAdminUser(OCP\User::getUser()) || OC_Group::inGroup(OCP\User::getUser(), 'admin'))) {
    p($l->t("That configuration is done in the administration section."));
} else {
    p($l->t("That configuration has to be done by the system administration."));
}
?>
			</a>
		</div>
	</body>
</html>
Esempio n. 8
0
 public static function changekeypasscode($oldPassword, $newPassword)
 {
     if (OCP\User::isLoggedIn()) {
         $username = OCP\USER::getUser();
         $view = new OC_FilesystemView('/' . $username);
         // read old key
         $key = $view->file_get_contents('/encryption.key');
         // decrypt key with old passcode
         $key = OC_Crypt::decrypt($key, $oldPassword);
         // encrypt again with new passcode
         $key = OC_Crypt::encrypt($key, $newPassword);
         // store the new key
         $view->file_put_contents('/encryption.key', $key);
     }
 }
Esempio n. 9
0
 /**
  * @brief add/remove a notification class to/from the blacklist
  * @param string $uid user
  * @param int $class class id
  * @param boolean $block true to add, false to remove from blacklist
  */
 public static function setBlacklist($uid = null, $class, $block)
 {
     if (is_null($uid)) {
         if (OCP\User::isLoggedIn()) {
             $uid = OCP\User::getUser();
         } else {
             throw new Exception('Not logged in!');
         }
     }
     $stmt = null;
     if ($block) {
         if (!isset(self::$addToBlacklistStmt)) {
             self::$addToBlacklistStmt = OCP\DB::prepare("INSERT INTO *PREFIX*notification_blacklist (uid, class) VALUES (?, ?)");
         }
         $stmt = self::$addToBlacklistStmt;
     } else {
         if (!isset(self::$removeFromBlacklistStmt)) {
             self::$removeFromBlacklistStmt = OCP\DB::prepare("DELETE FROM *PREFIX*notification_blacklist WHERE uid = ? AND class = ?");
         }
         $stmt = self::$removeFromBlacklistStmt;
     }
     $stmt->execute(array($uid, $class));
 }