Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/user_saml.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'appinfo/app.php')
-rw-r--r--appinfo/app.php35
1 files changed, 29 insertions, 6 deletions
diff --git a/appinfo/app.php b/appinfo/app.php
index e59d594e..88fd027b 100644
--- a/appinfo/app.php
+++ b/appinfo/app.php
@@ -21,6 +21,13 @@
require_once __DIR__ . '/../3rdparty/vendor/autoload.php';
+// If we run in CLI mode do not setup the app as it can fail the OCC execution
+// since the URLGenerator isn't accessible.
+if(OC::$CLI) {
+ return;
+}
+
+
$urlGenerator = \OC::$server->getURLGenerator();
$config = \OC::$server->getConfig();
$request = \OC::$server->getRequest();
@@ -32,7 +39,7 @@ $samlSettings = new \OCA\User_SAML\SAMLSettings(
$userBackend = new \OCA\User_SAML\UserBackend(
$config,
- \OC::$server->getURLGenerator(),
+ $urlGenerator,
\OC::$server->getSession(),
\OC::$server->getDb()
);
@@ -41,17 +48,33 @@ OC_User::useBackend($userBackend);
OC_User::handleApacheAuth();
// Setting up the one login config may fail, if so, do not catch the requests later.
-try {
- $oneLoginSettings = new \OneLogin_Saml2_Settings($samlSettings->getOneLoginSettingsArray());
-} catch(OneLogin_Saml2_Error $e) {
+$returnScript = false;
+$type = '';
+switch($config->getAppValue('user_saml', 'type')) {
+ case 'saml':
+ try {
+ $oneLoginSettings = new \OneLogin_Saml2_Settings($samlSettings->getOneLoginSettingsArray());
+ } catch (OneLogin_Saml2_Error $e) {
+ $returnScript = true;
+ }
+ $type = 'saml';
+ break;
+ case 'environment-variable':
+ \OC::$server->getSession()->set('user_saml.samlUserData', $_SERVER);
+ $type = 'environment-variable';
+ break;
+}
+
+if($returnScript === true) {
return;
}
$redirectSituation = false;
-
// All requests that are not authenticated and match against the "/login" route are
// redirected to the SAML login endpoint
-if(!$userSession->isLoggedIn() && \OC::$server->getRequest()->getPathInfo() === '/login') {
+if(!$userSession->isLoggedIn() &&
+ \OC::$server->getRequest()->getPathInfo() === '/login' &&
+ $type === 'saml') {
$redirectSituation = true;
}