init ninedocker
This commit is contained in:
125
volume/nextcloud/nine/app/user_cas/appinfo/app.php
Normal file
125
volume/nextcloud/nine/app/user_cas/appinfo/app.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - user_cas
|
||||
*
|
||||
* @author Felix Rupp <kontakt@felixrupp.com>
|
||||
* @copyright Felix Rupp <kontakt@felixrupp.com>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
use OCA\UserCAS\AppInfo\Application;
|
||||
use OCA\UserCAS\Service\AppService;
|
||||
use OCA\UserCAS\Service\LoggingService;
|
||||
use OCA\UserCAS\Service\UserService;
|
||||
|
||||
/** @var Application $app */
|
||||
$app = new Application();
|
||||
$c = $app->getContainer();
|
||||
|
||||
$requestUri = (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '');
|
||||
|
||||
if (\OC_App::isEnabled($c->getAppName()) && !\OC::$CLI) {
|
||||
|
||||
/** @var UserService $userService */
|
||||
$userService = $c->query('UserService');
|
||||
|
||||
/** @var AppService $appService */
|
||||
$appService = $c->query('AppService');
|
||||
|
||||
# Check for valid setup, only enable app if we have at least a CAS host, port and path
|
||||
if ($appService->isSetupValid()) {
|
||||
|
||||
// Register User Backend
|
||||
$userService->registerBackend($c->query('Backend'));
|
||||
|
||||
$loginScreen = (strpos($requestUri, '/login') !== FALSE && strpos($requestUri, '/apps/user_cas/login') === FALSE);
|
||||
$publicShare = (strpos($requestUri, '/index.php/s/') !== FALSE && $appService->arePublicSharesProtected());
|
||||
|
||||
if ($requestUri === '/' || $loginScreen || $publicShare) {
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') { // POST is used for single logout requests
|
||||
|
||||
// Register UserHooks
|
||||
$c->query('UserHooks')->register();
|
||||
|
||||
// URL params and redirect_url cookie
|
||||
setcookie("user_cas_enforce_authentication", "0", 0, '/');
|
||||
$urlParams = '';
|
||||
|
||||
if (isset($_REQUEST['redirect_url'])) {
|
||||
|
||||
$urlParams = $_REQUEST['redirect_url'];
|
||||
// Save the redirect_rul to a cookie
|
||||
$cookie = setcookie("user_cas_redirect_url", "$urlParams", 0, '/');
|
||||
}
|
||||
|
||||
// Register alternative LogIn
|
||||
$appService->registerLogIn();
|
||||
|
||||
/** @var boolean $isEnforced */
|
||||
$isEnforced = $appService->isEnforceAuthentication($_SERVER['REMOTE_ADDR'], $requestUri);
|
||||
|
||||
// Check if public share, if yes, enforce regardless the enforce-flag
|
||||
if($publicShare) {
|
||||
$isEnforced = true;
|
||||
}
|
||||
|
||||
// Check for enforced authentication
|
||||
if ($isEnforced && (!isset($_COOKIE['user_cas_enforce_authentication']) || (isset($_COOKIE['user_cas_enforce_authentication']) && $_COOKIE['user_cas_enforce_authentication'] === '0'))) {
|
||||
|
||||
/** @var LoggingService $loggingService */
|
||||
$loggingService = $c->query("LoggingService");
|
||||
|
||||
$loggingService->write(LoggingService::DEBUG, 'Enforce Authentication was: ' . $isEnforced);
|
||||
setcookie("user_cas_enforce_authentication", '1', 0, '/');
|
||||
|
||||
// Initialize app
|
||||
if (!$appService->isCasInitialized()) {
|
||||
|
||||
try {
|
||||
|
||||
$appService->init();
|
||||
|
||||
//if (!\phpCAS::isAuthenticated()) {
|
||||
|
||||
$loggingService->write(LoggingService::DEBUG, 'Enforce Authentication was on and phpCAS is not authenticated. Redirecting to CAS Server.');
|
||||
|
||||
$cookie = setcookie("user_cas_redirect_url", urlencode($requestUri), 0, '/');
|
||||
|
||||
header("Location: " . $appService->linkToRouteAbsolute($c->getAppName() . '.authentication.casLogin'));
|
||||
die();
|
||||
//}
|
||||
|
||||
} catch (\OCA\UserCAS\Exception\PhpCas\PhpUserCasLibraryNotFoundException $e) {
|
||||
|
||||
$loggingService->write(LoggingService::ERROR, 'Fatal error with code: ' . $e->getCode() . ' and message: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
# Filter DAV requests
|
||||
if(strpos($requestUri, '/remote.php') === FALSE && strpos($requestUri, '/webdav') === FALSE && strpos($requestUri, '/dav') === FALSE) {
|
||||
// Register UserHooks
|
||||
$c->query('UserHooks')->register();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
$appService->unregisterLogIn();
|
||||
}
|
||||
}
|
45
volume/nextcloud/nine/app/user_cas/appinfo/info.xml
Normal file
45
volume/nextcloud/nine/app/user_cas/appinfo/info.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0"?>
|
||||
<info>
|
||||
<id>user_cas</id>
|
||||
<name>CAS user and group backend</name>
|
||||
<description>This app provides in-depth features to authenticate and authorize users against a [jasig/apereo Central Authentication Server (CAS)](https://www.apereo.org/projects/cas). The app provides all necessary options needed to connect to your CAS instance and also advanced features to manage the groups accessible by your CAS infrastructure to implement an authorization feature. This version supports ECAS instances used by the European Commission. Additionally this version supports ActiveDirectory (LDAP) import via commandline. Commercial support for user_cas is available through ownCloud GmbH and myself personally.</description>
|
||||
<summary>Authenticate users against an jasig/apereo CAS Server (https://github.com/apereo/cas)</summary>
|
||||
<licence>AGPL</licence>
|
||||
<screenshot>https://raw.githubusercontent.com/felixrupp/user_cas/master/.github/SCREENSHOTS/splashscreen.png</screenshot>
|
||||
<author>Felix Rupp</author>
|
||||
<namespace>UserCAS</namespace>
|
||||
<version>2.0</version>
|
||||
<types>
|
||||
<prelogin/>
|
||||
<authentication/>
|
||||
</types>
|
||||
|
||||
<category>security</category>
|
||||
|
||||
<website>https://github.com/felixrupp/user_cas</website>
|
||||
|
||||
<documentation>
|
||||
<user>https://github.com/felixrupp/user_cas/blob/master/README.md</user>
|
||||
<admin>https://github.com/felixrupp/user_cas/blob/master/README.md</admin>
|
||||
<developer>https://github.com/felixrupp/user_cas/blob/master/README.md</developer>
|
||||
</documentation>
|
||||
|
||||
<bugs>https://github.com/felixrupp/user_cas/issues</bugs>
|
||||
|
||||
<repository type="git">https://github.com/felixrupp/user_cas.git</repository>
|
||||
|
||||
<dependencies>
|
||||
<owncloud min-version="10.0" max-version="10.10"/>
|
||||
<nextcloud min-version="14" max-version="27.1"/>
|
||||
</dependencies>
|
||||
|
||||
<commands>
|
||||
<command>OCA\UserCAS\Command\CreateUser</command>
|
||||
<command>OCA\UserCAS\Command\UpdateUser</command>
|
||||
<command>OCA\UserCAS\Command\ImportUsersAd</command>
|
||||
</commands>
|
||||
|
||||
<settings>
|
||||
<admin>OCA\UserCAS\Panels\Admin</admin>
|
||||
</settings>
|
||||
</info>
|
34
volume/nextcloud/nine/app/user_cas/appinfo/routes.php
Normal file
34
volume/nextcloud/nine/app/user_cas/appinfo/routes.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - user_cas
|
||||
*
|
||||
* @author Felix Rupp <kontakt@felixrupp.com>
|
||||
* @copyright Felix Rupp <kontakt@felixrupp.com>
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\UserCAS\AppInfo;
|
||||
|
||||
/** @var \OCA\UserCAS\AppInfo\Application $application */
|
||||
$application = new \OCA\UserCAS\AppInfo\Application();
|
||||
$application->registerRoutes($this, array(
|
||||
'routes' => [
|
||||
array('name' => 'settings#saveSettings', 'url' => '/settings/save', 'verb' => 'POST'),
|
||||
array('name' => 'authentication#casLogin', 'url' => '/login', 'verb' => 'GET'),
|
||||
array('name' => 'authentication#casLogout', 'url' => '/login', 'verb' => 'POST')
|
||||
]
|
||||
));
|
Reference in New Issue
Block a user